SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2011
    Location
    Kuching, Sarawak
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Select Statement for Oracle

    Good day for all,

    I have used MySQL database for my previous projects but now I need to try some on oracle.
    At the beginner to the Oracle, I decide to familiarize myself with oracle by testing my previous projects in Oracle instead of MySQL.

    I have the select statement here in the 'try' block which I have used in the java bean.

    Here's the code:

    Code:
    String strQry   = "SELECT T_STAFF*, T_DEPARTMENT.CODE, T_ROLE.CODE, T_STATUS.CODE, ";
          strQry          += "T_DEPARTMENT.DESCRIPTION, T_ROLE.DESCRIPTION, T_STATUS.DESCRIPTION ";
          strQry          += "FROM T_DEPARTMENT, T_ROLE, T_STATUS, T_STAFF ";
          strQry          += "WHERE STAFF_NAME = '"+strUserName+"' ";
          strQry          += "AND T_STAFF.STAFF_DEPARTMENT_OBJECTID = T_DEPARTMENT.OBJECTID ";
          strQry          += "AND T_STAFF.STAFF_ROLE_OBJECTID = T_ROLE.OBJECTID ";
          strQry          += "AND T_STAFF.STAFF_STATUS_OBJECTID = T_STATUS.OBJECTID ";
          rs = stmt.executeQuery(strQry);
    I need to know, can I use the same string above for Oracle? If no, how should the string look like?

    Thanks in advance.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,241
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by Php Beginner View Post
    I need to know, can I use the same string above for Oracle?
    of course

    except for this asterisk here --
    Code:
    SELECT T_STAFF*, ...
    that's gonna barf in every database system, including mysql

    also, you should really learn JOIN syntax, and stop using the deprecated comma list style joins
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2011
    Location
    Kuching, Sarawak
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    except for this asterisk here --
    Code:
    SELECT T_STAFF*, ...
    that's gonna barf in every database system, including mysql
    Sorry, my mistake. it should be SELECT T_STAFF.*

    Thanks for the explanation.

  4. #4
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,179
    Mentioned
    65 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by Php Beginner View Post
    Sorry, my mistake. it should be SELECT T_STAFF.*

    Thanks for the explanation.
    http://stackoverflow.com/questions/3...idered-harmful


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •