Need help in executing sql

Below is my sql which is taking forever...can any one tell whats wrong
SELECT COUNT(ACCOUNT_NBR) FROM STG_ACCOUNT WHERE ACCOUNT_NBR
NOT IN(SELECT OU_NUM FROM QA_ACCOUNT)
Below is plan for above query
Plan
SELECT STATEMENT CHOOSE               
     4 SORT AGGREGATE           
          3 FILTER      
               1 TABLE ACCESS FULL TABLE STG_ACCOUNT
               2 TABLE ACCESS FULL TABLE QA_ACCOUNT
Message was edited by:
user632733

As the execution plan shows, for each row from the STG_Account table full scan of QA_Account table is performed. It's VERY inefficient (each test tables has 50000 rows):
SQL> set timing on
SQL> set linesize 200
SQL> set autotrace on
SQL>
SQL> SELECT COUNT(ACCOUNT_NBR) FROM STG_ACCOUNT
  2  WHERE ACCOUNT_NBR NOT IN(SELECT OU_NUM FROM QA_ACCOUNT);
COUNT(ACCOUNT_NBR)
                 0
Elapsed: 00:02:27.31
Execution Plan
Plan hash value: 2866032720
| Id  | Operation           | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT    |             |     1 |    13 | 32524   (4)| 00:06:31 |
|   1 |  SORT AGGREGATE     |             |     1 |    13 |            |          |
|*  2 |   FILTER            |             |       |       |            |          |
|   3 |    TABLE ACCESS FULL| STG_ACCOUNT | 52597 |   667K|    20   (5)| 00:00:01 |
|*  4 |    TABLE ACCESS FULL| QA_ACCOUNT  | 47771 |   606K|    20   (5)| 00:00:01 |
Predicate Information (identified by operation id):
   2 - filter( NOT EXISTS (SELECT /*+ */ 0 FROM "QA_ACCOUNT" "QA_ACCOUNT"
              WHERE LNNVL("OU_NUM"<>:B1)))
   4 - filter(LNNVL("OU_NUM"<>:B1))
Note
   - dynamic sampling used for this statement
Statistics
        478  recursive calls
          0  db block gets
    2072920  consistent gets
        169  physical reads
          0  redo size
        420  bytes sent via SQL*Net to client
        384  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          8  sorts (memory)
          0  sorts (disk)
          1  rows processed
SQL> select value as "table scan rows gotten" from v$sesstat where statistic# = 249 and sid= [cur session sid] ;
table scan rows gotten
            1266674450Obviously, query should be rewritten, for example (db restarted):
SQL> set timing on
SQL> set linesize 200
SQL> set autotrace on
SQL> select count(*) from
  2  (
  3    select qa.ou_num
  4    from stg_account stg
  5      left outer join qa_account qa on stg.account_nbr = qa.ou_num
  6  )
  7  where ou_num is null
  8  ;
  COUNT(*)
         0
Elapsed: 00:00:00.29
Execution Plan
Plan hash value: 2130409646
| Id  | Operation             | Name        | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT      |             |     1 |    26 |       |   164   (2)| 00:00:02 |
|   1 |  SORT AGGREGATE       |             |     1 |    26 |       |            |          |
|*  2 |   HASH JOIN RIGHT ANTI|             |  2311 | 60086 |  1232K|   164   (2)| 00:00:02 |
|   3 |    TABLE ACCESS FULL  | QA_ACCOUNT  | 50286 |   638K|       |    20   (5)| 00:00:01 |
|   4 |    TABLE ACCESS FULL  | STG_ACCOUNT | 52597 |   667K|       |    20   (5)| 00:00:01 |
Predicate Information (identified by operation id):
   2 - access("STG"."ACCOUNT_NBR"="QA"."OU_NUM")
Note
   - dynamic sampling used for this statement
Statistics
        476  recursive calls
          0  db block gets
        364  consistent gets
        167  physical reads
          0  redo size
        410  bytes sent via SQL*Net to client
        384  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
         10  sorts (memory)
          0  sorts (disk)
          1  rows processed
SQL> select value as "table scan rows gotten" from v$sesstat where statistic# = 249 and sid = [cur session sid];
table scan rows gotten
                264703Compare 'consistent gets' and 'table scan rows gotten' statistics of both queries.
Regards,
Dima

Similar Messages

  • New To Oracle.. Needs Help:: Conversion from SQL Server to Oracle 11g

    I am new to Oracle 11g and badly need the conversion of SQL Server Functions to Oracle.. Sample Pasted Code not working .. end with error.. pls help
    Create Table TempT (ID1 Varchar (10),
    ID2 Varchar (10)
    CREATE OR REPLACE PACKAGE GLOBALPKG
    AS
    TYPE RCT1 IS REF CURSOR;
    TRANCOUNT INTEGER := 0;
    IDENTITY INTEGER;
    END;
    CREATE OR REPLACE FUNCTION fTempT
    i IN VARCHAR2 DEFAULT NULL
    RETURN GLOBALPKG.RCT1
    IS
    REFCURSOR GLOBALPKG.RCT1;
    BEGIN
    OPEN REFCURSOR FOR
    SELECT TT.*
    FROM TempT TT
    WHERE (fTempT.i = ''
    OR TT.ID1 = fTempT.i)
    RETURN REFCURSOR;
    END;
    CREATE OR REPLACE FUNCTION fTempTF
    i IN VARCHAR2 DEFAULT NULL
    RETURN GLOBALPKG.RCT1
    IS
    REFCURSOR GLOBALPKG.RCT1;
    BEGIN
    OPEN REFCURSOR FOR
    SELECT *
    FROM TABLE(fTempT(i))
    RETURN REFCURSOR;
    END;
    LAST FUNCTION ENDs WITH ERROR
    Error(13,7): PL/SQL: ORA-22905: cannot access rows from a non-nested table item

    2. The major purpose is to get a simplest way to create a parameterized function who can return a table like output. 2nd function has no use instead i was testing the result of First Function like thisIf you just want to select from a select, you should use a view not a function.
    1. which program is more help ful for writing and executing queries bcoz after using Query Analyzer of Microsoft It seems difficult to work on SQL Developer.
    sqlplus? If you are having difficulty learning new tools because of an old one you used, probably best to forget the old one and concentrate on learning the new one because it will be different. This goes for the database itself also.
    2. Can DMLs be used within a Function.Yes, you just can't execute the function in another SQL statement if it modifies data and this is a good thing.
    3. Can temporary tables be used within a function.Unfortunately yes, but they shouldn't be unless you are in a slowest application competition.
    5. Each Function which is a Table Function must be accompanied with Type Definitions?? its a bit longer way of doing the things than SQL ServerThat is why it is better to use views instead, is there any reason you want a select that you can select from inside a function?
    SQL Server for last 9 years thats why i refer this toolThat is not in itself a problem, if you try and do what you did in SQLServer in Oracle, that will be a problem though.

  • I need help on This SQL problem ASAP :)

    Hi All,
    I need help on this....
    I have a table...
    Say table name: one
    with these values
    premnum status
    1234 C
    1234 F
    1234 P
    1234 F
    5678 C
    5678 F
    5678 P
    9112 C
    9112 F
    9112 P
    9112 F
    3456 C
    3456 F
    3456 P
    7890 C
    7890 P
    7890 F
    Now, I want to output only those premnum with status = 'C' and those premnum with Status 'F' having a count > 1 (with two status = 'F')
    So the output would be something like this
    premnum status
    1234 C
    1234 F
    1234 F
    5678 C
    9112 C
    9112 F
    9112 F
    3456 C
    7890 C
    I really need help on this asap...
    I need the SQL statement on this....
    Thank you in advance. :)
    Edited by: 804697 on Oct 23, 2010 9:45 PM

    Hi,
    you can use the following query.
    CREATE TABLE PREM_TEST ( premnum NUMBER , STATUS VARCHAR2(1));
    INSERT INTO PREM_TEST VALUES(1234 ,'C');
    INSERT INTO PREM_TEST VALUES(1234 ,'F');
    INSERT INTO PREM_TEST VALUES(1234 ,'P');
    INSERT INTO PREM_TEST VALUES(1234 ,'F');
    INSERT INTO PREM_TEST VALUES(5678 ,'C');
    INSERT INTO PREM_TEST VALUES(5678 ,'F');
    INSERT INTO PREM_TEST VALUES(5678 ,'P');
    INSERT INTO PREM_TEST VALUES(9112 ,'C');
    INSERT INTO PREM_TEST VALUES(9112 ,'F');
    INSERT INTO PREM_TEST VALUES(9112 ,'P');
    INSERT INTO PREM_TEST VALUES(9112 ,'F');
    INSERT INTO PREM_TEST VALUES(3456 ,'C');
    INSERT INTO PREM_TEST VALUES(3456 ,'F');
    INSERT INTO PREM_TEST VALUES(3456 ,'P');
    INSERT INTO PREM_TEST VALUES(7890 ,'C');
    INSERT INTO PREM_TEST VALUES(7890 ,'P');
    INSERT INTO PREM_TEST VALUES(7890 ,'F');
    SELECT     PREMNUM , STATUS
    FROM     PREM_TEST
    WHERE     STATUS = 'C'
    OR          (PREMNUM , STATUS ) IN (     SELECT PREMNUM , STATUS
                                                 FROM     PREM_TEST
                                                 WHERE     STATUS = 'F'
                                                 GROUP BY PREMNUM , STATUS
                                                 HAVING COUNT(*) > 1
    PREMNUM S
    1234 C
    1234 F
    1234 F
    5678 C
    9112 C
    9112 F
    9112 F
    3456 C
    7890 C
    9 rows selected.

  • Hi all, need help in PL SQL?

    I am new in this industry. I have my training going on ORACLE PL SQL.
    Can somebody help me out:
    1.) How do we write program to add two numbers and then printing them as output.
    2.) How do we write program to read from a file and then write to another file.
    3.) How do we write program to send an email from your program.
    4.) How do we write program to create random numbers.
    Thanks in advance. . .

    Hello;
    This forum is dedicated for Oracle Beehive, if you need help and advices on SQL/PL-SQL please open a thread on the following forum: PL/SQL
    About your third question, if you want to send an email from Beehive the best way is to perform that through the Web Services.
    Fred

  • Need Help in Simple SQL

    Hi,
    I need help. I did not know how to make this select statement run without error.
    select iif(max(numberseries) is null,'0',numberseries+ 1) from registration
    Thank

    Hi ,
    May i know what are you trying to do ,
    if you are trying to use if else in query, then it wont work
    if else is not valid in query.
    try to use decode or case , such that your need can be full filled
    Thank you
    Raj Deep.A

  • Need help on a sql query

    Hi Friends,
    I am trying to load Employees and their Assignments using APIs.
    I have various columns in my staging table like Last Name, First Name, etc., but I need help in writing query in the cursor especially for columns Emp Number and Supervisor Number.
    I have data as below
    Emp_Number     Supervisor_Number
    GE0002               GE0064
    GE0064               EG0009
    EG0009               EG0001
    100009                EG0001
    EG0001               TU0001
    Cursor I write will process the data in the same order as above, but here the problem is...
    When it processes first row, it checks for supervisor GE0064 which do not exist and so it errors out.
    Similarly for second row, it checks for supervisor EG0009 which again do not exist and so it errors out.
    So in order to prevent this, the cursor should process the rows as below
    Emp_Number     Supervisor_Number
    EG0001               TU0001
    EG0009               EG0001
    GE0064               EG0009
    GE0002               GE0064
    100009                EG0001
    By this way, Supervisor should be defined first as an employee and then it can be used as a supervisor for other employees
    is there a way that I can get the output as above(second set of data), when the table has records randomly as above(first set of data)
    Appreciate your help!
    Thanks,
    Srikanth

    Srikanth wrote:
    ... but the number of records returned by above query are lot more than number of records in the table.
    Why did the number go up?
    It's something only you can find out
    Maybe some Emp have several Supervisor(s) like
    with
    t as
    (select 'GE0002' Emp,'GE0064' Supervisor from dual union all
    select 'GE0064','EG0009' from dual union all
    select 'EG0009','EG0001' from dual union all
    select 'GE0064','100009' from dual union all
    select '100009','EG0001' from dual union all
    select 'EG0001','TU0001' from dual
    select Emp,Supervisor,lpad('_',3 * (level - 1),'_')||Emp indent
      from (select Emp,Supervisor
              from t
            union all
            select supervisor,null
              from t tt
             where not exists(select null
                                from t
                               where emp = tt.supervisor
    start with Supervisor is null
    connect by prior Emp = Supervisor
    EMP
    SUPERVISOR
    INDENT
    TU0001
    TU0001
    EG0001
    TU0001
    ___EG0001
    100009
    EG0001
    ______100009
    GE0064
    100009
    _________GE0064
    GE0002
    GE0064
    ____________GE0002
    EG0009
    EG0001
    ______EG0009
    GE0064
    EG0009
    _________GE0064
    GE0002
    GE0064
    ____________GE0002
    Regards
    Etbin

  • Need help in compling sql file

    Hi,
    I am having around 20 sql files (20 different proc/functions) and I am changing almost all the sql files frequently, for compiling everytime I am executing
    SQL> @1.sql
    SQL> @2.sql
    SQL> @20.sql
    Its there anyway to compile all the sql's in one shot.
    Thanks

    Step 1: save all source code in c:\
    step 2 : Create file main.sql in c:\
    /*main.sql file*/
    Spool C:\temp\sql\pkg_installation_errors.log
    prompt #compliing package 1;
    @@C:\1.sql;
    show errors;
    prompt #compliing package 2;
    @@C:\2.sql;
    show errors;
    prompt #compliing Porcedure3;
    @@C:\3.sql;
    show errors;
    prompt #compliing Function 4;
    @@C:\4.sql;
    show errors;
    prompt #compliing package 5;
    @@C:\5.sql;
    show errors;
    prompt #compliing package 6;
    @@C:\6.sql;
    show errors;
    spool off;
    step 3: \ run it from sqlplus
    It wil work

  • Need help in using SQL in a jsp file to compare date and time

    hi every one,
    Actually I am doing a project using JSP. I need to compare a date field in the database (MS Acess) to the current system date and time. I have to do this in a select statement.
    I have alredy defined a variable of type Date in the JSP file and I am comparing this variable to the date in the database through a select statemant.
    Here is what I am doing
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");
              java.util.Date today = new java.util.Date();
              String myDate=sdf.format(today);
    query = "SELECT Car_ID, Model_ID, Year, Ext_Color, Price from Cars where EDate <= "+myDate+" ;";
    EDate is the feild in the database and it's format is (5/12/2008 5:29:47 PM) it is of type Date/Time in MS Acess.
    when I execute the query it gives the following error
    SQL error:java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'EDate <= 2008-10-16 08:10:07'.
    I hope any one can help me with that error and answer my question, I've tried too many things but nothing helps
    Thanks in advance :-)

    Hi,
    When the comparision is needed to be done with the current date , we don't need to send in Java
    Date then format it and compare with MS Acess Date.
    In MS Access we have Date() function which will give you the current date.
    So you can try rewriting your query as following :
    query = "SELECT Car_ID, Model_ID, Year, Ext_Color, Price from Cars where EDate <= Date() ;"; ---------------------
    Hope this helps.
    Thanks

  • Need help in executing the plsql code

    hi guys,
    below is the structure of the procedure i have created.
    CREATE OR REPLACE PROCEDURE sp_R_TrgComparisonReport
         DataDate IN      DATE DEFAULT NULL,
         Business IN OUT      VARCHAR2,
         Sector IN      VARCHAR2 DEFAULT NULL,
         SubSector IN      VARCHAR2 DEFAULT NULL,
         CUSIP IN OUT      VARCHAR2,
         DEALTICKER IN OUT      VARCHAR2,
         sFloatInd IN      VARCHAR2 DEFAULT NULL,
         RCT1 IN OUT      GLOBALPKG.RCT1
    AS
         tmpBusCount INT;
         tmpStartCount INT;
         tmpEndCount INT;
         tmpBusName VARCHAR2(30);
         tmpAlterTable VARCHAR2(500);
         tmpUpdateStr VARCHAR2(2000);
         tmpFinalStr1 VARCHAR2(1000);
         tmpFinalStr2 VARCHAR2(1000);
         Days INT;
         tmpFinalStrCMBS VARCHAR2(2000);
         tmpCusip VARCHAR2(100);
         tmpColName VARCHAR2(30);
         tmpFinalStr4 VARCHAR2(1000);
         tmpCMBSTable VARCHAR2(500);
         tmpEndCount_CMBS INT;
         tmpRating3str VARCHAR2(1000);
         Deletestr VARCHAR2(1000);
         ipos INT;
         CALLINGPROCASSIGNTEMP1 VARCHAR2(31);
         strSector VARCHAR2(2000);
         CALLINGPROCASSIGNTEMP2 VARCHAR2(29);
         strSubSector VARCHAR2(2000);
         CALLINGPROCASSIGNTEMP3 VARCHAR2(32);
         CALLINGPROCASSIGNTEMP4 VARCHAR2(28);
         CALLINGPROCASSIGNTEMP5 VARCHAR2(40);
         CALLINGPROCASSIGNTEMP6 VARCHAR2(34);
         CALLINGPROCASSIGNTEMP7 VARCHAR2(36);
         SCOPE_IDENTITY_VARIABLE INT;
         G1_COL1 TMPHOLDINGTRIGGER.DEALTICKER%TYPE;
         G1_ROWID ROWID;
         G2_COL1 TMPHOLDINGTRIGGER.CURRENT_CE%TYPE;
         G2_ROWID ROWID;
         G3_COL1 TMPHOLDINGTRIGGER.SP_RATING%TYPE;
         G3_ROWID ROWID;
         G4_COL1 TMPHOLDINGTRIGGER.MOODY_RATING%TYPE;
         G4_ROWID ROWID;
         G5_COL1 TMPHOLDINGTRIGGER.FITCH_RATING%TYPE;
         G5_ROWID ROWID;
         G6_COL1 TMPHOLDINGTRIGGER.DEAL_DESC%TYPE;
         G6_ROWID ROWID;
         G7_COL1 TMPHOLDINGTRIGGER.CUSIP_COMMENTARY%TYPE;
         G7_ROWID ROWID;
         G8_COL1 TMPHOLDINGTRIGGER.CUSIP_RANKING_DESC%TYPE;
         G8_ROWID ROWID;
         G9_COL1 TMPHOLDINGTRIGGER.BB_DEALTICKER%TYPE;
         G9_ROWID ROWID;
         G10_COL1 TMPHOLDINGTRIGGER.CLASS%TYPE;
         G10_ROWID ROWID;
         G11_COL1 TMPHOLDINGTRIGGER.RANKING%TYPE;
         G11_ROWID ROWID;
         CALLINGPROCASSIGNTEMP8 VARCHAR2(34);
         CALLINGPROCASSIGNTEMP9 VARCHAR2(39);
         CALLINGPROCASSIGNTEMP10 VARCHAR2(43);
         G12_COL1 TMPHOLDINGTRIGGER.INTEX_STATUSCODE%TYPE;
         G12_ROWID ROWID;
         G13_COL1 TMPHOLDINGTRIGGER.USER_STATUSCODE%TYPE;
         G13_ROWID ROWID;
         G14_COL1 TMPHOLDINGTRIGGER.INTEX_STATUSCODE%TYPE;
         G14_COL2 TMPHOLDINGTRIGGER.COMMENT_%TYPE;
         G14_ROWID ROWID;
         G15_COL1 TMPHOLDINGTRIGGER.INTEX_STATUSCODE%TYPE;
         G15_COL2 TMPHOLDINGTRIGGER.COMMENT_%TYPE;
         G15_ROWID ROWID;
         G16_COL1 TMPHOLDINGTRIGGER.USER_STATUSCODE%TYPE;
         G16_COL2 TMPHOLDINGTRIGGER.COMMENT_%TYPE;
         G16_ROWID ROWID;
         G17_COL1 TMPHOLDINGTRIGGER.USER_STATUSCODE%TYPE;
         G17_COL2 TMPHOLDINGTRIGGER.COMMENT_%TYPE;
         G17_ROWID ROWID;
         G18_COL1 TMPHOLDINGTRIGGER.USER_STATUSCODE%TYPE;
         G18_COL2 TMPHOLDINGTRIGGER.COMMENT_%TYPE;
         G18_ROWID ROWID;
         G19_COL1 TMPHOLDINGTRIGGER.USER_STATUSCODE%TYPE;
         G19_COL2 TMPHOLDINGTRIGGER.COMMENT_%TYPE;
         G19_ROWID ROWID;
         G20_COL1 TMPHOLDINGTRIGGER.USER_STATUSCODE%TYPE;
         G20_COL2 TMPHOLDINGTRIGGER.COMMENT_%TYPE;
         G20_ROWID ROWID;
         G21_COL1 TMPHOLDINGTRIGGER.INTEX_STATUSCODE%TYPE;
         G21_COL2 TMPHOLDINGTRIGGER.COMMENT_%TYPE;
         G21_ROWID ROWID;
         G22_COL1 TMPHOLDINGTRIGGER.USER_STATUSCODE%TYPE;
         G22_ROWID ROWID;
    the procedure got compiled successfully.
    and i am trying to execute this procedure in this way.
    1 declare x refcursor;
    2 exec sp_R_TrgComparisonReport ('31-DEC-2003','','ABS','ALL','ALL','','ALL');
    3* print x
    L> /
    i am facing errors.
    ERROR at line 3:
    ORA-06550: line 3, column 7:
    PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
    := . ( @ % ; not null range default character
    basically i am appsdba so dont have much exposure on this
    can some one please help me out
    thanks in advance.
    let me know if you need the complete code
    thanks,
    Vamshi.D

    and i am trying to execute this procedure in this way.
    declare x refcursor;
    2 exec sp_R_TrgComparisonReport ('31-DEC-2003','','ABS','ALL','ALL','','ALL');
    3* print xIn SQL*plus you would run it like this:
    SQL> var x refcursor
    SQL> exec exec sp_R_TrgComparisonReport ('31-DEC-2003','','ABS','ALL','ALL','','ALL')
    SQL> print xOf course that last command is going to hurl an invalid handle exception because you don't appear to have a ref cursor as an argument in your procedure's signature.
    Unless that is what is meant by RCT1 IN OUT GLOBALPKG.RCT1. In which case you need to reference your variable there:
    SQL> exec exec sp_R_TrgComparisonReport ('31-DEC-2003','','ABS','ALL','ALL','',:x) If that last argument is not the ref cursor then your call is going to fail because we can't use literals as OUT parameters.
    Cheers, APC
    Blog : http://radiofreetooting.blogspot.com/

  • Need help on Dynamic SQL Cursor in Forms

    Hi All,
    I am trying to execute Dynamic SQL Cursor in forms using EXEC_SQL built in.
    I have a cursor for example:
    'select * from supplier where supplier = '||p_supplier||' and processing_order = '||p_order
    My code is
    cur_num := Exec_SQL.Open_cursor;
    sql_order := 'select * from supplier where supplier = '||p_supplier||' and processing_order = '||p_order;
    EXEC_SQL.PARSE(cursor_number, sql_order);
      EXEC_SQL.DEFINE_COLUMN(cur_num ,1,ln_Supp_Id);
      EXEC_SQL.DEFINE_COLUMN(cur_num ,2,ls_Suppl_Name,30);
    EXEC_SQL.DEFINE_COLUMN(cur_num ,24,ls_exchange,20);
      sql_count := EXEC_SQL.EXECUTE(cur_num );
      While EXEC_SQL.FETCH_ROWS(cur_num ) > 0 Loop
            EXEC_SQL.COLUMN_VALUE(cur_num ,1,ln_Supp_Id);
            EXEC_SQL.COLUMN_VALUE(cur_num ,2,ls_Suppl_Name);
            EXEC_SQL.COLUMN_VALUE(cur_num ,24,ls_exchange);
    End Loop;
    EXEC_SQL.CLOSE_CURSOR(cur_num );
    In this case I have to write 24 Define Columns and 24 Column value. Is there any way to assign them to %rowtype at one time as I need all coulmn of the table.
    I had similar case on multiple tables.
    Please help me
    Thanks,
    Maddy

    I need this dynamic sql because p_supplier and p_order values changes at run time
    I do not understand. Is this a simplified sample or the real thing? You do know that you can pass variables to cursors:
    cursor test is
    select * from supplier where supplier = p_supplier and processing_order = p_order;
    or does e.g. p_supplier hold other parts of the query?
    cheers

  • Need help in executing report in OIM 10g

    Hi,
    I am getting error while executing a stored procedure for a report. The error is :
    ERROR,10 May 2012 00:25:07,649,[XELLERATE.WEBAPP],Class/Method: ReportAction/displayTabularReport encounter some problems: {1}
    Thor.API.Exceptions.tcColumnNotFoundException
    at Thor.API.tcMetaDataSet.getColumnType(Unknown Source)
    at com.thortech.xl.webclient.util.ReportUtilities.populateTableDataForTabularDisplay(Unknown Source)
    at com.thortech.xl.webclient.util.ReportUtilities.displayReportWithTabularLayout(Unknown Source)
    at com.thortech.xl.webclient.util.ReportUtilities.displayReportWithLayout(Unknown Source)
    at com.thortech.xl.webclient.actions.ReportAction.displayTabularReport(Unknown Source)
    at com.thortech.xl.webclient.actions.ReportAction.displayReport(Unknown Source)
    at com.thortech.xl.webclient.actions.ReportAction.handleInputParameters(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    for 2 days I am trying to solve this issue by trying different permutation and conbination but its not working. The table takes values from only two tables. Also I tried removing the othertable values and fetch value only from one table but still I am getting above error.
    Please help if anybody knows the solution for this.
    Thanks,
    Kalpana.

    I created my own report by copying from existing stored procedure. I just changed the select, from & where clause. I am not using any java program. Just changed the stored procedure, created the xml file, saved the parameter mappings in properties file, bounced the server but when I run the report I get this error.
    This is the xml file:
    <Report layout="tabular">
    <StoredProcedure>
    <InputParameters>
    <InputParameter name="struserlogin_in" order="1" fieldType="TextField" fieldLabel="report.contractorextension.label.reportDateRange" required="true" />
    </InputParameters>
    </StoredProcedure>
    <ReturnColumns>
    <ReturnColumn name="Contractor_Id" label="report.contractorextension.label.Contractor_Id" position="Table" order ="1"/>
    <ReturnColumn name="Contractor_Name" label="report.contractorextension.label.Contractor_Name" position="Table" order ="2"/>
    <ReturnColumn name="Contractor_NTLogon" label="report.contractorextension.label.Contractor_NTLogon" position="Table" order ="3"/>
    <ReturnColumn name="USR_STATUS" label="report.contractorextension.label.USR_STATUS" position="Table" order ="4"/>
    <ReturnColumn name="USR_END_DATE" label="report.contractorextension.label.USR_END_DATE" position="Table" order ="5"/>
    <ReturnColumn name="Supervisor_Name" label="report.contractorextension.label.Supervisor_Name" position="Table" order ="6"/>
    <ReturnColumn name="Supervisor_NTLogon" label="report.contractorextension.label.Supervisor_NTLogon" position="Table" order ="7"/>
    <ReturnColumn name="Supervsior_EmailId" label="report.contractorextension.label.Supervsior_EmailId" position="Table" order ="8"/>
    <ReturnColumn name="Notification_Send_Date" label="report.contractorextension.label.Notification_Send_Date" position="Table" order ="9"/>
    <ReturnColumn name="Extension_Date" label="report.contractorextension.label.Extension_Date" position="Table" order ="10"/>
    </ReturnColumns>
    </Report>
    this is the stored procedure:
    create or replace
    PROCEDURE "XL_SP_CONTRACTOREXTENSION" (
    csrresultset_inout IN OUT sys_refcursor,
    intuserkey_in IN NUMBER,
    strsortcolumn_in IN VARCHAR2,
    strsortorder_in IN VARCHAR2,
    intstartrow_in IN NUMBER,
    intpagesize_in IN NUMBER,
    intdocount_in IN NUMBER,
    inttotalrows_out OUT NUMBER,
    strfiltercolumnlist_in IN VARCHAR2,
    strfiltercolumnvaluelist_in IN VARCHAR2,
    strudfcolumnlist_in IN VARCHAR2,
    strudfcolumnvaluelist_in IN VARCHAR2,
    struserlogin_in IN VARCHAR2
    AS
    BEGIN
    Declare
    whereclause VARCHAR2(8000);
    select_stmt VARCHAR2(8000);
    strColumnList VARCHAR2(4000);
    strFromClause VARCHAR2(4000);
    strWhereClause VARCHAR2(4000);
    strOrderByClause VARCHAR2(2000);
    intSortDirection_in PLS_INTEGER;
    userkey NUMBER(30);
    str_row EXCEPTION;
    do_cnt EXCEPTION;
    no_logged_in_user EXCEPTION;
    property_not_found EXCEPTION;
    pragma exception_init(Str_row,-20001);
    pragma exception_init(Do_cnt,-20002);
    pragma exception_init(no_logged_in_user,-20003);
    BEGIN
    -- Throw exception if the start row or page size is either NULL or have
    -- values less than or equal to zero
    IF (intstartrow_in <= 0 OR intpagesize_in <= 0 OR intstartrow_in IS NULL
    OR intpagesize_in IS NULL) THEN
    RAISE str_row;
    END IF;
    -- Throw exception if the intdocount_in parameter is NULL or has a value
    -- other than 0 and 1
    IF intdocount_in NOT IN (0, 1, 2) OR intdocount_in IS NULL THEN
    RAISE do_cnt;
    END IF;
    -- Throw exception if the intuserkey_in (logged in user) parameter is NULL
    IF intuserkey_in IS NULL or intuserkey_in <= 0 THEN
    RAISE no_logged_in_user;
    END IF;
    -- Now, we start accumulating the whereclause based on the input
    -- parameters, performing error checking along the way.
    IF struserlogin_in IS NOT NULL THEN
    Whereclause :=
    whereclause || ' extn.udf_extn_ntlogon IN ( ''' || struserlogin_in || ''')' ;
    -- Perform the count query and store the result in inttotalrows_out
    -- inttotalrows_out := 0;
    IF intdocount_in IN (1,2)
    THEN
    EXECUTE IMMEDIATE ' SELECT count(*)'
    || ' FROM '
    || ' usr usr,usr usr2 '
    || ' where usr.USR_MANAGER_KEY = usr2.USR_KEY and'
    || ' extn.usr_key= usr.usr_key and '
    || whereclause INTO inttotalrows_out;
    -- UI needs the SP to return result set always. The following is returned
    -- when the indocount is 2 which does not return any result set but count
    IF intdocount_in = 2 THEN
    select_stmt := 'SELECT ''dummy'' FROM dual';
    OPEN csrresultset_inout FOR select_stmt;
    END IF;
    END IF;
    -- If intdocount_in is 2, UI just wants to get the totalrows to give
    -- the warning to users if the result set exceeds the limit set by
    -- UI. When ntdocount_in is 2, the following block won't be executed.
    -- This is the main query for this stored procedure
    If Intdocount_In In (0,1) Then
    -- The value of attestation field is NA in case of GTC resource names.
    -- If the GTC resource is selected, then "NA" will be displayed in the role name column
    Strcolumnlist :='usr.USR_LOGIN AS Contractor_Id, '
    --|| 'usr.USR_FIRST_NAME || '' '' || usr.usr_middle_name || '' '' || usr.USR_LAST_NAME AS "Contractor_NTLogon", '
    || 'usr.USR_FIRST_NAME AS Contractor_Name, '
    || 'usr.USR_UDF_NTLOGON AS Contractor_NTLogon,'
    || 'usr.USR_STATUS AS USR_STATUS, '
    || 'usr.USR_END_DATE AS USR_END_DATE, '
    --|| 'usr2.usr_first_name || '' '' || usr2.usr_middle_name || '' '' || usr2.usr_last_name AS "Supervisor_Name", '
    ||'usr2.usr_first_name AS Supervisor_Name, '
    || 'usr2.USR_UDF_NTLOGON AS Supervisor_NTLogon, '
    || 'usr2.USR_EMAIL AS Supervsior_EmailId'
    || 'extn.UDF_EXTN_CREATED AS Notification_Send_Date, '
    || 'extn.UDF_EXTN_EXTENDED AS Extension_Date';
    strFromClause :=' ud_co_extn_q extn, usr usr,usr usr2';
    strWhereClause := ' usr.USR_MANAGER_KEY = usr2.USR_KEY and '
    ||' extn.usr_key= usr.usr_key and '
    || whereclause;
    IF strsortcolumn_in IS NULL THEN
    strOrderByClause := 'extn.UDF_EXTN_EXTENDED';
    ELSE
    strOrderByClause := strsortcolumn_in;
    END IF;
    IF strsortorder_in = 'DESC' THEN
    intSortDirection_in := 0;
    ELSE
    intSortDirection_in := 1;
    END IF;
    XL_SPG_GetPagingSql(strColumnList,
    strFromClause,
    strWhereClause,
    strOrderByClause,
    intSortDirection_in,
    intStartRow_in,
    intPageSize_in,
    select_stmt);
    OPEN csrresultset_inout FOR select_stmt;
    END IF;
    END IF;
    -- Exception Handling
    EXCEPTION
    WHEN Str_row THEN
    RAISE_APPLICATION_ERROR(sqlcode,
    'Start Row/Page Size cannot be NULL OR less than or equal to zero ');
    WHEN Do_cnt THEN
    RAISE_APPLICATION_ERROR(sqlcode,
    'Do Count must be 0, 1 or 2. ');
    WHEN no_logged_in_user THEN
    RAISE_APPLICATION_ERROR(sqlcode,
    'Logged-in User Key cannot be NULL OR less than or equal to zero ');
    END;
    END XL_SP_CONTRACTOREXTENSION;

  • Need help on executing ssis package from ssrs report

    i want to develop a load test tool.
    we do load test on beta servers i need to capture server statistics during load test and make a report out of it.
    basically as a tool to start and stop capturing server info from ssrs report.
    Any help is highly appreciated !!

    Whats the need of a report for starting and stopping of jobs here? Isnt it enough to capture the details from MSDB system tables or SSISDB tables (in case of 2012) for capturing the details. The package execution can be done using procedures/t-sql scripts
    using sp_start_job or  catalog.create_execution procedure
    http://msdn.microsoft.com/en-us/library/ff878034.aspx
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Help! Executing SQL from ASP

    This is my Code..
    Set OraSession = CreateObject("OracleInProcServer.XOraSession")
    Set OraDatabase = OraSession.DbOpenDatabase(strDB, strID & "/" &
    strPASS, 0)
    OraDatabase.DbExecuteSQL("DELETE tmp_clean;")
    It then runs a SQL statement which populates the table
    tmp_clean. I don't really want to have to write a procedure to
    do this. It seems not to like the semi colon, but with out it
    it doesn't execute the SQL. Please Help.

    It's okay, I worked it out. I hadn't done a COMMIT from my SQL
    Plus session, so the table was still empty, and it musn't like
    that.

  • Need Help on Executing Shell Scripts through PL-SLQ

    Hi All,
    I am trying to execute a shell script from PL-SQL but I am not getting it right .
    the code i used is as follows
    ----JAVA CLASS ---
    CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "Host" AS
    import java.io.*;
    public class Host {
    public static void executeCommand(String command) {
    try {
    String[] finalCommand;
    if (isWindows()) {
    finalCommand = new String[4];
    // Use the appropriate path for your windows version.
    finalCommand[0] = "C:\\windows\\system32\\cmd.exe"; // Windows XP/2003
    //finalCommand[0] = "C:\\winnt\\system32\\cmd.exe"; // Windows NT/2000
    finalCommand[1] = "/y";
    finalCommand[2] = "/c";
    finalCommand[3] = command;
    else {
    finalCommand = new String[3];
    finalCommand[0] = "/bin/sh";
    finalCommand[1] = "-c";
    finalCommand[2] = command;
    final Process pr = Runtime.getRuntime().exec(finalCommand);
    pr.waitFor();
    new Thread(new Runnable(){
    public void run() {
    BufferedReader br_in = null;
    try {
    br_in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
    String buff = null;
    while ((buff = br_in.readLine()) != null) {
    System.out.println("Process out :" + buff);
    try {Thread.sleep(100); } catch(Exception e) {}
    br_in.close();
    catch (IOException ioe) {
    System.out.println("Exception caught printing process output.");
    ioe.printStackTrace();
    finally {
    try {
    br_in.close();
    } catch (Exception ex) {}
    }).start();
    new Thread(new Runnable(){
    public void run() {
    BufferedReader br_err = null;
    try {
    br_err = new BufferedReader(new InputStreamReader(pr.getErrorStream()));
    String buff = null;
    while ((buff = br_err.readLine()) != null) {
    System.out.println("Process err :" + buff);
    try {Thread.sleep(100); } catch(Exception e) {}
    br_err.close();
    catch (IOException ioe) {
    System.out.println("Exception caught printing process error.");
    ioe.printStackTrace();
    finally {
    try {
    br_err.close();
    } catch (Exception ex) {}
    }).start();
    catch (Exception ex) {
    System.out.println(ex.getLocalizedMessage());
    public static boolean isWindows() {
    if (System.getProperty("os.name").toLowerCase().indexOf("windows") != -1)
    return true;
    else
    return false;
    ---PROCEDURE TO BE EXECUTED WHICH USES THE ABOVE JAVA CLASS IS ----
    CREATE OR REPLACE PROCEDURE Host_Command (p_command IN VARCHAR2)
    AS LANGUAGE JAVA
    NAME 'Host.executeCommand (java.lang.String)';
    --- THE PERMISSIONS ---
    call dbms_java.grant_permission('SYSTEM', 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'read ,write, execute, delete');
    call dbms_java.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
    call dbms_java.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
    --- THE SHELL SCRIPT IS -----
    #!/bin/sh
    # This script removes the carriage returns from the Files having .DAT1 extensions in the /test/ Directory
    # and the sends the single line stream to the new file with the use of 'gawk' command
    # so finaly the files with same primary name but different secondary name are created
    # e.g. file 'test.DAT1' is onverted to 'test.DAT'
    # LOOP on /test/ DIRECTORY FOR SEARCHING FILES HAVING EXTENSION *.DAT1
    for file_name in `ls /test/*.DAT1`
    do
    new_file_name=`echo $file_name | sed 's/DAT1/DAT/'`
    # SEND THE CONTAINTS OF SELECTED FILE IN LOOP AS A CONTINUOUS STREAM TO NEW FILE NAME USING 'gawk' COMMAND
    gawk 'BEGIN { ORS = "''" } { print $0 }' $file_name >> $new_file_name
    # ABOVE LINE WILL CREATE A NEW FILE WITH SAME PRIMARY NAME BUT .DAT AS SECONDARY NAME(EXTENSION)
    # REMOVE THE PRIOR FILE(s) AFTER SUCCESSFUL CALL TO 'gawk'
    # $? returns 0 if the call to gawk command is succesfull
    if test 0 = "$?"
         then
         rm -f $file_name
    fi
    done
    # END LOOP ON /test/ DIRECTORY
    ---THE CALL TO THE PROCEDURE --
    SQL>CALL DBMS_JAVA.SET_OUTPUT(1000000);
    SQL>SET SERVEROUTPUT ON SIZE 1000000
    SQL>exec host('/root/sh ecs_script.sh'); -----------------------------------------------1
    now, the statement 1 is the path of the Shell Script ecs_script.sh
    which uses gawk command and does some operations on some file..
    but when i give the call in Statement 1 its giving error like
    /bin/sh is not a directory
    so i am not getting wHat should I do so that my script "ecs_script.sh" gets executed..
    Please Help.

    @ Bhagat & Michaels
    Dear Friends,
    I changed my shell name as per ur suggestions
    and recompiled the Java class source with
    finalCommand[0] = "/bin/bash"; instead of finalCommand[0] = "/bin/sh";
    and then recompiled the host procedure
    executed the host procedure as per ur suggestion as follows (with out put)
    SQL> exec host('/bin/bash ecs_script.sh')
    PL/SQL procedure successfully completed.
    bt, bt, bt, it still did not do any operations defined in the "ecs_script.sh"
    in fact the script did nt executed.......
    pls help , I am loosing my time..
    regards.

  • Need help on small sql query

    Hi,
    I have a requirement where I need to show 'F&D' string. I can explain this by below query.
    select 'F&D' from dual
    but when I run this query, toad prompts me to enter value for &D variable :( But my requirement is to show 'F&D' string.
    Can anyone please tell me what modification needs to be done to above query to get string 'F&D' as output.
    I know work around for this as below.
    select 'F'||chr(38)||'D' from dual
    I want permenant solution for this. Can anyone please help me?
    Thanks
    Shantanu

    see if below make difference
    SQL> select 'F&D' from dual ;
    Enter value for d: &D
    old   1: select 'F&D' from dual
    new   1: select 'F&D' from dual
    'F&
    F&D
    SQL> select 'F'||'&'||'D' from dual ;
    'F'
    F&D

Maybe you are looking for

  • Mail and Address book integration

    I tried to find a solution to this over the internet but no luck. I have bunch of contacts in my address book. In Mail's list view, the from field is not synchronized with the address book. Say that I have a contact "John Smith" in my address book wi

  • Broadcast and point to point server in the same port

    I'm trying to set up a system where I can send point to point messages via sockets to certain ips, send broadcast messages to every pc in the network, and also be able to listen for point to point messages and broadcast messages, all in the same port

  • What exactly is in the in-app purchase in the new Garageband?

    I've found that the lessons in the old version of Garageband are the same as the new one. If you have the old verison and donwload the lessons from it, you also have the lessons for the new version without paying extra. Likewise, it seems, with many

  • 16:9 print to video - 16:9 Quicktime Export

    Sorry to bother again this those same old 16:9 questions. 1) I have my 16:9 material imported and edited (of course, I have set the configuration for PAL Anamorphotic). What happens, when I go print to video? Does FCE export true 16:9 or does it in f

  • Nokia 3110 c : How to transfer the Video Clip Fold...

    My handset model is Nokia 3110C. The memory of which is around 32~34 MB. I have installed Memory Card of 2GB. Currently, the Video Clip Folder can accommodate only 8 MB maximim. The Files dowmloaded can not save beyond 8 MB. But my SD can hold upto 5