Oracle to T-SQL statement

Short version of a long story. I am trying to use T-SQL to write a number of create statements to be used in an Oracle database. The Oracle statement that I would use to get the output I am looking for is:
select 'comment on column someschema.'||table_name||'.'||column_name||' is '''||comments||''';'
from dba_col_comments
where comments is not null
and owner ='SOMESCHEMA'
order by table_name;
However, my feeble attempts (based on numerous web searches, I am an Oracle DBA, not SQL Server) have produced this so far:
SELECT 'comment on column someschema.'+B.TABLE_NAME+'.',A.objname+' '''+cast(A.value as varchar)+''';' as value
FROM fn_listextendedproperty('MS_DESCRIPTION','schema','dbo','table','SOMETABLE','column',default)
as A, INFORMATION_SCHEMA.TABLES as B
where value is not null
GO
This does not produce the output I need. This requires that I explicitly provide the table name for each table. I want this to be pulled dynamically as in the Oracle code. It also complains when I try to concatenate the '.' and A.objname with a +.
It only runs when I put that into a separate column using the comma.
I appreciate any suggestions anyone can provide.

kalffiend,
check if this works :
--check this
SELECT 'comment on column '+ sch.name+'.'+t.name+'.'+c.name+' is"'+ cast(value as varchar)+'";'
FROM sys.extended_properties AS ep
INNER JOIN sys.objects AS t ON ep.major_id = t.object_id
INNER JOIN sys.schemas sch ON sch.schema_id=t.schema_id
INNER JOIN sys.columns AS c ON ep.major_id = c.object_id
AND ep.minor_id = c.column_id
WHERE class = 1
(couldn't test sorry)
check this as well fr reference:
http://technet.microsoft.com/en-us/library/ms186989(v=sql.105).aspx
Thanks,
Jay
<If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

Similar Messages

  • Oracle Date in SQL Statement.

    Hello,
        We are having performance issues with some reports using conditions on date fields in the Record Selection Formula. Our application does not use the time portion of the date fields very often. When Crystal Reports builds the SQL statement to Oracle it uses a range condition to include all the possible time values. This practice makes a big difference compared to a direct condition
         Example:   SELECT "TABLE_A"."ID"
                           FROM   "TABLE_A"
                           WHERE  ("TABLE_A"."DT">= TO_DATE('2011-03-31 00:00:00','YYYY-MM-DD HH24:MI:SS') AND
                                          "TABLE_A"."DT"< TO_DATE('2011-04-01 00:00:00','YYYY-MM-DD HH24:MI:SS'))
         Is there a way to tell Crystal not to perform range validation on dates?
         We would like to have a SQL Statment that looks like:
                           SELECT "TABLE_A"."ID"
                           FROM   "TABLE_A"
                           WHERE  ("TABLE_A"."DT" = TO_DATE('2011-03-31'))
        We are on Oracle 11 with Crystal Report for VS2010 Sp1.
    Thank you.
    Charles

    Have a look at the kbase below. I think this is a throwback to the fact that we can't handle the milliseconds in the DateTime. So, in order to ensure we get the correct data we search on a range plus one second of what you asked for.
    [1217417 - SQL query shows '&lt;' for a DateTime field filter although '&lt;=' was selected |http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_bi/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333233313337333433313337%7D.do]

  • Oracle 7 - Maximum SQL statement length

    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96536/ch44.htm#288033
    Like above, maximum SQL Statement Length is clearly defined on the "Reference" document of Oracle 8, 9, and 10.
    But I could not find it for Oracle 7.
    Can someone help me?

    This info is available in the Oracle 7 Server Reference. It can be found via http://otn.oracle.com/documentation. Look at the "Previously Released Oracle Documentation" to access it. It's a pdf. Here's a direct link: http://download-uk.oracle.com/docs/pdf/A32589_1.pdf. The details can be found in chapter 5.
    It comes down to this: 64k.
    MHE

  • Oracle Spatial operator SQL statement help

    I have a 3D elevation point feature class (elev) and a polygon feature class (Building) loaded in Oracle Spatial. I am trying to update the "HEIGHT" attribute of the "Building" Feature class using the average elevation of "elev" feature class. Here below is the SQL statement I used, which generated the same value for all buildings. The avg(elevation) returns the average elevation of all points within all building polygons, not all points within ONE polygon.
    Please help and thanks.
    update building
    set height = (select avg(elevation)
    from elev e, building b
    where sdo_anyinteract(e.shape, b.shape) = 'TRUE');

    Hi,
    try this
    update building b
    set height = (select avg(elevation)
    from elev e where sdo_anyinteract(e.shape, b.shape) = 'TRUE');
    Udo

  • Using bind variables with sql statements

    We connect from a VB 6.0 program via OO4O to an Oracle 8.1.7 database, using bind variables in connection with select statements. Running ok, but performance again by using bind vars not as good as expected!
    When looking into the table v$sqlarea, we were able to detect the reason. We expected that our program submits the sql statement with bind vars, Oracle parses this once, and with each select statement again, we do not have a reparse. But: It seems that with each new session Oracle reparses the sql statement, that is, Oracle is not able to memorize or cache bind vars and statements. Even more worrying, this kind of behaviour was visible with each new dynaset, but the same database/session.
    Is there anybody our there with an idea of what is happening here?
    Code snippet:
    Dim OraSession As OracleInProcServer.OraSessionClass
    Dim OraDatabase As OracleInProcServer.OraDatabase
    Set OraSession = CreateObject("OracleInProcServer.XOraSession")
    Set OraDatabase = OraSession.OpenDatabase(my database", "my connect", 0&)
    OraDatabase.Parameters.Add "my_bind", 0, ORAPARM_INPUT
    OraDatabase.Parameters("my_bind").DynasetOption = ORADYN_NOCACHE
    OraDatabase.Parameters("my_bind").serverType = ORATYPE_NUMBER ' Bind Var Type
    Dim RS As OracleInProcServer.OraDynaset
    strSQLstatement= "Select * from my_table where igz= [my_bind] "
    Set RS = OraDatabase.CreateDynaset(strSQLstatement, &H4)
    OraDatabase.Parameters("my_bind").Value = myValue
    RS.Refresh
    Cheers and thanks a lot :)
    Michael Sonntag

    We connect from a VB 6.0 program via OO4O to an Oracle 8.1.7 database, using bind variables in connection with select statements. Running ok, but performance again by using bind vars not as good as expected!
    When looking into the table v$sqlarea, we were able to detect the reason. We expected that our program submits the sql statement with bind vars, Oracle parses this once, and with each select statement again, we do not have a reparse. But: It seems that with each new session Oracle reparses the sql statement, that is, Oracle is not able to memorize or cache bind vars and statements. Even more worrying, this kind of behaviour was visible with each new dynaset, but the same database/session.
    Is there anybody our there with an idea of what is happening here?
    Code snippet:
    Dim OraSession As OracleInProcServer.OraSessionClass
    Dim OraDatabase As OracleInProcServer.OraDatabase
    Set OraSession = CreateObject("OracleInProcServer.XOraSession")
    Set OraDatabase = OraSession.OpenDatabase(my database", "my connect", 0&)
    OraDatabase.Parameters.Add "my_bind", 0, ORAPARM_INPUT
    OraDatabase.Parameters("my_bind").DynasetOption = ORADYN_NOCACHE
    OraDatabase.Parameters("my_bind").serverType = ORATYPE_NUMBER ' Bind Var Type
    Dim RS As OracleInProcServer.OraDynaset
    strSQLstatement= "Select * from my_table where igz= [my_bind] "
    Set RS = OraDatabase.CreateDynaset(strSQLstatement, &H4)
    OraDatabase.Parameters("my_bind").Value = myValue
    RS.Refresh
    Cheers and thanks a lot :)
    Michael Sonntag

  • Oracle equivalent to SQL SERVER CLRClipString function

    Hello Friends,
    I am running the following sql query in SQL SERVER successfully ..
    select * from
    CLRSplitString('33,54,105,148,149,163,165,179,193,195,201,202,234,239,279,282,297,299,329,332,350,415,417,439,440,500,552,570,589,603,628,655', '', ',') x
    join dbo.PART_ADDL_INFO_NAMES_V v on x.col1 = v.addl_info_name_id
    I want to implement the same sql statement in ORACLE .
    I created the function that takes comma seperated string and display as single column .. I want to implemement in oracle as a sql statement ..
    create or replace function str2tbl
         (p_str in varchar2,
         p_delim in varchar2 default '.')
         return myTableType
    as
         l_str     long default p_str || p_delim;
         l_n     number;
         l_data myTableType := myTabletype();
    begin
         loop
         l_n := instr( l_str, p_delim );
         exit when (nvl(l_n,0) = 0);
         l_data.extend;
         l_data( l_data.count ) := ltrim(rtrim(substr(l_str,1,l_n-1)));
         l_str := substr( l_str, l_n+length(p_delim) );
         end loop;
         return l_data;
    end;
    DECLARE
    v_array mytabletype;
    BEGIN
    v_array := str2tbl ('10.01.03.04.234');
    FOR i IN 1 .. v_array.COUNT LOOP
         DBMS_OUTPUT.PUT_LINE (v_array(i));
    END LOOP;
    END;
    10
    01
    03
    04
    234
    appreciate your help ..
    thanks

    If you need to split a single string:
    with t as (
               select '33,54,105,148,149,163,165,179,193,195,201,202,234,239,279,282,297,299,329,332,350,415,417,439,440,500,552,570,589,603,628,655' str from dual
    select  regexp_substr(str,'[^,]+',1,level) sub_str
      from  t
      connect by level <= regexp_count(str,',') + 1
    SUB_STR
    33
    54
    105
    148
    149
    163
    165
    179
    193
    195
    201
    SUB_STR
    202
    234
    239
    279
    282
    297
    299
    329
    332
    350
    415
    SUB_STR
    417
    439
    440
    500
    552
    570
    589
    603
    628
    655
    32 rows selected.
    SQL> SY.
    P.S. REGEXP_COUNT is available in 11g only. If you are on 10g use:
    with t as (
               select '33,54,105,148,149,163,165,179,193,195,201,202,234,239,279,282,297,299,329,332,350,415,417,439,440,500,552,570,589,603,628,655' str from dual
    select  regexp_substr(str,'[^,]+',1,level) sub_str
      from  t
      connect by level <= length(regexp_replace(str,'[^,]')) + 1
    /

  • Precompiled SQL statement at client side ? (JDBC)

    Hi,
    Will Oracle support precompiled SQL statement for jdbc client ?
    Thanks

    A pre-compiled SQL statement on the client side makes absolutely no sense. Let's say the statement refers to system object id 1234 - the EMP table. But in the meantime the EMP table has been dropped and re-created as an index organised table and is now object id 7890.
    What about issues like scope, cost-based optimisation, etc?
    It honestly does not make the slightest sense to even want such a "pre-compiled client SQL" feature.
    > hmm.... Is there anyway to return the compiled SQL
    from database ?
    Yes - that is exactly what a cursor handle is. You give the database a SQL statement. It parses that and returns a SQL (aka cursor) handle for you to use and re-use.
    The typical (stateful) client would use the following template:
    -- open a database connection (usually returns a connection/session handle)
    hConnection = open DBconnection(params)
    -- parse/prepare a SQL statement (returns a SQL/cursor handle)
    hSQL = parseSQL( hConnection, 'INSERT INTO foo VALUES( :0, :1 )' )
    -- reuse the SQL statement
    while (Some_Condition)
    loop
    Some_Processing()
    -- bind values to the SQL statement variables
    SQLBind( hSQL, '0', var1)
    SQLBind( hSQL, '1', var2)
    -- execute the statement (it is not compiled or parsed again by the database)
    ExecSQL( hSQL )
    endloop

  • Adding a field to an sql statement in Oracle Reports error ORA-00933

    We have been requested to add a field that already exists in the table referred to by the sql statement in Oracle Reports Builder. The report was set up by a consultant about 3 yrs ago and we don't really have much skill in this area. What is happening when I try to modify the SQL statement, either adding a field or deleting a field to the SELECT statement, causes an error message preventing the statement from being saved. The only way out of the error message is to click Cancel. The error message is
    ORA-00933:SQL command not properly ended
    ORDER BY Program ==> NAME
    Even adding or deleting a space anywhere in the SQL statement causes the error (not adding any new fields). A coworker found that if we comment out the ORDER BY, the statement will accept the new field in the SELECT section, however then we lose the order by functionality. I would like to add one additional field before the FROM. Not sure if any additional data are needed. Thank you.
    SELECT p.person_uid PIDM_KEY, p.id_number ID,
                   p.full_name_lfmi name,            
                    p.BIRTH_DATE, p.GENDER Sex,
                    Decode(a.residency,'D',p.Primary_ethnicity,'F')  Ethn,
                    a.academic_period TERM,        
                    CASE WHEN :p_group_by = 'PROGRAM' THEN a.program
                                 ELSE ' '
                    END AS Program,
                    a.COLLEGE, a.degree, a.major, ' ' rule,
                    a.STUDENT_POPULATION,a.STUDENT_LEVEL,    a.application_status Status,  a.application_status_date app_sts_dte,
                    ad.decision_date1 Last_Dec_Date,
                    ad.decision1||' '||ad.decision2||' '|| ad.decision3||' '|| ad.decision4||' '|| ad.decision5 Decisions,
                    /*  Deposit Date uses the last term entered in :p_term parameter string */
                    (SELECT MAX(deposit_effective_date) FROM usf_as_deposit WHERE account_uid = a.person_uid &term_clause group by account_uid)   AS "DEPOSIT DATE",     
                    ph.phone as PHONE,
                    CASE WHEN PS.FIRST_CONTACT IN ('NET','PAP','COM','COP') THEN PS.First_Contact
                     ELSE CASE WHEN ps.latest_contact IN ('NET','PAP','COM','COP') THEN PS.Latest_Contact
                                ELSE '  '
                                END
                    END AS FIRST_CONTACT,
                    DECODE(:p_address,'Y',REPLACE(adr.street1||' '||adr.street2||' '||adr.street3||' '||adr.city||','||adr.state||' '||adr.nation||' '||adr.zip,'  ',' '),' ') as  address, adr.nation, adr.state,
                    goremal_email_address email, a.residency, a.application_date, p.primary_ethnicity, c.cohort
    FROM MST_ADMISSIONS_APPLICATION A,
               MST_PERSON p,mst_pre_student PS,  Admissions_Cohort c, usf_v_phone_pr_ma ph,
               MST_admissions_decision_slot AD, usf_v_email, usf_v_address_dr_lr_ma_pr adr
    WHERE a.PERSON_UID = p.person_uid
            AND a.curriculum_priority  = 1
            AND a.person_uid = ps.person_uid
           AND a.person_uid = ad.person_Uid(+)
           AND a.person_uid = goremal_pidm(+)
           AND a.person_uid = adr.pidm(+)
           AND a.person_uid = ph.pidm(+)
           AND ph.rnum(+) = 1
           AND a.person_uid = c.person_uid(+)
           AND a.academic_period = c.academic_period(+)
      &Where_Clause
           /*    TAKE OUT FOLLOWING LINE AFTER DATA IS CLEANED UP  */
            AND NOT(p.id_number = '00000000'   OR SUBSTR(p.id_number,1,1) = 'B'  OR UPPER(p.full_name_lfmi)  LIKE '%TESTING%')
           AND  a.application_status_date >= NVL(:p_as_of_date,sysdate-8000)
           AND a.academic_period = ad.academic_period(+)
            AND a.application_number = ad.application_number(+)
            AND a.degree <> 'ND'    /*   AND a.college <> 'LW'                         --  Does not need non-degree and law students    */
           &Cohort_Clause 
    ORDER BY Program  &ORDER_CLAUSE

    Hi Denis,
    I tried your suggestion. The good thing is that adding the comma allowed me to be able to add a.campus to the select statement, unfortunately, another error message happened.
    ORA-00936: missing expression SELECT p . person_uid PIDM_KEY ,
    p . id_number , p . full_name_lfmi name , p . BIRTH_DATE , p . GENDER Sex ,
    Decode ( a . residency , 'D' , p . Primary_Ethnicity , 'F' ) Ethn , a . academic_period TERM ,
    CASE WHEN : P_group_by = 'PROGRAM THEN a I started over and tried only putting in the comma and get the same message even though I didn't add campus. After that, removed the comma which led to the ORA-00933 error message. So once again, I had to close the file without saving, in order for the report to run at all.

  • [0098]SQL*Plus encountered oracle error 100 while executing SQL Statement

    Hi,
    i'm trying to delete duplicate records from a table and running following script. this script is triggered from a unix script. it successfully deletes the records but in the last throws following error message,
    :[0098]SQL*Plus encountered oracle error 100 while executing SQL Statement:2:Investigation required:
    can anybody please help? below is the script.
    DECLARE
    --CURSOR FOR DUPLICATE ROWS
    CURSOR CUR_DUPLICATE_ROWS IS
    Select RMS_NOTE_ID, RMS_SUMMARY_NOTE_ID, count(*) cnt from PARTY_NOTE
    group by RMS_NOTE_ID,RMS_SUMMARY_NOTE_ID having count(*) > 1;
    var_date PARTY_NOTE.PARTY_NOTE_CREATED_DATE%TYPE;
    BEGIN
    FOR DUPLICATE_ROWS_REC IN CUR_DUPLICATE_ROWS
    LOOP
    delete from party_note
    where RMS_NOTE_ID= DUPLICATE_ROWS_REC.RMS_NOTE_ID
    and RMS_SUMMARY_NOTE_ID= DUPLICATE_ROWS_REC.RMS_SUMMARY_NOTE_ID
    and rowid not in (select max(rowid) from party_note
    where RMS_NOTE_ID= DUPLICATE_ROWS_REC.RMS_NOTE_ID and RMS_SUMMARY_NOTE_ID= DUPLICATE_ROWS_REC.RMS_SUMMARY_NOTE_ID);
    commit;
    END LOOP;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE(SQLERRM);
    ROLLBACK;
    END;

    Try this:
    delete party_note
    where  rowid not in (select max(rowid)
                         from   party_note
                         group  by rms_note_id, rms_summary_note_id
    commit;No need for cursors and loops.
    And when that's completed, consider ALTERing the table to add a unique index (or even a primary key) so you'll never need to do this again.

  • Unable to connect SQL State=S1000 [Oracle][ODBC][Ora]ORA-12170:

    Hi all,
    I have an Windows XP OS with SP3.
    I have installed the Oracle 11g server.
    On trying to connect to the ODBC connection, i get the following error message:
    Unable to connect SQL State=S1000 [Oracle][ODBC][Ora]ORA-12170: TNS: Connect timeout occured
    On trying the tnsping,
    TNS Ping Utility for 32-bit Windows: Version 11.1.0.6.0 - Production on 09-OCT-2
    011 13:11:05
    Copyright (c) 1997, 2007, Oracle. All rights reserved.
    Used parameter files:
    E:\app\Gautam\product\11.1.0\db_1\network\admin\sqlnet.ora
    Used TNSNAMES adapter to resolve the alias
    Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.
    5.207)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl))
    TNS-12535: TNS:operation timed out
    On trying to connect with SQL Developer, i get the following error:
    Status: Failure - Test failed: Io Exception: The Network Adapter could not establish the connection
    However i am able to connect to the same using SQL Plus
    Another issue that occurs is that the Oracle Enterprise Manager shows the following error after a while:
    Agent Connection to Instance
    Status Failed
    Details ORA-12505: TNS:listener does not currently know of SID given in connect descriptor (DBD ERROR: OCIServerAttach)
    The following services are all up during this point of time:
    OracleDBConsoleorcl
    OracleOraDb11g_home1TNSListener
    OracleServiceORCL
    Any help in this regard will be very useful as this is hindering the progress of my work.
    Thanks in advance for the help.
    - Gautam

    841683 wrote:
    Hi,
    I did try and delete my listener.ora and then create a new one..
    That did not solve my issue..
    What are the steps for configuring the listener again.
    Thanks for the response..
    - Gautamno listener.ora file is required.
    just do as below
    lsnrctl start

  • Run a PL/SQL statement in an Oracle Alert action?

    Hello
    did anyone know is it possible to run a PL/SQL statement in an Oracle Alert action?
    I can run an SQL like “UPDATE Table SET alert_run = 'ok' where id = 10;” but if I run instead of this the following
    “Select XXKN_TEST.UPDATE_XXX_TEST('&USER_NAME') From dual;”
    I get the following error log:
    Alert: Version : 11.5.0
    Copyright (c) 1979, 1999, Oracle Corporation. All rights reserved.
    ALECDC module: Check Periodic Alert
    PL/SQL procedure successfully completed.
    XXKN_TEST.UPDATE_XXX_TEST('GROSS2')
    ERROR at line 2:
    ORA-00904: "XXKN_TEST"."UPDATE_XXX_TEST": invalid identifier
    APP-ALR-04020: Oracle Alert was unable to execute "&VALUE". Check that this file exists and that its read protection is set correctly.
    Many thanks for your help,
    Alois

    Hello Suresh,
    I tried your suggestion but it doesn't work.
    The PL/SQL procedure was successfully completed but no data was modified.
    Are you sure that running a PL/SQL is possible in an alert action?
    Kind Regards,
    Alois

  • How to use a Sybase table in Oracle SQL statement?

    How to use a Sybase table in Oracle SQL statement?
    Sybase version : 11.9.2.4
    Oracle version : 10.2.05
    Thanks.

    user12088323 wrote:
    How to use a Sybase table in Oracle SQL statement?
    Sybase version : 11.9.2.4
    Oracle version : 10.2.05
    Thanks.Any Oracle client connected to the Oracle database can access Sybase data through the <font style="background-color: #FFFFCC">Database Gateway for Sybase</font> (it requires an additional license) or the <font style="background-color: #FFFFCC">Database gateway for ODBC</font> (it's free).
    The Oracle client and the Oracle database can reside on different machines. The gateway accepts connections only from the Oracle database.
    A connection to the gateway is established through a database link when it is first used in an Oracle session. In this context, a connection refers to the connection between the Oracle database and the gateway. The connection remains established until the Oracle session ends. Another session or user can access the same database link and get a distinct connection to the gateway and Sybase database.
    Database links are active for the duration of a gateway session. If you want to close a database link during a session, you can do so with the ALTER SESSION statement.
    To access the Sybase server, you must create a <font style="background-color: #FFFFCC">database link</font>. A public database link is the most common of database links.
    SQL> CREATE PUBLIC DATABASE LINK dblink CONNECT TO
    2  "user" IDENTIFIED BY "password" USING 'tns_name_entry';
    --dblink is the complete database link name.
    --tns_name_entry specifies the Oracle Net connect descriptor specified in the tnsnames.ora file that identifies the gatewayAfter the database link is created you can verify the connection to the Sybase database, as follows:
    SQL> SELECT * FROM DUAL@dblink;
    Configuring Oracle Database Gateway for Sybase
    <font style="background-color: #FFFFCC">{message:id=10649126}</font>

  • SQL statement in Oracle

    As I know in SQL server, i can create a field called customer name, can be two words. But in the SQL statement I need to use double quote to quote the customer name, such like: select * from "customer name"
    Can Oracle accept two words field name or table name. If Yes, then do I need to use double quote, or single quote or other things?

    As I know in SQL server, i can create a field called
    customer name, can be two words. But in the SQL
    statement I need to use double quote to quote the
    customer name, such like: select * from "customer
    name"
    Can Oracle accept two words field name or table name.
    If Yes, then do I need to use double quote, or single
    quote or other things?Yes, you can do it.
    However, most DBAs (even MS SQL Server ones) will tell you that that is bad form.
    And of course the reason for doing that should never be because those field names are being displayed. Displaying field names breaks every model that seperates data from display (GUI.)

  • Oracle Parsing SQL Statement in ANSI or Oracle Format

    I have problem with a Query ..It seems to be Oracle Bugs .
    When I enter below simple Query (in Oracle Join format ), It works properly
    select * from (
    select dept.*,emp.ename from dept,emp
    where dept.deptno=emp.deptno(+)
    where deptno in
    select deptno a from
    select deptno,dname from dept where deptno=10
    UNION ALL
    select deptno,dname from dept where deptno=20
    But When I changed it and use it in ANSI Format ,it is not parsed and shows me ORA-00920: invalid relational operator error ......
    Below shows the changes that I have made to convert it to ANSI Format.
    select * from (
    select dept.*,emp.ename from dept
    left outer join emp on (emp.deptno=dept.deptno)
    where (deptno) in
    select deptno a from
    select deptno,dname from dept where deptno=10
    UNION ALL
    select deptno,dname from dept where deptno=20
    It seems to be Oracle bugs.I appreciate everybody to help me.
    ( Comments : I use Oracle 9i R2 on Windows and I can not change the SQL statement
    because it is created dynamically)
    Best regards

    This sort of technical question needs to be addressed to one of the technical forums. Products | Database | SQL and PL/SQL would seem to be appropriate here.
    Have you tried applying the latest patchset for your database? Seems to work for me on 9.2.0.5
    SCOTT @ HP92 Local> select * from (
      2  select dept.*,emp.ename from dept
      3  left outer join emp on (emp.deptno=dept.deptno)
      4  )
      5  where (deptno) in
      6  (
      7  select deptno a from
      8  (
      9  select deptno,dname from dept where deptno=10
    10  UNION ALL
    11  select deptno,dname from dept where deptno=20
    12  )
    13  )
    14  /
        DEPTNO DNAME          LOC           ENAME
            10 ACCOUNTING     NEW YORK      CLARK
            10 ACCOUNTING     NEW YORK      KING
            10 ACCOUNTING     NEW YORK      MILLER
            20 RESEARCH       DALLAS        SMITH
            20 RESEARCH       DALLAS        JONES
            20 RESEARCH       DALLAS        SCOTT
            20 RESEARCH       DALLAS        ADAMS
            20 RESEARCH       DALLAS        FORD
    8 rows selected.
    SCOTT @ HP92 Local> select * from v$version;
    BANNER
    Oracle9i Enterprise Edition Release 9.2.0.5.0 - Production
    PL/SQL Release 9.2.0.5.0 - Production
    CORE    9.2.0.6.0       Production
    TNS for 32-bit Windows: Version 9.2.0.5.0 - Production
    NLSRTL Version 9.2.0.5.0 - ProductionJustin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Where to run SQL statements in Oracle Database 11gR1 ?

    Folks,
    Hello. I have just installed Oracle Database 11gR1 and login to Database Control page. There are 4 tabs on the top: Database, Setup, Preference, Help and Logout.
    I just create a table "table1" in "Database" tap. But I don't see anywhere to run SQL statement such as Select, Insert, Update.
    Can any folk tell me where to run SQL statements in Oracle Database 11gR1 ?
    Or
    Can any folk provide a User Manual for Oracle DB 11gR1 ?

    You can run from a terminal or install an SQL client and connect from there.
    http://www.articlesbase.com/databases-articles/how-to-install-oracle-11g-client-1793770.html
    Best Regards
    mseberg
    Assuming you have an oracle OS user on Linux you can try typing sqlplus at you OS command prompt. Generally you will have a .bash_profile with setting like this:
    # User specific environment and startup programs
    PATH=$PATH:$HOME/bin
    export PATH
    # Oracle Settings
    TMP=/tmp; export TMP
    TMPDIR=$TMP; export TMPDIR
    export ORACLE_BASE=/u01/app/oracle
    export ORACLE_HOME=/u01/app/oracle/product/11.2.0
    #export DISPLAY=localhost:0.0
    export TZ=CST6CDT 
    export ORACLE_SID=ORCL
    export ORACLE_TERM=xterm
    #export TNS_ADMIN= Set if sqlnet.ora, tnsnames.ora, etc. are not in $ORACLE_HOME/network/admin
    export NLS_LANG=AMERICAN;
    LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
    export LD_LIBRARY_PATH
    # Set shell search paths
    PATH=/usr/sbin:$PATH; export PATH
    export PATH=$PATH:$ORACLE_HOME/bin
    # CLASSPATH:
    CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
    CLASSPATH=$CLASSPATH:$ORACLE_HOME/network/jlib
    export EDITOR=vi
    set -o vi
    PS1='$PWD:$ORACLE_SID >'Edited by: mseberg on Jul 11, 2011 3:18 PM

Maybe you are looking for

  • F-28 : Clearing open items

    Hi, in Tcode F-28 i select one item (Customer invoice) = 1500 EUR to clear it with an incoming payment = 1490 EUR, then i enter the difference of 10 EUR in Residual items table and i enter the reason code. when i save i get this error message : " Onl

  • Using Admin Center/Process Administrator inside BPM Studio

    Hi, I have a process where we have included many jars and external resources as well as we are using the External Task - Portal for our JSP's? Also the users are such that they cannot be included inside of Studio Users. We therefore cannot test the p

  • Install left problems HOW CAN I GET BACK TO TIGER FROM LEOPARD?

    so i upgraded from tiger to leopard, then i had a few problems, i.e. itunes would quit everytime i tried to delete a podcast, or editing multiple song info would make it crash. My ms word continously crashes as well as ichat. So since i really need t

  • Aperture 3: Geotagged Photos show up in wrong part of world

    I imported a set of geotagged photos. When I look at places in Aperture 3 several of the photos are appearing in the wrong part of the world ( Kazakhstan instead of Nova Scotia). The photos were taken / geotagged by my Blackberry Storm. When I travel

  • SQL unicode to XML using XMLForest

    I'm using XMLForest to retrieve some data from the db. One of the columns has unicode characters such as "Ă". I use XMLForest to read in this data, but the result turns this Ă into a "?". How do I keep the unicode format? I need to output this xml to