Inner Join in oracle 10g

Is it possible to use inner join in oracle 10g?

SQL> select ename, dname
  2  from emp inner join dept
  3  on emp.deptno=dept.deptno;
ENAME      DNAME
SMITH      RESEARCH
ALLEN      SALES
WARD       SALES
JONES      RESEARCH
MARTIN     SALES
BLAKE      SALES
CLARK      ACCOUNTING
SCOTT      RESEARCH
KING       ACCOUNTING
TURNER     SALES
ADAMS      RESEARCH
ENAME      DNAME
JAMES      SALES
FORD       RESEARCH
MILLER     ACCOUNTING
14 rows selected.
SQL>

Similar Messages

  • Perform an Inner Join in Oracle 8

    We have to make our application (that runs with Oracle 9i) backward compatible with Oracle 8.
    There are certain SQL statements that were introduced in Oracle 9i, such as Inner Join (Oracle 9i now allows more of the ANSI standard SQL that MS SQL also uses)
    Does anyone know of the other differences I should look out for, or any documentation that lists the new 9i differences that we may already be using.
    I have trawled through lots of OTN documentation, but not been able to find anything that highlights even the Inner Join problem.
    If there are any documents that also suggest a solution, that would be even better.
    Thanks in advance for any help/suggestion
    Mark

    You have a parameter called "COMPATIBLE", and if you set to, for example 8.1.7 in your 9i database, then your application should be compatible with 8.1.7. It is that easy!
    Of course, by doing so, you renounce to use the 9i features.
    There is a book called "New Features" in the book list in your oracle documentation.
    Regards
    Laurent Schneider

  • Delete using joins in Oracle 10g

    Hi All
    I am trying to delete rows from a table by comparing the criteria required with the rows in different tables..
    The select statement below works fine...But when I use it for delete as shown in the subsequent SQL statement it errors out stating "SQL Command not properly ended"
    Can anybody provide suggestions?....
    This works fine
    select rp.emplid,rp.empl_rcd,rp.dur,rp.punch_type,dt.dur,
    TO_CHAR(CAST((rp.PUNCH_TIME) AS TIMESTAMP),'HH24.MI.SS.FF') AS PUNCH_TIME
    from
    ps_tl_rptd_time rp
    join ps_hd_dt_end_tmp4 dt on (rp.emplid = dt.emplid and rp.dur = dt.dur +1 AND(rp.punch_time = dt.PUNCH_TIME_8
    or rp.punch_time = dt.PUNCH_TIME_7
    or rp.punch_time = dt.PUNCH_TIME_6
    or rp.punch_time = dt.PUNCH_TIME_5
    or rp.punch_time = dt.PUNCH_TIME_4
    or rp.punch_time = dt.PUNCH_TIME_3
    or rp.punch_time = dt.PUNCH_TIME_2) )
    join ps_fo_empl_xref fo on (rp.emplid = fo.emplid and rp.empl_rcd = fo.empl_rcd and dt.pbm_asgn_id = fo.pbm_asgn_id)
    and TO_CHAR(CAST((rp.PUNCH_TIME) AS TIMESTAMP),'HH24.MI.SS.FF') BETWEEN '00.00.00.000000' AND '11.59.59.000000'
    While this below one doesnt work.....
    delete from
    ps_tl_rptd_time rp
    join ps_hd_dt_end_tmp4 dt on (rp.emplid = dt.emplid and rp.dur = dt.dur +1 AND(rp.punch_time = dt.PUNCH_TIME_8
    or rp.punch_time = dt.PUNCH_TIME_7
    or rp.punch_time = dt.PUNCH_TIME_6
    or rp.punch_time = dt.PUNCH_TIME_5
    or rp.punch_time = dt.PUNCH_TIME_4
    or rp.punch_time = dt.PUNCH_TIME_3
    or rp.punch_time = dt.PUNCH_TIME_2) )
    join ps_fo_empl_xref fo on (rp.emplid = fo.emplid and rp.empl_rcd = fo.empl_rcd)
    where dt.pbm_asgn_id = fo.pbm_asgn_id and
    TO_CHAR(CAST((rp.PUNCH_TIME) AS TIMESTAMP),'HH24.MI.SS.FF') BETWEEN '00.00.00.000000' AND '11.59.59.000000'
    ;

    may be
    delete from ps_tl_rptd_time rp
    where  exists (select 1
                   from   ps_hd_dt_end_tmp4 dt
                   where  rp.emplid = dt.emplid
                          and rp.dur = dt.dur + 1
                          and ( rp.punch_time = dt.punch_time_8
                                 or rp.punch_time = dt.punch_time_7
                                 or rp.punch_time = dt.punch_time_6
                                 or rp.punch_time = dt.punch_time_5
                                 or rp.punch_time = dt.punch_time_4
                                 or rp.punch_time = dt.punch_time_3
                                 or rp.punch_time = dt.punch_time_2 ))
           and exists (select 1
                       from   ps_fo_empl_xref fo
                       where  rp.emplid = fo.emplid
                              and rp.empl_rcd = fo.empl_rcd
                              and dt.pbm_asgn_id = fo.pbm_asgn_id)
           and to_char(cast(( rp.punch_time ) as timestamp), 'HH24.MI.SS.FF')
               between
               '00.00.00.000000' and '11.59.59.000000' 

  • Help:Nested Inner Join

    Hello Folks,
    I have a query which has a nested Inner Join as follows
    INNER JOIN(Client
    INNER JOIN CUBS SNAPSHOT ON Client . Client = CUBS SNAPSHOT . CLIENT) ON CancelDesc . CancelReason = CUBS SNAPSHOT . CANCELREASONcouldnt figure out wat is the quivalent of this nested inner join in Oracle Server. I am trying to create a report based on this inner join of a query. Can anyone throw some light on this.
    Thanks

    Hi,
    Inner joins don't need to be nested. The results will be the same, no matter in what order the tables are joined.
    In Oracle, don't use table names with spaces in them, and don't put spaces before or after the dots that separate table name qualifiers from column names.
    I think this is what you want:
    INNER JOIN     cubs_snapshot  ON     CancelDesc.CancelReason = cubs_snapshot.cancelreason
    INNER JOIN     Client            ON     Client.Client           = cubs_snapshot.clientWhenever you have a question, post a little sample data (CREATE TABLE and INSERT statememts) for all tables invlovled, and the results you want from that data.
    If you really did need to nest joins, you could join some tables in a sub-query, then use the result set of that sub-query as if it were a table.
    For example:
    WITH  cubs_and_client            AS
         SELECT     CancelReason
         ,     ...     -- Whatever other columns are needed in superior query or queries
         FROM          client
         INNER JOIN     cubs_snapshot     ON     Client.Client           = cubs_snapshot.client
    SELECT     
    INNER JOIN     cubs_and_client     ON     CancelDesc.CancelReason = cubs_and_client.CancelReason
    ...In this example, the two tables cubs_snapshot and client are joined in a sub-query. The results of that sub-query can be referenced later in the query as if it were a table called cubs_and_client, very much like a view.

  • Help: Modifying inner join

    Hello Folks,
    I have an Access Query and am rewriting the whole query in Oracle to run a report.The thing is Am a beginner in oracle and am scratching my head on how to modify this inner join. please help me in rewriting this inner join in oracle. thanks a million
       ((Debtor INNER JOIN MAX_TRANS_DATE AS MAX_TRANS_DATE_1 ON Debtor .
            EVENT_ID = MAX_TRANS_DATE_1.EVENT_ID) INNER JOIN
            TMP$ALL_RECOVERY_TYPE
            ON(Debtor . EVENT_CASE_ID = TMP$ALL_RECOVERY_TYPE . EVENT_CASE_ID) AND
            (Debtor . EVENT_ID = TMP$ALL_RECOVERY_TYPE . EVENT_ID))
    INNER JOIN CUBS TRANSACTIONS
        ON (Debtor . EVENT_ID = CUBS TRANSACTIONS . EVENT_ID)
       AND (Debtor . EVENT_CASE_ID = CUBS TRANSACTIONS . EVENT_CASE_ID)

    Thanks for getting back. But still am unable to get the correct data. I will try to break it down.
    Microsoft Access Table MAX_TRANS_DATE menitoned above in the inner join was originally coming from table called TRANSACTIONS i.e.( MAX_TRANS_DATE = SELECT [Transactions].[EVENT_ID], Max([Transactions].[TRANSDATE]) AS MaxOfTRANSDATE
    FROM Debtor INNER JOIN Transactions ON [Debtor].[EVENT_ID]=[Transactions].[EVENT_ID]
    GROUP BY [Transactions].[EVENT_ID];
    Here the problem is am recreating the access database query in oracle database and we dont have MAX_TRANS_DATE in the Oracle database but we do have TRANSACTIONS table.
    So i just used TRANSACTIONS in the inner join instead of MAX_TRANS_DATE.
    But the result is wrong.The Field Transdate from TRANSACTIONS is pulling dates as 10/5/2006 instead of 02/01/2010. I suspect something is wrong with the joins.Please help me. I can provide the old access query and the new oracle query that i have created.
    Thanks
    Edited by: user11961230 on Mar 5, 2010 11:49 AM

  • Can we make apply  join a column on which VPD policy applied in Oracle 10g

    Hi,
    i am planning to apply a column level security using VPD concept into Oracle 10g
    but i have a one doubt.
    Suppose i am going to apply a VPD policy based on user priviliges on a column DEPTNO in EMP table so whenever a particular user logs in,he will not see the deptno.But he can fetch the data from other table DEPT based on join condition EMP.DEPTNO=DEPT.DEPTNO . Is it possible can we make a join a column on which VPD polciy is applied ?
    pls any idea or thought would be appreciable..
    Thanks in advance
    Anwar

    Hi Anwar!
    I have not tried yet, but I believe that you can do this.
    However imagine the following:
    A user U1 has the right to see some values in the deptno column, but not all. This is fine, and I believe that this is what you want to achieve.
    A user U2 will see no records from the deptno column. This will impact your query, as your emp.deptno = dept.deptno part of the where clause will deliever no records.
    So you have to be careful if this condition could apply and what the impact will be on your software.
    cu
    Andreas

  • Does INNER JOIN work with Oracle 8i ? (ORA-00933)

    hi,
    I try to execute the sql:
    SELECT
    A0.FULL_NAME,A0.MANAGER_ID,A0.DEPT_NO,A0.TOP_DEPT
    FROM
    HR_ORG A0
    INNER JOIN
    HR_EMP A1
    ON
    A0.MANAGER_ID=A1.EMP_NO
    WHERE
    A1.NAME = 'michael'
    but I caught an exception:
    java.sql.SQLException: ORA-00933: SQL...(message in
    chinese)
    Does INNER JOIN work with Oracle 8i ?
    thanks.

    INNER JOIN syntax is introduced in 9i, it does not exists in 8i. You can rewrite your statement:
    SELECT
    A0.FULL_NAME,A0.MANAGER_ID,A0.DEPT_NO,A0.TOP_DEPT
    FROM
    HR_ORG A0
    , HR_EMP A1
    WHERE
    A0.MANAGER_ID=A1.EMP_NO
    AND
    A1.NAME = 'michael'

  • Outer joins don't return expected results in Oracle 10g

    I don't know where to report oracle bugs. So I'm writing here for someone to verify it again and report is a bug to oracle.
    --Creating two table and inserting records in each tables
    create table table1 ( pk_id number(6) primary key, name_tx varchar2(20) );
    create table table1_nls (pk_id number(6) primary key, parent_id number(6), heading varchar2(20), lang_code varchar2(3) );
    insert into table1 values( 1, 'test1' );
    insert into table1_nls values( 1, 1, 'test heading', 'enu' );
    --problem is with the following query.
    select * from table1, (select parent_id, heading from table1_nls where lang_code = '' ) table1_nls
    where table1.PK_ID = table1_nls.PARENT_ID(+) and pk_id = 1
    This returns back one row in Oracle 9i, but none in oracle 10g. If I substitute " lang_code = '' " with lang_code='something' or lang_code is null it works fine. The problem is with comparing the empty value ('').
    Logically lang_code is null is the right way of writing the query, but empty ('') works in Oracle 9i,
    Is this a valid bug?
    If not migration steps should account for this in programs.
    drop table table1;
    drop table table1_nls;

    You want to go to metalink.oracle.com and create a "TAR".

  • How to write Inline queries in Oracle 10g

    Hi all,
    The following Procedure is written in SQL Server 2005 . It uses Inline queries and executes it in the end . I want to write the same stored procedure in Oracle 10g.
    Could you guys please help me in doing the same .
    CREATE PROCEDURE [dbo].[proc_MDM_ShowDetails]
    @MASTERCODE VARCHAR(50),
    @MDMCode VARCHAR(50),
    @IsDrpDwnFill BIT,
    @CntryCode INT,
    @StateCode INT,
    @CityCode INT = 0,
    @GetParent INT = 0,
    @PinCode BIT = 0
    AS
    BEGIN
    DECLARE @strSQL VARCHAR(4000)
    DECLARE @TableName VARCHAR(4000)
    SET NOCOUNT ON;
    SELECT @TableName = MASTER_TABLE FROM MDM_MASTER WHERE MASTER_CODE=@MASTERCODE
    IF @IsDrpDwnFill = 0 AND @CntryCode = 0 AND @GetParent = 0
    BEGIN
    SET @strSQL = 'SELECT M.*,H.* FROM ' + @TableName + ' M LEFT JOIN MDM_HIERARCHY H ON M.MDM_MASTER_CODE=H.MASTER_CODE WHERE M.MDM_CODE=' + @MDMCode
    END
    ELSE IF @CntryCode = 0 AND @IsDrpDwnFill = 1
    BEGIN
    SET @strSQL = 'SELECT MDM_DESCRIPTION,MDM_CODE FROM ' + @TableName + ' WHERE MDM_STATUS=' + '''' + 'approved' + '''' + ' AND MDM_EXIST=1'
    END
    ELSE IF @CntryCode > 0 and @GetParent = 0
    BEGIN
    SET @strSQL = 'SELECT M.MDM_DESCRIPTION,M.MDM_CODE,H.* FROM ' + @TableName + ' M INNER JOIN MDM_HIERARCHY H ON M.MDM_MASTER_CODE=H.MASTER_CODE WHERE MDM_STATUS=' + '''' + 'approved' + '''' +
    ' AND MDM_EXIST = 1 AND MDM_PARENT_CODE =' + str(@CntryCode)
    END
    ELSE IF @StateCode > 0 and @GetParent = 0
    BEGIN
    SET @strSQL = 'SELECT MDM_DESCRIPTION,MDM_CODE FROM ' + @TableName + ' WHERE MDM_STATUS=' + '''' + 'approved' + '''' +
    ' AND MDM_EXIST = 1 AND MDM_PARENT_CODE =' + str(@StateCode)
    END
    ELSE IF @CityCode > 0 and @GetParent = 0
    BEGIN
    SET @strSQL = 'SELECT MDM_DESCRIPTION,MDM_CODE FROM ' + @TableName + ' WHERE MDM_STATUS=' + '''' + 'approved' + '''' +
    ' AND MDM_EXIST = 1 AND MDM_PARENT_CODE =' + str(@CityCode)
    END
    ELSE IF @PinCode = 1 and @GetParent = 0 and @IsDrpDwnFill = 1
    BEGIN
    SET @strSQL = 'SELECT MDM_DESCRIPTION,MDM_CODE FROM ' + @TableName + ' WHERE MDM_STATUS=' + '''' + 'approved' + '''' +
    ' AND MDM_EXIST = 1 '
    END
    ELSE IF @GetParent > 0
    BEGIN
    SET @strSQL = 'SELECT * FROM ' + @TableName + ' WHERE MDM_STATUS=' + '''' + 'approved' + '''' +
    ' AND MDM_EXIST = 1 AND MDM_CODE =' + str(@GetParent)
    END
    EXEC(@strSQL)
    SET NOCOUNT OFF;
    END
    Thanks
    Shobhit

    Hi,
    I dont know sql server 2005. But by observing it I feel you are generating sql dynamically based on condition inside the proc.
    DECLARE
       TYPE EmpCurTyp IS REF CURSOR;
       emp_cv   EmpCurTyp;
       emp_rec  employees%ROWTYPE;
       sql_stmt VARCHAR2(200);
       v_job   VARCHAR2(10) := 'ST_CLERK';
    BEGIN
       sql_stmt := 'SELECT * FROM employees WHERE job_id = :j';
       OPEN emp_cv FOR sql_stmt USING v_job;
       LOOP
         FETCH emp_cv INTO emp_rec;
         EXIT WHEN emp_cv%NOTFOUND;
         DBMS_OUTPUT.PUT_LINE('Name: ' || emp_rec.last_name || ' Job Id: ' ||
                               emp_rec.job_id);
       END LOOP;
       CLOSE emp_cv;
    END;something like this it will be. it is in oracle documentaion
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/dynamic.htm#i14500

  • Performance Problem between Oracle 9i to Oracle 10g using Crystal XI

    We have a Crystal XI Report using ODBC Drivers, 14 tables, and one sub report. If we execute the report on an Oracle 9i database the report will complete in about 12 seconds. If we execute the report on an Oracle 10g database the report will complete in about 35 seconds.
    Our technical Setup:
    Application server: Windows Server 2003, Running Crystal XI SP2 Runtime dlls with Oracle Client 10.01.00.02, .Net Framework 1.1, C# for Crystal Integration, Unmanaged C++ for app server environment calling into C# through a dynamically loaded mixed-mode C++ DLL.
    Database server is Oracle 10g
    What we have concluded:
    Reducing the number of tables to 1 will reduce the execution time of the report from 180s to 13s. With 1 table and the sub report we would get 30 seconds
    We have done some database tracing and see that Crystal Reports Issues the following query when verifying the database and it takes longer in 10g vs 9i.
    We have done some profiling in the application code. When we retarget the first table to the target database, it takes 20-30 times longer in 10g than in 9i. Retargeting the other tables takes about twice as long. The export to a PDF file takes about 4-5 times as long in 10g as in 9i.
    Oracle 10g no longer supports the /*+ RULE */ hint.
    Verify DB Query:
    select /*+ RULE */ *
    from
    (select /*+ RULE */ null table_qualifier, o1.owner table_owner,
    o1.object_name table_name, decode(o1.owner,'SYS', decode(o1.object_type,
    'TABLE','SYSTEM TABLE','VIEW', 'SYSTEM VIEW', o1.object_type), 'SYSTEM',
    decode(o1.object_type,'TABLE','SYSTEM TABLE','VIEW', 'SYSTEM VIEW',
    o1.object_type), o1.object_type) table_type, null remarks from all_objects
    o1 where o1.object_type in ('TABLE', 'VIEW') union select /*+ RULE */ null
    table_qualifier, s.owner table_owner, s.synonym_name table_name, 'SYNONYM'
    table_type, null remarks from all_objects o3, all_synonyms s where
    o3.object_type in ('TABLE','VIEW') and s.table_owner= o3.owner and
    s.table_name = o3.object_name union select /*+ RULE */ null table_qualifier,
    s1.owner table_owner, s1.synonym_name table_name, 'SYNONYM' table_type,
    null remarks from all_synonyms s1 where s1.db_link is not null ) tables
    WHERE 1=1 AND TABLE_NAME='QCTRL_VESSEL' AND table_owner='QLM' ORDER BY 4,2,
    3
    SQL From Main Report:
    SELECT "QCODE_PRODUCT"."PROD_DESCR", "QCTRL_CONTACT"."CONTACT_FIRST_NM", "QCTRL_CONTACT"."CONTACT_LAST_NM", "QCTRL_MEAS_PT"."MP_NM", "QCTRL_ORG"."ORG_NM", "QCTRL_TKT"."SYS_TKT_NO", "QCTRL_TRK_BOL"."START_DT", "QCTRL_TRK_BOL"."END_DT", "QCTRL_TRK_BOL"."DESTINATION", "QCTRL_TRK_BOL"."LOAD_TEMP", "QCTRL_TRK_BOL"."LOAD_PCT", "QCTRL_TRK_BOL"."WEIGHT_OUT", "QCTRL_TRK_BOL"."WEIGHT_IN", "QCTRL_TRK_BOL"."WEIGHT_OUT_UOM_CD", "QCTRL_TRK_BOL"."WEIGHT_IN_UOM_CD", "QCTRL_TRK_BOL"."VAPOR_PRES", "QCTRL_TRK_BOL"."SPECIFIC_GRAV", "QCTRL_TRK_BOL"."PMO_NO", "QCTRL_TRK_BOL"."ODORIZED_VOL", "QARCH_SEC_USER"."SEC_USER_NM", "QCTRL_TKT"."DEM_CTR_NO", "QCTRL_BA_ENTITY"."BA_NM1", "QCTRL_BA_ENTITY_VW"."BA_NM1", "QCTRL_BA_ENTITY"."BA_ID", "QCTRL_TRK_BOL"."VOLUME", "QCTRL_TRK_BOL"."UOM_CD", "QXREF_BOL_PROD"."MOVEMENT_TYPE_CD", "QXREF_BOL_PROD"."BOL_DESCR", "QCTRL_TKT"."VOL", "QCTRL_TKT"."UOM_CD", "QCTRL_PMO"."LINE_UP_BEFORE", "QCTRL_PMO"."LINE_UP_AFTER", "QCODE_UOM"."UOM_DESCR", "QCTRL_ORG_VW"."ORG_NM"
    FROM (((((((((((("QLM"."QCTRL_TRK_BOL" "QCTRL_TRK_BOL" INNER JOIN "QLM"."QCTRL_PMO" "QCTRL_PMO" ON "QCTRL_TRK_BOL"."PMO_NO"="QCTRL_PMO"."PMO_NO") INNER JOIN "QLM"."QCTRL_MEAS_PT" "QCTRL_MEAS_PT" ON "QCTRL_TRK_BOL"."SUP_MP_ID"="QCTRL_MEAS_PT"."MP_ID") INNER JOIN "QLM"."QCTRL_TKT" "QCTRL_TKT" ON "QCTRL_TRK_BOL"."PMO_NO"="QCTRL_TKT"."PMO_NO") INNER JOIN "QLM"."QCTRL_CONTACT" "QCTRL_CONTACT" ON "QCTRL_TRK_BOL"."DRIVER_CONTACT_ID"="QCTRL_CONTACT"."CONTACT_ID") INNER JOIN "QFC_QLM"."QARCH_SEC_USER" "QARCH_SEC_USER" ON "QCTRL_TRK_BOL"."USER_ID"="QARCH_SEC_USER"."SEC_USER_ID") LEFT OUTER JOIN "QLM"."QCODE_UOM" "QCODE_UOM" ON "QCTRL_TRK_BOL"."ODORIZED_VOL_UOM_CD"="QCODE_UOM"."UOM_CD") INNER JOIN "QLM"."QCTRL_ORG_VW" "QCTRL_ORG_VW" ON "QCTRL_MEAS_PT"."ORG_ID"="QCTRL_ORG_VW"."ORG_ID") INNER JOIN "QLM"."QCTRL_BA_ENTITY" "QCTRL_BA_ENTITY" ON "QCTRL_TKT"."DEM_BA_ID"="QCTRL_BA_ENTITY"."BA_ID") INNER JOIN "QLM"."QCTRL_CTR_HDR" "QCTRL_CTR_HDR" ON "QCTRL_PMO"."DEM_CTR_NO"="QCTRL_CTR_HDR"."CTR_NO") INNER JOIN "QLM"."QCODE_PRODUCT" "QCODE_PRODUCT" ON "QCTRL_PMO"."PROD_CD"="QCODE_PRODUCT"."PROD_CD") INNER JOIN "QLM"."QCTRL_BA_ENTITY_VW" "QCTRL_BA_ENTITY_VW" ON "QCTRL_PMO"."VESSEL_BA_ID"="QCTRL_BA_ENTITY_VW"."BA_ID") LEFT OUTER JOIN "QLM"."QXREF_BOL_PROD" "QXREF_BOL_PROD" ON "QCTRL_PMO"."PROD_CD"="QXREF_BOL_PROD"."PURITY_PROD_CD") INNER JOIN "QLM"."QCTRL_ORG" "QCTRL_ORG" ON "QCTRL_CTR_HDR"."BUSINESS_UNIT_ORG_ID"="QCTRL_ORG"."ORG_ID"
    WHERE "QCTRL_TRK_BOL"."PMO_NO"=12345 AND "QXREF_BOL_PROD"."MOVEMENT_TYPE_CD"='TRK'
    SQL From Sub Report:
    SELECT "QXREF_BOL_VESSEL"."PMO_NO", "QXREF_BOL_VESSEL"."VESSEL_NO"
    FROM "QLM"."QXREF_BOL_VESSEL" "QXREF_BOL_VESSEL"
    WHERE "QXREF_BOL_VESSEL"."PMO_NO"=12345
    Does anyone have any suggestions on how we can improve the report performance with 10g?

    Hi Eric,
    Thanks for your response. The optimizer mode in our 9i database is CHOOSE. We changed the optimizer mode from ALL_ROWS to CHOOSE in 10g but it didn't make a difference.
    While researching Metalink I came across a couple of documents that indicated performance problems and issues with using certain data-dictionary views in 10g. Apparently, the definition of ALL_OBJECTS, ALL_ARGUMENTS and ALL_SYNONYMS have changed in 10g, resulting in degradation in performance, if quieried against these views. These are the same queries that crystal reports is queriying. We'll try the workaround suggested in these documents and see if it resolves the issue.
    Here are the Doc Ids, if you are interested:
    Note 377037.1
    Note:364822.1
    Thanks again for your response.
    Venu Boddu.

  • Issue on left outer join query in 10G

    Dear Mr./Mrs./Ms. Oracle expertise,
    The following query structure can function properly in Oracle 9i, but not work in Oracle 10G.
    Please kindly advise what happened in Oracle 10G?
    Is it a bug in 10G? If yes, any patch for it?
    select a.col1,
    a.col2,
    a.col5,
    b.col3,
    b.col4
    from t1 a
    inner join t2 c on c.col1 = a.col1
    left join (select col3
    col4
    from t3) b
    on b.col1 = a.col1
    and a.col2 = 'Y' <---------- seems 10G cannot allow this condition
    where a.col5 = 123;
    Purpose of above SQL
    ====================
    Only those records from t1 table with a.col2 = 'Y' will
    do the left outer join to "b" table and get the columns b.col3 and b.col4
    Result set in Oracle 9i
    =======================
    col1 col2 col5 col3 col4
    AAA N 111
    BBB N 222
    CCC Y 333 XYZ OOO
    DDD Y 444 QPR 111
    Result set in Oracle 10G
    ========================
    col1 col2 col5 col3 col4
    AAA N 111
    BBB N 222
    CCC Y 333
    DDD Y 444
    Rgds,
    Ken Chan

    Dear Schneider,
    Sorry that there was a typo in my query.
    Below is the revised query.
    select a.col1,
    a.col2,
    a.col5,
    b.col3,
    b.col4
    from t1 a
    inner join t2 c on c.col1 = a.col1
    left join (select col1,
    col3,
    col4
    from t3) b
    on b.col1 = a.col1
    and a.col2 = 'Y' <---------- seems 10G cannot allow this condition
    where a.col5 = 123;
    Thanks.
    Rgds,
    ken Chan

  • Inner Join and "PIVOT" results

    Good day all;
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    "CORE     10.2.0.4.0     Production"
    TNS for Solaris: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    I have 2 tables that I would like to do a query on and then "pivot" the results. I understand that since this is 10g that the use of PIVOT is not supported.
    (Corrected code issues :))
    create table CT
    DESIGN_ID NUMBER,
    CT_ID VARCHAR2(15) 
    INSERT INTO CT VALUES ('654321','10QWER123456');
    INSERT INTO CT VALUES ('987654','7ASDF654987');
    INSERT INTO CT VALUES ('321654','82CHEV852963');
    create table CXRF
    DESIGN_ID NUMBER,   
    ROW_SEQ_NBR NUMBER,   
    XREF_CT_ID VARCHAR2(15) 
    INSERT INTO CXRF VALUES ('654321','1','25ABCD');
    INSERT INTO CXRF VALUES ('654321','2','262ABCD');
    INSERT INTO CXRF VALUES ('987654','1','14WXYZ');
    INSERT INTO CXRF VALUES ('987654','2','34FRED');
    INSERT INTO CXRF VALUES ('321654','1','1TOM');- Oops measure twice cut once..
    select design_id,
            ct_id,
            xref_ct_id
      from cxrf
         INNER JOIN
           ct
       on(ct.design_id = cxrf.design_id) Desired results would look like this:
    DESIGN_ID             CT_ID            XREF_CT_1     XREF_CT_2
       654321       10QWER123456        25ABCD         262ABCDEdited by: GMoney on May 9, 2013 8:47 AM
    Edited by: GMoney on May 9, 2013 8:49 AM

    Please provide WORKING sql:
    SQL> create table CT
      2  (
      3  DESIGN_ID NUMBER      not null,
      4  CT_ID VARCHAR2(2)
      5  );
    Table created.
    SQL> INSERT INTO CT VALUES ('654321'','10QWER123456');
    ERROR:
    ORA-01756: quoted string not properly terminated
    SQL> INSERT INTO CT VALUES ('987654','7ASDF654987');
    INSERT INTO CT VALUES ('987654','7ASDF654987')
    ERROR at line 1:
    ORA-12899: value too large for column "SCOTT"."CT"."CT_ID" (actual: 11, maximum: 2)
    SQL> INSERT INTO CT VALUES ('321654','82CHEV852963');
    INSERT INTO CT VALUES ('321654','82CHEV852963')
    ERROR at line 1:
    ORA-12899: value too large for column "SCOTT"."CT"."CT_ID" (actual: 12, maximum: 2)
    SQL>
    SQL> create table CXRF
      2  (
      3  DESIGN_ID NUMBER
      4  ROW_SEQ_NBR NUMBER
      5  XREF_CT_ID VARCHAR2(12)
      6  );
    ROW_SEQ_NBR NUMBER
    ERROR at line 4:
    ORA-00907: missing right parenthesis
    SQL> INSERT INTO CXRF VALUES ('654321','1','25ABCD');
    INSERT INTO CXRF VALUES ('654321','1','25ABCD')
    ERROR at line 1:
    ORA-00942: table or view does not exist
    SQL> INSERT INTO CXRF VALUES ('654321','2','262ABCD');
    INSERT INTO CXRF VALUES ('654321','2','262ABCD')
    ERROR at line 1:
    ORA-00942: table or view does not exist
    SQL> INSERT INTO CXRF VALUES ('987654','1','14WXYZ');
    INSERT INTO CXRF VALUES ('987654','1','14WXYZ')
    ERROR at line 1:
    ORA-00942: table or view does not exist
    SQL> INSERT INTO CXRF VALUES ('987654','2','34FRED');
    INSERT INTO CXRF VALUES ('987654','2','34FRED')
    ERROR at line 1:
    ORA-00942: table or view does not exist
    SQL> INSERT INTO CXRF VALUES ('321654','1','1TOM');
    INSERT INTO CXRF VALUES ('321654','1','1TOM')
    ERROR at line 1:
    ORA-00942: table or view does not exist:p

  • Update statement with inner join

    Hello everyone. I am am trying to do an update statement with an inner join. I have found several examples of SQL statements that work with Sql server and mysql but they don't work in Oracle. Does anyone know the proper way in Oracle 10G? I am trying to update all fields in one table from fields in another table.
    for example:
    UPDATE table3
    SET
    TL3.name = TL2.name,
    TL3.status = TL2.status,
    TL3.date = TL2.date
    FROM table3 TL3 JOIN table2 TL2
    ON (TL3.unique_id = TL2.unique_id);
    any help will be appreciated.

    Hi,
    You can also use MERGE, like this:
    MERGE INTO  table3     dst
    USING   (
             SELECT  unique_id
             ,         name
             ,         status
             ,         dt          -- DATE is not a good column name
             FROM    table2
         )          src
    ON     (dst.unique_id     = src.unique_id)
    WHEN MATCHED THEN UPDATE
    SET     dst.name     = src.name
    ,     dst.status     = src.status
    ,     dst.dt          = src.dt
    ;Unlike UPDATE, this lets you avoid essentially doing the same sub-query twice: once in the SET clause and then again in the WHERE clause.
    Like UPDATE, you don't acutally join the table being changed (table3 in this case) to the other table(s); that is, the FROM clause of the suib-query does not include table3.
    Riedelme is right; you'll get better response to SQL questions like this in the SQL and PL/SQL forum:
    PL/SQL

  • Procedure compiles on Oracle 10g but fails to do so on Oracle 9i

    Hi,
    We have an application which supports both Oracle 9i and Oracle 10g dbs, recently we added a new procedure to get a report from the applications statistics schema, the procedure uses two other schemas also to get the report and uses a query which does not use any Oracle specific feature (pure ANSI SQL), it compiled successfully on Oracle 10g but gives the following error on 9i db
    SQL> show err
    Errors for PROCEDURE SPGETNONCOMPLOGBASEDONEMP:
    LINE/COL ERROR
    22/8 PL/SQL: SQL Statement ignored
    31/37 PL/SQL: ORA-00907: missing right parenthesis
    the 9i version
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    PL/SQL Release 9.2.0.1.0 - Production
    CORE 9.2.0.1.0 Production
    TNS for 32-bit Windows: Version 9.2.0.1.0 - Production
    NLSRTL Version 9.2.0.1.0 - Production
    10g version
    Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Prod
    PL/SQL Release 10.1.0.2.0 - Production
    CORE 10.1.0.2.0 Production
    TNS for 32-bit Windows: Version 10.1.0.2.0 - Production
    NLSRTL Version 10.1.0.2.0 - Production
    If any body knows the soln, please help
    Thanks in advance
    Gibs
    Procedure
    CREATE OR REPLACE PROCEDURE Spgetnoncomplogbasedonemp (
    in_emp_id IN VARCHAR,
    in_start_date IN DATE,
    in_end_date IN DATE,
    non_complog OUT Types.ref_cursor
    IS
    BEGIN
    OPEN non_complog
    FOR
    SELECT end_date AS end_date, employee_id AS emp_id, NAME AS emp_name,
    vcname AS plan_name, start_date, nid AS nid
    FROM (SELECT *
    FROM ((SELECT employee_id, NAME
    FROM hrsample_bridge.ath_employee
    WHERE ( (in_emp_id IS NULL AND 1 = 1)
    OR (in_emp_id IS NOT NULL
    AND employee_id = in_emp_id
    )) CROSS JOIN (SELECT vcname
    FROM orahrsamplecore.athobjectinstance
    WHERE compliance_status = 1
    AND ( (in_start_date IS NULL
    OR (dtcompreissue
    BETWEEN in_start_date
    AND in_end_date
    )))) LEFT OUTER JOIN COMPTRACKLOG c ON c.emp_id =
    employee_id
    AND c.plan_name =
    vcname
    WHERE c.emp_id IS NULL
    AND ( ( (in_emp_id IS NULL)
    OR ( in_emp_id IS NOT NULL
    AND NOT EXISTS (
    SELECT 1
    FROM COMPTRACKLOG
    WHERE plan_name = vcname
    AND c.emp_id = in_emp_id )
    AND ( (in_start_date IS NULL)
    OR ( (in_start_date IS NOT NULL)
    AND c.end_date BETWEEN in_start_date AND in_end_date
    ORDER BY c.emp_id, c.plan_name ASC;
    END;
    /

    Hi,
    We have an application which supports both Oracle 9i and Oracle 10g dbs, recently we added a new procedure to get a report from the applications statistics schema, the procedure uses two other schemas also to get the report and uses a query which does not use any Oracle specific feature (pure ANSI SQL), it compiled successfully on Oracle 10g but gives the following error on 9i db
    SQL> show err
    Errors for PROCEDURE SPGETNONCOMPLOGBASEDONEMP:
    LINE/COL ERROR
    22/8 PL/SQL: SQL Statement ignored
    31/37 PL/SQL: ORA-00907: missing right parenthesis
    the 9i version
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    PL/SQL Release 9.2.0.1.0 - Production
    CORE 9.2.0.1.0 Production
    TNS for 32-bit Windows: Version 9.2.0.1.0 - Production
    NLSRTL Version 9.2.0.1.0 - Production
    10g version
    Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Prod
    PL/SQL Release 10.1.0.2.0 - Production
    CORE 10.1.0.2.0 Production
    TNS for 32-bit Windows: Version 10.1.0.2.0 - Production
    NLSRTL Version 10.1.0.2.0 - Production
    If any body knows the soln, please help
    Thanks in advance
    Gibs
    Procedure
    CREATE OR REPLACE PROCEDURE Spgetnoncomplogbasedonemp (
    in_emp_id IN VARCHAR,
    in_start_date IN DATE,
    in_end_date IN DATE,
    non_complog OUT Types.ref_cursor
    IS
    BEGIN
    OPEN non_complog
    FOR
    SELECT end_date AS end_date, employee_id AS emp_id, NAME AS emp_name,
    vcname AS plan_name, start_date, nid AS nid
    FROM (SELECT *
    FROM ((SELECT employee_id, NAME
    FROM hrsample_bridge.ath_employee
    WHERE ( (in_emp_id IS NULL AND 1 = 1)
    OR (in_emp_id IS NOT NULL
    AND employee_id = in_emp_id
    )) CROSS JOIN (SELECT vcname
    FROM orahrsamplecore.athobjectinstance
    WHERE compliance_status = 1
    AND ( (in_start_date IS NULL
    OR (dtcompreissue
    BETWEEN in_start_date
    AND in_end_date
    )))) LEFT OUTER JOIN COMPTRACKLOG c ON c.emp_id =
    employee_id
    AND c.plan_name =
    vcname
    WHERE c.emp_id IS NULL
    AND ( ( (in_emp_id IS NULL)
    OR ( in_emp_id IS NOT NULL
    AND NOT EXISTS (
    SELECT 1
    FROM COMPTRACKLOG
    WHERE plan_name = vcname
    AND c.emp_id = in_emp_id )
    AND ( (in_start_date IS NULL)
    OR ( (in_start_date IS NOT NULL)
    AND c.end_date BETWEEN in_start_date AND in_end_date
    ORDER BY c.emp_id, c.plan_name ASC;
    END;
    /

  • Need Advise and Suggestions-Oracle 10g

    Hi,
    I have been working on databases as DB developer(mainly PLsql)--Oracle 10g
    Recently,i have joined in a particular position where I have been asked to find out areas where
    improvement is necessary / or areas where improvement or changes would help very much and also gradually implement all best practises avaialable.
    So,could you please help me with these queries
    (1)What are the most important areas that i can start with the database which would impact largely the entire database.How can i start with it? any steps or process
    (2)I had once taken a report out for the expensive SQLs running.But that dint help much...because those SQLs were used temporarily on and off.
    Similarly,what are the other points to be looked on.
    (3)Things which can be replaced with the industry standarad better ones fully.
    an example would be...like.."following a particular naming format,or coding style,etc
    Thanks
    Rohit

    Hi Rohit,
    This is a pretty huge subject. To start, I'd say you need to talk to the business. Talk to the users of the database, cause they are your customers. Get a clear understanding of the most critical business processes. Start with the most critical ones, and get performance profiles. How long do they take to run? What's the customer's perception of the process performance? If it's acceptable, move on to the next one. If it's not acceptable, you'll need to dig deeper. Look at each piece of the process. Where is the most time being spent? Can it be improved? This step will be a combination of process improvement and setting the correct expectation. Often, the user doesn't really know what is realistic in terms of performance. If you have a 2 billion row table that needs to get full table scanned, expecting a response time of a few seconds just simply isn't going to happen. You need to clearly convey that to the customer. On the other hand, at the same time, you should be on the lookout for real improvements. If you can re-write the SQL or add an index, and eliminate the FTS on that 2 billion row table, maybe a response time of a few seconds is actually realistic.
    It's all about understanding the system, and understanding the customer's needs, and how they intersect. It will be an iterative process, and will take some time.
    As to "best practices", I'm not a fan of them. Understand your system, understand your customer's needs, and understand how Oracle actually works. If you can master that, you'll be unstoppable. Note that many, many people, much smarter people than me, have spent a lifetime trying to master those three points... :-)
    Good luck with your new job!
    -Mark

Maybe you are looking for

  • Creation of PD Profiles directly within Production environment.

    The company I work for has recently upgraded all SAP environments, including where HR resides.  Prior to the upgrade, we were able to create PD profiles directly within PRD, but now we are no longer since upgrading via OOSP which updates some of the

  • Jsf components

    Hi sir I have successfully developed first jsf application, i m happy, that you people helped me out, I have created jsp page, where jsf component embedded, but some confusion generating in my mind regarding: 1. hasn't jsp its own components for user

  • Issues while using 2 MDBs together.

    I have two message driven beans, MDB1 and MDB2. An external application first puts a message in MDB2's queue and then eventually puts a different message in MDB1's queue after a few seconds. MDB2 processes the messge and updates the database. MDB1 is

  • Lesson Learned - SAP SOP 3.0.2.2 On-Premise  - Must Read

    Dear Community, We had Sev 1 issue in our production system after system upgraded last night from 3.0.2.1 and 3.0.2.2... Before upgrade :  Most of master data and Key figure data jobs ran in parallel ( Informatica  ETL and loading data from staging t

  • Hard Drive Fail

    Creative Zen Micro 5 gig ..... Read all the documentation provided on Knowledge Base http://93.95.7.84/?Player freezes at?the Creative Logo. Tried Detach the player from the PC and power the unit off.< Remove the battery.< Move and hold the Power but