How to return a recordset (SQL)

I would like to know if it is possible to return a record set from a procedure and if so how?
Thanks in advance for any help.

If you find out how to... could you please let me know it...
Thanks... I'm looking for the same thing.
my email: [email protected]

Similar Messages

  • How to return in pl/sql the tuples of an sql query comming  several tables

    I have a select query whose result comes from several tables. The question is how to return the tuples of the select query using a pl/sql function. In othe words, is it possible to define a construct structure to store the values of sql query and return that construct. if yes how to define such a construct where its elements comming from several tables.
    I appreciate very much ur help

    The way to return a resultset from a function is with a cursor variable. The lazy of doing this is using a weakly-typed ref cursor (in 9i use the predefined SYS_REFCURSOR).
    Cheers, APC

  • How to run recordset SQL query in FORM DATA event

    How can I run recordset SQL query in FORM DATA event upon clicking on Add button in the document?

    Hi Slamet,
    When you receive a form data event you have a class containing inside it a ObjectKeys xml info regarding the object added/modified,...
    With the objects keys you can then use the DI API method called GetByKeys to obtain the DI Object.
    There is some information about it in the SDK Help file, mainly in the "FormDataEvent" class definition:
    <i>The event provides the unique ID (BusinessObjectInfo.ObjectKey) of the modified business object. You can use the value of this property as an input parameter in the DI API DataBrowser.GetByKeys method to get a DI object.</i>
    Pay attention you don't have this information in the Before=True event of the Add as it is not yet in the database.
    Hope it helps
    Trinidad.

  • How to test a procedure which returns a recordset from pl/sql

    hello,
    Is it possible to test a procedure which returns a recordset from pl/sql?
    Everything I try results in errors like PLS-00382: expression is of wrong type, when I try to open the result cursor
    or PLS-00221: tc is not a procedure or is undefined.
    I created the following procedure:
    CREATE OR REPLACE PACKAGE test AS
    TYPE cursorType is REF CURSOR;
    PROCEDURE test_cursor( tc IN OUT cursorType,
    v_err OUT varchar2,
    v_msg OUT varchar2);
    END;
    CREATE OR REPLACE
    PACKAGE BODY test AS
    PROCEDURE test_cursor
    (tc IN OUT cursorType,
    v_err OUT varchar2,
    v_msg OUT varchar2)
    AS
    BEGIN
    open tc for
    SELECT '1' "number" FROM dual
    union
    select '2' "number" from dual;
    v_msg := 'no errors';
    v_err := 0;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    v_msg := 'no data found';
    v_err := SQLCODE;
    WHEN OTHERS
    THEN
    v_msg := SQLERRM;
    v_err := SQLCODE;
    END;
    END;
    I try to get the output from pl/sql with something like this:
    DECLARE
    TC PROVGRON.TEST.cursorType;
    V_ERR VARCHAR2(200);
    V_MSG VARCHAR2(200);
    BEGIN
    V_ERR := NULL;
    V_MSG := NULL;
    PROVGRON.TEST.TEST_CURSOR ( TC, V_ERR, V_MSG );
    DBMS_OUTPUT.Put_Line('V_ERR = ' || V_ERR);
    DBMS_OUTPUT.Put_Line('V_MSG = ' || V_MSG);
    -- in tc I was hoping to hava a cursor??
    FOR i IN tc
    LOOP
    DBMS_OUTPUT.PUT_LINE (i.number);
    END LOOP;
    END;
    Without the for loop (or open tc) the pl/sql will output:
    V_ERR = 0
    V_MSG = no errors
    PL/SQL procedure successfully completed.
    With anything I try with the cursor I get errors?
    What am I doing wrong?

    http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch5.htm#sthref1122

  • How do I return a java.sql.Timestamp data type in a Web service?

    I'm new to workshop and java. I'm creating a mini application to simulate a real work Web Service (development environment is on an intranet). I was able to completely simulate the Web Services minus all date values.
    I'm using a standard weblogic workshop database controls that are feeding the various WebServices and their methods (Web services was generated from DB control). I get a java type not support error when I attempt to return a java.sql.Timestamp. I temporarily got around the problem by omitting all dates from the sql.
    However, we are at the point where we need the complete record.
    My two questions
    1) What java data type do I convert the java.sql.Timestamp to
    2) Where and how do I do it in workshop.
    Thanks in advance
    Derrick
    Source view from workshop looks something like this.
    public interface MyData extends DatabaseControl, com.bea.control.ControlExtension
    static public class dbOverallRec
    public String key;
    public String field1;
    public int field2;
    public java.sql.Timestamp create_date
    public dbOverallRec () {};
    *@jc:sq; rowset-name="OverallRowSet" statement::
    *select key, field1, field2 ,create_date from overall where key={KEY}::
    dbOverallRec getOverallByKey(String Key);
    * I had to omit the create_date to get it to work

    You should try changing java.sql.Timestamp to java.util.Calendar.
    java.util.Calendar maps to the dateTime type in XML Schema, and TIMESTAMP as a JDBC type.
    Regards,
    Mike Wooten

  • Return a Recordset in a PL/SQL

    Hello All,
    I'm attempting to write a PL/SQL statement over some very large tables. The processing of the statement takes over 45 minutes to complete.
    I've been able to speed up processing by creating a temp table over the largest of the tables, and it truly has speed up processing. The problem is that this statement will be used in a report run from SQL Reporting Services, using PL/SQL. This will be used in various reports and would like to make this an adhoc type of job - launched by executing the report.
    I've tried writing a procedure that returns a recordset, but I'm having no luck. I'm new to writing Stored Procedures, Functions and Packages, and am trying to get my head around the best way to approach this.
    Here is what I have so far - and it's not even close to working, but you can see the logic I'm trying to follow as far was what I need to return.
    CREATE OR REPLACE PACKAGE PKG_BillSegs_ZeroUsage AS
    TYPE cursor_type IS REF CURSOR;
    Procedure GETBILLSEG_ZEROUSAGE (
                   p_RevMth IN bi_bill_segment.rev_month%TYPE,
    p_recordset OUT PKG_BillSegs_ZeroUsage.cursor_type);
    END PKG_BillSegs_ZeroUsage;
    CREATE OR REPLACE PROCEDURE GetBillSeg_ZeroUsage (p_RevMth IN bi_bill_segment.rev_month%TYPE,
    p_recordset OUT PKG_BillSegs_ZeroUsage.cursor_type) AS
    BEGIN
    OPEN p_recordset FOR
    select * from bi_bill_segment where usage_qty = 0 and rev_month = p_RevMth;
    END GetBillSeg_ZeroUsage;
    Any help is greatly appreciated!

    Here's the output from explain plan - sorry for the output, but couldn't get it to be any prettier :
    OPERATION     OPTIONS     OBJECT_NAME     OBJECT_TYPE     OPTIMIZER     SEARCH_COLUMNS     ID     PARENT_ID     POSITION     COST     CARDINALITY     BYTES
    SELECT STATEMENT     REMOTE               CHOOSE          0          91911     91911     2     4902
    TABLE ACCESS     BY INDEX ROWID     BI_BILL_SEGMENT_T          ANALYZED          1     0     1     91911     2     4902
    INDEX     RANGE SCAN     BI_BILL_SEGMENT_IE7     NON-UNIQUE     ANALYZED     1     2     1     1     659     178774

  • How can I get the return code of SQL*Plus under Win2000Pro

    How can I get the return code of SQL*Plus under Win2000Pro ?

    In a DOS batch script? Try ECHO %ERRORLEVEL%
    -- CJ

  • [Forum FAQ] How do I send multiple rows returned by Execute SQL Task as Email content in SQL Server Integration Services?

    Question:
    There is a scenario that users want to send multiple rows returned by Execute SQL Task as Email content to send to someone. With Execute SQL Task, the Full result set is used when the query returns multiple rows, it must map to a variable of the Object data
    type, then the return result is a rowset object, so we cannot directly send the result variable as Email content. Is there a way that we can extract the table row values that are stored in the Object variable as Email content to send to someone?
    Answer:
    To achieve this requirement, we can use a Foreach Loop container to extract the table row values that are stored in the Object variable into package variables, then use a Script Task to write the data stored in packages variables to a variable, and then set
    the variable as MessageSource in the Send Mail Task. 
    Add four variables in the package as below:
    Double-click the Execute SQL Task to open the Execute SQL Task Editor, then change the ResultSet property to “Full result set”. Assuming that the SQL Statement like below:
    SELECT   Category, CntRecords
    FROM         [table_name]
    In the Result Set pane, add a result like below (please note that we must use 0 as the result set name when the result set type is Full result set):
    Drag a Foreach Loop Container connects to the Execute SQL Task. 
    Double-click the Foreach Loop Container to open the Foreach Loop Editor, in the Collection tab, change the Enumerator to Foreach ADO Enumerator, then select User:result as ADO object source variable.
    Click the Variable Mappings pane, add two Variables as below:
    Drag a Script Task within the Foreach Loop Container.
    The C# code that can be used only in SSIS 2008 and above in Script Task as below:
    public void Main()
       // TODO: Add your code here
                Variables varCollection = null;
                string message = string.Empty;
                Dts.VariableDispenser.LockForWrite("User::Message");
                Dts.VariableDispenser.LockForWrite("User::Category");
                Dts.VariableDispenser.LockForWrite("User::CntRecords");     
                Dts.VariableDispenser.GetVariables(ref varCollection);
                //Format the query result with tab delimiters
                message = string.Format("{0}\t{1}\n",
                                            varCollection["User::Category"].Value,
                                            varCollection["User::CntRecords"].Value
               varCollection["User::Message"].Value = varCollection["User::Message"].Value + message;   
               Dts.TaskResult = (int)ScriptResults.Success;
    The VB code that can be used only in SSIS 2005 and above in Script Task as below, please note that in SSIS 2005, we should
    change PrecompileScriptIntoBinaryCode property to False and Run64BitRuntime property to False
    Public Sub Main()
            ' Add your code here
            Dim varCollection As Variables = Nothing
            Dim message As String = String.Empty
            Dts.VariableDispenser.LockForWrite("User::Message")
            Dts.VariableDispenser.LockForWrite("User::Category")
            Dts.VariableDispenser.LockForWrite("User::CntRecords")
            Dts.VariableDispenser.GetVariables(varCollection)
            'Format the query result with tab delimiters
            message = String.Format("{0}" & vbTab & "{1}" & vbLf, varCollection("User::Category").Value, varCollection("User::CntRecords").Value)
            varCollection("User::Message").Value = DirectCast(varCollection("User::Message").Value,String) + message
            Dts.TaskResult = ScriptResults.Success
    End Sub
    Drag Send Mail Task to Control Flow pane and connect it to Foreach Loop Container.
    Double-click the Send Mail Task to specify the appropriate settings, then in the Expressions tab, use the Message variable as the MessageSource Property as below:
    The final design surface like below:
    References:
    Result Sets in the Execute SQL Task
    Applies to:
    Integration Services 2005
    Integration Services 2008
    Integration Services 2008 R2
    Integration Services 2012
    Integration Services 2014
    Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.

    Thanks,
    Is this a supported scenario, or does it use unsupported features?
    For example, can we call exec [ReportServer].dbo.AddEvent @EventType='TimedSubscription', @EventData='b64ce7ec-d598-45cd-bbc2-ea202e0c129d'
    in a supported way?
    Thanks! Josh

  • Procedure to return a recordset in ASP.

    I'll admint that my background is with MS SQL and Oracle is a bit different!
    In SQL I can create a stored procedure that will return a recordset, filtered by the parameter that I pass to the procedure. Such as:
    CREATE PROCEDURE sp_DriverList @BusCoID int
    AS
    SELECT DISTINCT ListName, DriverID
    FROM T_Drivers
    WHERE BusCoID = @BusCoID
    ORDER BY ListName
    In ASP I get back a list of all the Drivers for a given company, using the @BusCoID parameter.
    When I try to implement this same method in Oracle 9i, I get an error. Can someone provide an example, comparable to the SQL version above, that would return a recordset?
    Thanks!!!

    Your post will likely get a better response on the ODP.NET forum, but here's how I would do it.
    CREATE OR REPLACE PACKAGE my_package
    IS
    TYPE refc IS REF CURSOR
    RETURN t_drivers%ROWTYPE refc;
    Function fetch_drivers(p_busid_in IN number);
    END my package;
    CREATE OR REPLACE PACKAGE BODY my_package
    IS
    Function fetch_drivers (p_busid_in IN number)
    IS
    l_curser refc;
    BEGIN
    OPEN l_cursor FOR
    SELECT DISTINCT ListName, DriverID
    FROM T_Drivers
    WHERE BusCoID = p_busid_in
    ORDER BY ListName;
    RETURN l_cursor;
    END fetch_drivers;

  • How to return each grouping separately in XML?

    I developed this query in T-SQL:
    ; with prov as (
    select NPI,FileCreationDate, FileCreationTime
    from TN_DataFeed2
    group by NPI,FileCreationDate, FileCreationTime
    SELECT
    NPI as [NPI],
    FileCreationDate as [FileCreationDate],
    FileCreationTime as [FileCreationTime],
    Select
    ProviderPatientNo ,
    LastName as [LastName],
    FirstName as [FirstName],
    SSN as [SSN],
    DOB as [DOB],
    Gender as [Gender],
    Race as [Race],
    Ethnicity as [Ethnicity],
    Select
    t_phone.ProviderPhoneAssessmentId,
    t_phone.ProviderF2FAssessmentId,
    CallEndDate,
    CallEndTime,
    DispatchDate,
    DispatchTime,
    CallDisposition,
    DispositionOther,
    Notes,
    select
    ProviderF2FAssessmentId,
    AssessmentDate,
    [ArrivalTime] ,
    ResidentialStatus AS [ResidentialStatus],
    County AS [County],
    EmploymentStatus AS [EmploymentStatus],
    MaritalStatus AS [MaritalStatus],
    MilitaryStatus AS [MilitaryStatus],
    NumArrests30Days AS [NumArrests30Days],
    AttendedSchoolLast3Months AS [AttendedSchoolLast3Months]
    FROM #Assessments t_assess
    where t_phone.ProviderPatientNo = t_assess.ProviderPatientNo
    and t_assess.ProviderF2FAssessmentId is not null
    FOR XML PATH('F2FAssessment'), type) AS [*]
    FROM (select distinct ProviderPatientNo, ProviderPhoneAssessmentId,ProviderF2FAssessmentId,CallEndDate,CallEndTime,DispatchDate,DispatchTime,
    CallDisposition,DispositionOther,Notes from #phones where CallDisposition in (1,5,8)
    and ProviderPhoneAssessmentId = t_base.ProviderPhoneAssessmentId) t_phone
    FOR XML PATH('PhoneAssessment'), type) AS [*]
    FROM (select distinct ProviderPhoneAssessmentId, ProviderPatientNo,LastName,FirstName,SSN,DOB,Gender,Race,Ethnicity from #base) t_base
    FOR XML PATH('Patient'), type
    from prov
    for xml path(''), root('Provider')
    Which returns data like:
    <Patient>
    <ProviderPatientNo>00200791</ProviderPatientNo>
    <LastName>Rob</LastName>
    <FirstName>Chris</FirstName>
    <SSN>7570193</SSN>
    <DOB>2005-09-21</DOB>
    <Gender>2</Gender>
    <Race>6</Race>
    <Ethnicity>2</Ethnicity>
    <PhoneAssessment>
    <ProviderPhoneAssessmentId>0A923156-A8F9-4B92-9FFE-7630B99CBE8D</ProviderPhoneAssessmentId>
    <CallEndDate>2013-09-01</CallEndDate>
    <CallEndTime>13:55:00</CallEndTime>
    <CallDisposition>8</CallDisposition>
    <F2FAssessment>
    <ProviderF2FAssessmentId>BDEC13F5-E175-4A36-A7EA-760DC0E3E786</ProviderF2FAssessmentId>
    <AssessmentDate>2014-01-02</AssessmentDate>
    <ArrivalTime>15:05:00</ArrivalTime>
    <ResidentialStatus>11</ResidentialStatus>
    <County>75</County>
    <EmploymentStatus>10</EmploymentStatus>
    <MaritalStatus>6</MaritalStatus>
    <MilitaryStatus>4</MilitaryStatus>
    <AttendedSchoolLast3Months>1</AttendedSchoolLast3Months>
    </F2FAssessment>
    <F2FAssessment>
    <ProviderF2FAssessmentId>CE0AE86F-1DE3-4B7D-A8FC-B3D07D09B495</ProviderF2FAssessmentId>
    <AssessmentDate>2014-01-02</AssessmentDate>
    <ArrivalTime>13:40:00</ArrivalTime>
    <ResidentialStatus>11</ResidentialStatus>
    <County>97</County>
    <EmploymentStatus>10</EmploymentStatus>
    <MaritalStatus>6</MaritalStatus>
    <MilitaryStatus>4</MilitaryStatus>
    <AttendedSchoolLast3Months>3</AttendedSchoolLast3Months>
    </F2FAssessment>
    </PhoneAssessment>
    </Patient>
    But instead I want this data to look like:
    <Patient>
    <ProviderPatientNo>00200791</ProviderPatientNo>
    <LastName>Rob</LastName>
    <FirstName>Chris</FirstName>
    <SSN>7570193</SSN>
    <DOB>2005-09-21</DOB>
    <Gender>2</Gender>
    <Race>6</Race>
    <Ethnicity>2</Ethnicity>
    <PhoneAssessment>
    <ProviderPhoneAssessmentId>0A923156-A8F9-4B92-9FFE-7630B99CBE8D</ProviderPhoneAssessmentId>
    <CallEndDate>2013-09-01</CallEndDate>
    <CallEndTime>13:55:00</CallEndTime>
    <CallDisposition>8</CallDisposition>
    <F2FAssessment>
    <ProviderF2FAssessmentId>BDEC13F5-E175-4A36-A7EA-760DC0E3E786</ProviderF2FAssessmentId>
    <AssessmentDate>2014-01-02</AssessmentDate>
    <ArrivalTime>15:05:00</ArrivalTime>
    <ResidentialStatus>11</ResidentialStatus>
    <County>75</County>
    <EmploymentStatus>10</EmploymentStatus>
    <MaritalStatus>6</MaritalStatus>
    <MilitaryStatus>4</MilitaryStatus>
    <AttendedSchoolLast3Months>1</AttendedSchoolLast3Months>
    </F2FAssessment>
    </PhoneAssessment>
    <PhoneAssessment>
    <ProviderPhoneAssessmentId>0A923156-A8F9-4B92-9FFE-7630B99CBE8D</ProviderPhoneAssessmentId>
    <CallEndDate>2013-09-01</CallEndDate>
    <CallEndTime>13:55:00</CallEndTime>
    <CallDisposition>8</CallDisposition>
    <F2FAssessment>
    <ProviderF2FAssessmentId>CE0AE86F-1DE3-4B7D-A8FC-B3D07D09B495</ProviderF2FAssessmentId>
    <AssessmentDate>2014-01-02</AssessmentDate>
    <ArrivalTime>13:40:00</ArrivalTime>
    <ResidentialStatus>11</ResidentialStatus>
    <County>97</County>
    <EmploymentStatus>10</EmploymentStatus>
    <MaritalStatus>6</MaritalStatus>
    <MilitaryStatus>4</MilitaryStatus>
    <AttendedSchoolLast3Months>3</AttendedSchoolLast3Months>
    </F2FAssessment>
    </PhoneAssessment>
    </Patient>
    How do I modify my SQL script accordingly?
    Ryan D

    Try this:
    ; with prov as (
    select NPI,FileCreationDate, FileCreationTime
    from TN_DataFeed2
    group by NPI,FileCreationDate, FileCreationTime
    SELECT
    NPI as [NPI],
    FileCreationDate as [FileCreationDate],
    FileCreationTime as [FileCreationTime],
    Select
    ProviderPatientNo ,
    LastName as [LastName],
    FirstName as [FirstName],
    SSN as [SSN],
    DOB as [DOB],
    Gender as [Gender],
    Race as [Race],
    Ethnicity as [Ethnicity],
    Select
    t_phone.ProviderPhoneAssessmentId,
    t_phone.ProviderF2FAssessmentId,
    CallEndDate,
    CallEndTime,
    DispatchDate,
    DispatchTime,
    CallDisposition,
    DispositionOther,
    Notes,
    ProviderF2FAssessmentId as [F2FAssessment/ProviderF2FAssessmentId],
    AssessmentDate as [F2FAssessment/AssessmentDate],
    [ArrivalTime] as [F2FAssessment/ArrivalTime],
    ResidentialStatus as [F2FAssessment/],
    County as [F2FAssessment/],
    EmploymentStatus AS [F2FAssessment/EmploymentStatus],
    MaritalStatus AS [F2FAssessment/MaritalStatus],
    MilitaryStatus AS [F2FAssessment/MilitaryStatus],
    NumArrests30Days AS [F2FAssessment/NumArrests30Days],
    AttendedSchoolLast3Months AS [F2FAssessment/AttendedSchoolLast3Months]
    FROM (select distinct ProviderPatientNo, ProviderPhoneAssessmentId,ProviderF2FAssessmentId,CallEndDate,CallEndTime,DispatchDate,DispatchTime,
    CallDisposition,DispositionOther,Notes
    from #phones where CallDisposition in (1,5,8)
    and ProviderPhoneAssessmentId = t_base.ProviderPhoneAssessmentId) t_phone
    inner join #Assessments t_assess
    On t_phone.ProviderPatientNo = t_assess.ProviderPatientNo
    and t_assess.ProviderF2FAssessmentId is not null
    FOR XML PATH('PhoneAssessment'), type) AS [*]
    FROM (select distinct ProviderPhoneAssessmentId, ProviderPatientNo,LastName,FirstName,SSN,DOB,Gender,Race,Ethnicity from #base) t_base
    FOR XML PATH('Patient'), type
    from prov
    for xml path(''), root('Provider')
    Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

  • Stored procedure: how to return multline table

    Environment: SQL Server 2008 R2, Windows
    Tools: MSMS 2008 R2
    Code:
    CREATE PROCEDURE [dbo].[Cleanup]
    (@id CHAR(12)
    ,@Date DATETIME
    ,@ID int OUT
    ,@Ln_ID CHAR(10) OUT
    ,@qcdate DATETIME OUT
    ,@P4 VARCHAR(8000)OUT
    ,@P9 VARCHAR(8000) OUT
    ,@P11 VARCHAR(8000) OUT
    ) WITH ENCRYPTION
    AS
    BEGIN
    Update Table_mocha
    SET P4=Replace(PE4,RTRIM(Cast(Q_ID as varchar(10))), '')
    where id=@id and order_dt=@Date
    Update Table_mocha
    SET P4 = NullIf(P4,'')
    where id=@id and order_dt=@Date
    Update Table_mocha
    SET P4=LTRIM(RTRIM(P4))
    where id=@id and order_dt=@Date
    SELECT @id=id, ln_id=@ln_id,@p4=p4, @p9=P9,@p11=P11
    where id=@id and order_dt=@Date
    Problem: having three updates would cause the database to lock. How would I pass input paramaters for those three updates in SP. How would I update multiple tables, how to avoid database lock, how to return multi-statment table - value (display
    table contains multiple records)

    I prefer to use different stored procedures to do different things.
    CREATE PROCEDURE [dbo].usp_updatedata
    (@id CHAR(12)
    ,@Date DATETIME
    AS
    BEGIN
    Update Table_mocha
    SET P4=LTRIM(RTRIM(Nullif(Replace(PE4,RTRIM(Cast(Q_ID as varchar(10))), ''),'')))
    where id=@id and order_dt=@Date
    End
    CREATE PROCEDURE [dbo].usp_getData
    (@id CHAR(12)
    ,@Date DATETIME
    AS
    BEGIN
    SET NOCOUNT ON;
    SELECT id, ln_id,p4, P9,P11
    where id=@id and order_dt=@Date
    End

  • How can I improve below SQL performance.

    Hi,
    How can I improve below SQL performance. This SQL consumes CPU and occures wait events. It is running every 10 seconds. When I look at the session information from Enterprise Manager I can see that "Histogram for Wait Event: PX Deq Credit: send blkd"
    I created some indexes. I heard that the indexes are not used when there is a NULL but when I checked the xecution plan It uses index.
    SELECT i.ID
    FROM EXPRESS.invoices i
    WHERE i.nbr IS NOT NULL
    AND i.EXTRACT_BATCH IS NULL
    AND i.SUB_TYPE='COD'
    Explain Plan from Toad
    SELECT STATEMENT CHOOSECost: 77 Bytes: 6,98 Cardinality: 349                     
         4 PX COORDINATOR                
              3 PX SEND QC (RANDOM) SYS.:TQ10000 Cost: 77 Bytes: 6,98 Cardinality: 349           
                   2 PX BLOCK ITERATOR Cost: 77 Bytes: 6,98 Cardinality: 349      
                        1 INDEX FAST FULL SCAN INDEX EXPRESS.INVC_TRANS_INDX Cost: 77 Bytes: 6,98 Cardinality: 349
    Execution Plan from Sqlplus
    | Id | Operation | Name | Rows | Bytes | Cost | TQ |IN-OUT| PQ Distrib |
    | 0 | SELECT STATEMENT | | 349 | 6980 | 77 | | | |
    | 1 | PX COORDINATOR | | | | | | | |
    | 2 | PX SEND QC (RANDOM) | :TQ10000 | 349 | 6980 | 77 | Q1,00 | P->S | QC (RAND) |
    | 3 | PX BLOCK ITERATOR | | 349 | 6980 | 77 | Q1,00 | PCWC | |
    |* 4 | INDEX FAST FULL SCAN| INVC_TRANS_INDX | 349 | 6980 | 77 | Q1,00 | PCWP | |
    Predicate Information (identified by operation id):
    4 - filter("I"."NBR" IS NOT NULL AND "I"."EXTRACT_BATCH" IS NULL AND "I"."SUB_TYPE"='COD')
    Note
    - 'PLAN_TABLE' is old version
    - cpu costing is off (consider enabling it)
    Statistics
    141 recursive calls
    0 db block gets
    5568 consistent gets
    0 physical reads
    0 redo size
    319 bytes sent via SQL*Net to client
    458 bytes received via SQL*Net from client
    1 SQL*Net roundtrips to/from client
    1 sorts (memory)
    0 sorts (disk)
    0 rows processed
    Instance Efficiency Percentages (Target 100%)
    Buffer Nowait %: 100.00
    Redo NoWait %: 100.00
    Buffer Hit %: 99.70
    In-memory Sort %: 100.00
    Library Hit %: 99.81
    Soft Parse %: 99.77
    Execute to Parse %: 63.56
    Latch Hit %: 90.07
    Parse CPU to Parse Elapsd %: 0.81
    % Non-Parse CPU: 98.88
    Top 5 Timed Events                         
    Event     Waits     Time(s)     Avg Wait(ms)     % Total Call Time     Wait Class
    latch: library cache     12,626     16,757     1,327     62.6     Concurrency
    CPU time          5,712          21.Mar     
    latch: session allocation     1,848,987     1,99     1     07.Nis     Other
    PX Deq Credit: send blkd     1,242,265     981     1     03.Tem     Other
    PX qref latch     1,405,819     726     1     02.Tem     Other
    The database version is 10.2.0.1 but we haven't installed the patch 10.2.0.5. yet.
    I am waiting your comments.
    Thanks in advance

    Welcome to the forum.
    I created some indexes. I heard that the indexes are not used when there is a NULL but when I checked the xecution plan It uses index. What columns are indexed?
    And what do:
    select i.sub_type
    ,      count(*)
    from   express.invoices i
    where  i.nbr is not null
    and    i.extract_batch is null
    group by i.sub_type; and
    select i.sub_type
    ,      count(*)
    from   express.invoices i
    group by i.sub_type; return?
    Also, try use the {noformat}{noformat} tag when posting examples/execution plans etc.
    See: HOW TO: Post a SQL statement tuning request - template posting for more tuning instructions.
    It'll make a big difference:
    SELECT i.ID
    FROM EXPRESS.invoices i
    WHERE i.nbr IS NOT NULL
    AND i.EXTRACT_BATCH IS NULL
    AND i.SUB_TYPE='COD'
    Explain Plan from Toad
    SELECT STATEMENT CHOOSECost: 77 Bytes: 6,98 Cardinality: 349                     
         4 PX COORDINATOR                
              3 PX SEND QC (RANDOM) SYS.:TQ10000 Cost: 77 Bytes: 6,98 Cardinality: 349           
                   2 PX BLOCK ITERATOR Cost: 77 Bytes: 6,98 Cardinality: 349      
                        1 INDEX FAST FULL SCAN INDEX EXPRESS.INVC_TRANS_INDX Cost: 77 Bytes: 6,98 Cardinality: 349
    Execution Plan from Sqlplus
    | Id | Operation | Name | Rows | Bytes | Cost | TQ |IN-OUT| PQ Distrib |
    | 0 | SELECT STATEMENT | | 349 | 6980 | 77 | | | |
    | 1 | PX COORDINATOR | | | | | | | |
    | 2 | PX SEND QC (RANDOM) | :TQ10000 | 349 | 6980 | 77 | Q1,00 | P->S | QC (RAND) |
    | 3 | PX BLOCK ITERATOR | | 349 | 6980 | 77 | Q1,00 | PCWC | |
    |* 4 | INDEX FAST FULL SCAN| INVC_TRANS_INDX | 349 | 6980 | 77 | Q1,00 | PCWP | |
    Predicate Information (identified by operation id):
    4 - filter("I"."NBR" IS NOT NULL AND "I"."EXTRACT_BATCH" IS NULL AND "I"."SUB_TYPE"='COD')
    Note
    - 'PLAN_TABLE' is old version
    - cpu costing is off (consider enabling it)
    Statistics
    141 recursive calls
    0 db block gets
    5568 consistent gets
    0 physical reads
    0 redo size
    319 bytes sent via SQL*Net to client
    458 bytes received via SQL*Net from client
    1 SQL*Net roundtrips to/from client
    1 sorts (memory)
    0 sorts (disk)
    0 rows processed
    Instance Efficiency Percentages (Target 100%)
    Buffer Nowait %: 100.00
    Redo NoWait %: 100.00
    Buffer Hit %: 99.70
    In-memory Sort %: 100.00
    Library Hit %: 99.81
    Soft Parse %: 99.77
    Execute to Parse %: 63.56
    Latch Hit %: 90.07
    Parse CPU to Parse Elapsd %: 0.81
    % Non-Parse CPU: 98.88
    Top 5 Timed Events                         
    Event     Waits     Time(s)     Avg Wait(ms)     % Total Call Time     Wait Class
    latch: library cache     12,626     16,757     1,327     62.6     Concurrency
    CPU time          5,712          21.Mar     
    latch: session allocation     1,848,987     1,99     1     07.Nis     Other
    PX Deq Credit: send blkd     1,242,265     981     1     03.Tem     Other
    PX qref latch     1,405,819     726     1     02.Tem     Other

  • ODSI support for return type "PL/SQL TABLE"?

    Hello!
    We are trying to connect our ODSI to an Oracle function with return type "PL/SQL TABLE". The ODSI "wizard" (used to create the physical data service) seems to understand the interface during creation, but when executed it fails. The ODSI server complains about wrong type (PLS-00382: expression is of wrong type) when we execute it from the "test tab".
    The function's metadata is looks like this:
    <params xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdt="http://www.w3.org/2004/07/xpath-datatypes" xmlns:pn1="ld:physical/rekondis/CALC_DEBITING" >
    <param name="RETURN_VALUE" kind="return" xqueryType="pn1:RETURN_VALUE_ROW" nativeTypeCode="1111" nativeType="PL/SQL TABLE"/>
    <param name="PIN_CASE_ID" kind="in" xqueryType="xs:decimal" nativeTypeCode="3" nativeType="NUMBER"/>
    <param name="PIN_ACTION_CODE" kind="in" xqueryType="xs:decimal" nativeTypeCode="3" nativeType="NUMBER"/>
    <param name="PI_AD_NAME" kind="in" xqueryType="xs:string" nativeTypeCode="12" nativeType="VARCHAR2"/>
    </params>
    Any ideas how we can make this work!? Or is this not even supported in ODSI 10.3?
    Thanks!
    // Mikael

    Please refer to the documentation - http://download.oracle.com/docs/cd/E13162_01/odsi/docs10gr3/datasrvc/Create%20Physical%20Data%20Services%20from%20Stored%20Procedures.html

  • How to call at PL/SQL package?

    Hi,
    How to call a PL/SQL package from withing a VORowImpl?
    Also what packages need to be imported for this?
    Thanks,
    AD

    Hi,
    Thanks for the replies friends.
    I understand this is not a good practice to call a pl/sql package. I tried as per the OAF standards.
    My requirement is to display the GL String in a region of type table. This is in iExpense and the region is (ReviewBusinessCCardTblRN.xml) i.e. the Review page in the Expense report creation steps.
    The data in this region is not coming directly from one VO. There are two VOs involved in it.
    1> BusinessCCardLinesForReviewVO
    2> ReceiptBasedLinesVO (This is the actual source of data and it contains a SQL statement)
    The "BusinessCCardLinesForReviewVORowImpl" calls methods in "ReceiptBasedLinesVORowImpl" to get all the data.
    So, my approach was to
    1> Extend "ReceiptBasedLinesVO" and add an attribute for the GL String in the SQL statement.
    2> Write a method in the "ReceiptBasedLinesVOExRowImpl" to fetch the GL String.
    3> Extend BusinessCCardLinesForReviewVO and add an attribute for the GL String.
    4> In the extended VO's (BusinessCCardLinesForReviewVOExRowImpl) row impl, call "ReceiptBasedLinesVOExRowImpl" GL String method.
    5> Then use "BusinessCCardLinesForReviewVO" GL string attribute to display in the region.
    Is there anything wrong with this approach?
    But, this does not seem to be working.
    Steps 3, 4, 5 are working as I tested with hard coded values in "BusinessCCardLinesForReviewVOExRowImpl".
    But when I call method in "ReceiptBasedLinesVOExRowImpl" to get the GL String, it does not working. No error returned. The page displays all the values as it was displaying in the standard functionality.
    As this is an urgent requirement, I thought of writting a PL/SQL function which would take CCID from "BusinessCCardLinesForReviewVO" and return the GL String.
    And call this PL/SQL funtion in "BusinessCCardLinesForReviewVOExRowImpl".
    Please help me on this.
    Srini: Could you please give the exact syntax for calling the PL/SQL stored function in VORowImpl.
    Thanks,
    AD

  • How to return a table to ref cursor?

    My client has created a package stored procedure that takes in 2 parameters of VarChar2 and an out parameter which is a table
    Following is the package header
    CREATE OR REPLACE PACKAGE "PKG_TRAVEL_NEW_SUND" IS
    ---RECORD TYPE DELARATION
    TYPE DIRECT_ALT_REC IS RECORD (SERVICE_NO CBG_DISTANCE_FARE.SERVICE_NO%TYPE,
    DISTANCE CBG_DISTANCE_FARE.DISTANCE%TYPE,
    CASH_FARE_AC CBG_DISTANCE_FARE.CASH_FARE_AC%TYPE,
    CASH_FARE_NON_AC CBG_DISTANCE_FARE.CASH_FARE_NON_AC%TYPE,
    CARD_FARE_AC CBG_DISTANCE_FARE.CARD_FARE_AC%TYPE,
    CARD_FARE_NON_AC CBG_DISTANCE_FARE.CARD_FARE_NON_AC%TYPE,
    EZLINK_FARE_AC CBG_DISTANCE_FARE.EZLINK_FARE_AC%TYPE,
    EZLINK_FARE_NON_AC CBG_DISTANCE_FARE.EZLINK_FARE_NON_AC%TYPE,
    AVG_RUNTIME CBG_DISTANCE_FARE.AVG_RUNTIME%TYPE,
    ALTERNATIVE_NO CBG_DIRECT_ALT.ALTERNATIVE_NO%TYPE,
    MAX_FREQ_AM CBG_SVC.MAX_FREQ_AM%TYPE,
    MIN_FREQ_AM CBG_SVC.MIN_FREQ_AM%TYPE,
    ADVANTAGE_CODE CBG_DIRECT_ALT.ADVANTAGE_CODE%TYPE,
    DIST_FARE_CODE_1 CBG_DISTANCE_FARE.DIST_FARE_CODE%TYPE,
    DIST_FARE_CODE_2 CBG_DISTANCE_FARE.DIST_FARE_CODE%TYPE,
    DIST_FARE_CODE_3 CBG_DISTANCE_FARE.DIST_FARE_CODE%TYPE,
    FROM_STOP_CODE CBG_DISTANCE_FARE.FROM_STOP_CODE%TYPE,
    TO_STOP_CODE CBG_DISTANCE_FARE.TO_STOP_CODE%TYPE,
    MIN_TIME CBG_DIRECT_ALT.MIN_TIME%TYPE,
    MIN_FARE CBG_DIRECT_ALT.MIN_FARE%TYPE,
                                            ACT_FARE CBG_DIRECT_ALT.MIN_FARE%TYPE,
    TRAVEL_TYPE VARCHAR2(4),
    TRANSFER_INFO VARCHAR2(1),
    END_TRANSFER_INFO VARCHAR2(1));
    --TABLE  TYPE DECLARATION
    TYPE BUS_INFO_TAB IS TABLE OF DIRECT_ALT_REC INDEX BY BINARY_INTEGER;
    -- CURSOR TYPE DECLARATION
    TYPE TEMP_REC_STRUCT1 IS RECORD (
    RECORD_POSITION BINARY_INTEGER,
    DIST_FARE_CODE1 CBG_DISTANCE_FARE.DIST_FARE_CODE%TYPE,
    DIST_FARE_CODE2 CBG_DISTANCE_FARE.DIST_FARE_CODE%TYPE,
    DIST_FARE_CODE3 CBG_DISTANCE_FARE.DIST_FARE_CODE%TYPE,
    ADVANTAGE_CODE CBG_DIRECT_ALT.ADVANTAGE_CODE%TYPE,
    MINIMUM_FARE CBG_DIRECT_ALT.MIN_FARE%TYPE,
    MINIMUM_TIME CBG_DIRECT_ALT.MIN_TIME%TYPE,
    TRAVEL_TYPE VARCHAR2(4) );
    TYPE TEMP_TAB_STRUCT1 IS TABLE OF TEMP_REC_STRUCT1 INDEX BY BINARY_INTEGER;
    TEMP_TABLE1 BUS_INFO_TAB;
    G_RESULTSET_INDEX BINARY_INTEGER := 0 ;
    G_TOT_RECS_IN_TAB1 BINARY_INTEGER := 0 ;
    TYPE BUS_INFO_CUR IS REF CURSOR RETURN DIRECT_ALT_REC;
    ---PROCEDURE INSIDE THE PACKAGE
    --- PROCEDURE TO SELECT THE RECORDS
    PROCEDURE SEL_DIRECT_ALT(P_FROM_STOP_CODE IN VARCHAR2,
    P_TO_STOP_CODE IN VARCHAR2,
    RESULTSET IN OUT BUS_INFO_TAB);
    I'm using ODP.net and here is my code
    string storedprocedure = "PKG_TRAVEL_NEW_SUND.SEL_DIRECT_ALT";
    //PKG_TRAVEL_NEW_SUND
    //CBG003_XP_SP_TEST1
    ArrayList retlist = new ArrayList();
    OracleConnection curr_conn = this.GetOpenConnection();
    OracleCommand cmd = curr_conn.CreateCommand();
    cmd = new OracleCommand(storedprocedure, curr_conn);
    cmd.CommandType = CommandType.StoredProcedure;
    // input parameter
    OracleParameter param1 = new OracleParameter();
    OracleParameter param2 = new OracleParameter();
    param1.ParameterName = "start_code";
    param2.ParameterName = "end_code";
    param1.OracleDbType = OracleDbType.Varchar2;
    param2.OracleDbType = OracleDbType.Varchar2;
    param1.Direction = ParameterDirection.Input;
    param2.Direction = ParameterDirection.Input;
    param1.Size = 5;
    param2.Size = 5;
    param1.Value = start_codes;
    param2.Value = end_codes;     
    cmd.Parameters.Add(param1);
    cmd.Parameters.Add(param2);
    OracleParameter outputparam3 = new OracleParameter();
    outputparam3.Direction = ParameterDirection.InputOutput;
    outputparam3.ParameterName = "output";
    outputparam3.OracleDbType = OracleDbType.RefCursor;
    // output type
    cmd.Parameters.Add(outputparam3);
    cmd.ExecuteNonQuery();
    At this point, when i execute Query, i get the message telling me that i could have the wrong number or type arguments for the procedure.
    I've looked thru countless examples saying i should use a RefCursor, but what else could i miss out?

    Hi,
    This is from Metalink NOTE.219191.1 How to return the values in a PL/SQL table to a ref cursor
    Hope it helps,
    Greg
    This document gives details with an example on how to pass the values
    in a PL/SQL table to a ref cursor.
    SCOPE & APPLICATION
    This document is useful for developers who are familiar with SQL & PL/SQL
    How to return the values in a PL/SQL table to a ref cursor
    This can be done by using a SQL Object type instead of a PL/SQL table.
    Here is an example.
    SQL> create or replace type ObjectType as object
    2 ( x int,
    3 y date,
    4 z varchar2(25)
    5 );
    6 /
    Type created.
    SQL> create or replace type TabType as table of ObjectType;
    2 /
    Type created.
    SQL> create or replace
    2 function demo_function( p_start_row in number,
    3 p_end_row in number )
    4 return TabType
    5 as
    6 l_data TabType := TabType();
    7 l_cnt number default 0;
    8 begin
    9 for x in ( select * from emp order by sal desc )
    10 loop
    11 l_cnt := l_cnt + 1;
    12 if ( l_cnt >= p_start_row )
    13 then
    14 l_data.extend;
    15 l_data(l_data.count) :=
    16 objectType( x.empno,
    17 x.hiredate,
    18 x.ename );
    19 end if;
    20 exit when l_cnt = p_end_row;
    21 end loop;
    22
    23 return l_data;
    24 end;
    25 /
    Function created.
    SQL> select *
    2 from the ( select cast( demo_function(3,7) as TabType )
    3 from dual ) a;
    X Y Z
    7902 03-DEC-81 FORD
    7566 02-APR-81 JONES
    7698 01-MAY-81 BLAKE
    7782 09-JUN-81 CLARK
    7844 08-SEP-81 TURNER
    By using a SQL object type, the table can be selected easily.
    SQL> create or replace package demo_pkg
    2 as
    3 type rc is ref cursor;
    4
    5 procedure p( p_cursor in out rc );
    6 end;
    7 /
    Package created.
    SQL> create or replace package body demo_pkg
    2 as
    3
    4 procedure p( P_cursor in out rc )
    5 is
    6 l_data TabType := TabType();
    7 begin
    8 for i in 1 .. 3 loop
    9 l_data.extend;
    10 l_data(i) :=
    11 ObjectType( i, sysdate+i, i || ' data');
    12 end loop;
    13
    14 open p_cursor for
    15 select *
    16 from TABLE ( cast ( l_data as TabType) );
    17 end;
    18
    19 end;
    20 /
    Package body created.
    SQL> set autoprint on
    SQL> variable x refcursor
    SQL> exec demo_pkg.p(:x)
    PL/SQL procedure successfully completed.
    X Y Z
    1 15-NOV-02 1 data
    2 16-NOV-02 2 data
    3 17-NOV-02 3 data

Maybe you are looking for

  • How do I get iPhoto to sync on all my devices

    I have photos on my iPhone, my iPad and my two computers. Some photos are on multiple devices but others are only on one device, my iPhone for example. How do I sync all my photos so that all the devices have all the photos? Is that even possible. I

  • Print Odd Page Dimensions

    I went through a lot of trouble trying to figure out why this wasn't working, so I would like to post my notes for anyone who needs to do this. I needed to print on page sizes that could vary from short, wide pages to tall, narrow pages. I was trying

  • Calculate future date in MM/dd/yyyy format

    Hi, I am trying to add a 56 months to a given date (MM/dd/yyyy string) and output the date in MM/dd/yyyy format. Here is my code:                SimpleDateFormat date = new SimpleDateFormat("MM/dd/yyyy");                date.parse("07/30/2000");     

  • Compliation process - help

    hi, i've got a question. what is the effect of the compilation process in java language: a) program b) library c) mediate file d) ...........? i think that program, but i'm confused. thanks for any advice

  • BDLS cancelled in the midaway - urgent help needed

    Hello All, After refresh from production into test system, we ran BDLS in the test system for logical system name coneversion in background. But the job got aborted throwing some database error (as some other activity was going on and due to which ro