Returning multiple pl/sql tables to VB using ADO + Oracle's OLE DB

Windows XP
VB 6
ADO 2.7
Oracle 9i Client (OLE DB 9.2.0.1)
Oracle DB 8.1.7.2
I have just upgraded a VB5/NT (RDO + MS ODBC for Oracle) app to VB6/XP (ADO + Oracle's OLE DB). The calls to stored procedures that returns tables are not working now. I get following error:
-214721900 ORA-06550: line 1, column 42:
PLS-00201:identifier 'LO_AUDIT_ID_TBL' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Please provide hint/help.

Yes, the LO_AUDIT_ID_TBL is a variable (of table type) being returned from the stored procedure.
I tried changing case of table is in pl/sql.
I tried removing the table(s) from the Call statement...
and I get error message that there are missing parameters.
THANKS SO MUCH FOR YOUR HELP.
I have been reading OLE DB User's guide in which there are examples of Ref Cursors and has no documentation regarding how to achieve same using tables (in stead of Ref Curs). I am also looking for documentation that would describe all different Registry attributes that could be turned on or off to do things, but have not been able to find any.
I am trying to use the PLSQLRSet to retrieve rowsets from pl/sql tables. You can see that in my VB code below, in GetSPResultSet function.
The VB Code is:
Public Function Retrieve() As ADODB.Recordset
Dim inparam(-2 To -1) As Variant 'set to be ignored by GetSPResultSet method
Dim outparam(0) As Variant
Dim strSQL As String
strSQL = "{ CALL PckPLAudit.Sel_Smmry( ?,{resultset 1000, lo_audit_id_tbl, lo_audit_dt_tbl, lo_audit_type_tbl, " & _
"lo_audit_status_tbl, lo_qty_selected_tbl, lo_qty_deselect_tbl, lo_qty_sent_tbl, lo_qty_follow_tbl, " & _
"lo_qty_received_tbl, lo_qty_ncpl_tbl, lo_qty_security_tbl, lo_qty_closed_tbl, lo_qty_sentsec_tbl}, {resultset 1, lo_res_tbl} ) }"
Set rdoRs = mConnection.GetSPResultSet(strSQL, inparam(), outparam())
BuildCollection
Set Retrieve = rdoRs
End Function
Public Function GetSPResultSet(ByVal szSQL As String, InParam() As Variant, OutParam() As Variant) As ADODB.Recordset
'============================================================================
'submits a call to a stored procedure that returns table output parameters.
'out params are interpreted as ADODB.Recordset
'szSQL : SQL call to stored procedure
'InParam() : array of input parameter values
'OutParam() : array of output parameter values set in this function
'============================================================================
Dim qry As New ADODB.Command
Dim ParamIn As ADODB.Parameter
Dim ParamOut As ADODB.Parameter
Dim RS As ADODB.Recordset
Dim inti As Integer
Dim intj As Integer
Dim blnret As Boolean
Dim mErrors As New cErrors
Dim retVal As Double
'Dim itmp As Integer
Dim ParmType As DataTypeEnum
Dim i
On Error GoTo errGetSPResultSet
blnret = True
Set qry = New ADODB.Command
qry.ActiveConnection = mrdoCn
qry.CommandType = adCmdText
qry.CommandText = szSQL
'load rdoParameter object(s) from InParam array if InParam exists
For inti = 0 To UBound(InParam)
'qry.Parameters(i).Value = InParam(inti)
Set ParamIn = New ADODB.Parameter
Select Case TypeName(InParam(inti))
Case "Integer"
ParmType = adDouble
Case "Double"
ParmType = adDouble
Case "String"
ParmType = adChar
Case "Null"
ParmType = adDouble
Case "Date"
ParmType = adDate
Case "Long"
ParmType = adDouble 'jks 12/19/2002
End Select
Set ParamIn = qry.CreateParameter(ParamIn, ParmType, adParamInput)
ParamIn.Value = InParam(inti)
If TypeName(InParam(inti)) = "Null" Then
ParamIn.Size = 0
Else
ParamIn.Size = Len(InParam(inti))
End If
qry.Parameters.Append ParamIn
Next
For intj = 0 To UBound(OutParam)
Set ParamOut = New ADODB.Parameter
Select Case TypeName(OutParam(intj))
Case "Integer"
ParmType = adDouble
Case "Double"
ParmType = adDouble
Case "String"
ParmType = adChar
Case "Null"
ParmType = adEmpty
Case "Empty"
ParmType = adDouble
Case "Date"
ParmType = adDate
Case "Long"
ParmType = adDouble 'jks 12/19/2002
End Select
Set ParamOut = qry.CreateParameter(ParamOut, ParmType, adParamOutput, 255)
qry.Parameters.Append ParamOut
Next
'execute the stored procedure call
qry.Properties("PLSQLRSet") = True
Set RS = qry.Execute() 'rdOpenStatic, rdConcurReadOnly
qry.Properties("PLSQLRSet") = False'
For intj = 0 To UBound(OutParam)
OutParam(intj) = qry.Parameters.Item(inti)
inti = inti + 1
Next
If OutParam(0) <> 0 Then
If OutParam(0) = 999 Then
i = mErrors.DisplayError(Val(OutParam(0)), "SAM")
Else
MsgBox "Database returned error code " & OutParam(0) & "." & vbCrLf & " Unable to complete operation. "
End If
blnret = False
End If
If blnret Then
Set GetSPResultSet = RS
Else
Set GetSPResultSet = Nothing
End If
Set RS = Nothing
Set qry = Nothing
Set ParamIn = Nothing
Set ParamOut = Nothing
exitGetSPResultSet:
Exit Function
errGetSPResultSet:
blnret = ProcessError(Err)
If Not blnret Then Set GetSPResultSet = Nothing
Resume exitGetSPResultSet
End Function
The stored procedure is:
CREATE OR REPLACE PACKAGE BODY D5750PGM.PckPLAudit IS
PROCEDURE Sel_Smmry (
     lo_res_cd          out     number,
     LO_AUDIT_ID_TBL          out     pckclaudit.audit_id_tbl%type,
     lo_audit_dt_tbl          out     pckclaudit.audit_dt_tbl%type,
lo_audit_type_tbl     out     pckclaudit.audit_type_tbl%type,
     lo_audit_status_tbl     out     pckclaudit.audit_status_tbl%type,
     lo_qty_selected_tbl     out     pckclaudit.audit_smmry_qty_tbl%type,
     lo_qty_deselect_tbl     out     pckclaudit.audit_smmry_qty_tbl%type,
     lo_qty_sent_tbl          out     pckclaudit.audit_smmry_qty_tbl%type,
     lo_qty_follow_tbl     out     pckclaudit.audit_smmry_qty_tbl%type,
     lo_qty_received_tbl     out     pckclaudit.audit_smmry_qty_tbl%type,
     lo_qty_ncpl_tbl          out     pckclaudit.audit_smmry_qty_tbl%type,
     lo_qty_security_tbl     out     pckclaudit.audit_smmry_qty_tbl%type,
     lo_qty_closed_tbl     out     pckclaudit.audit_smmry_qty_tbl%type,
     lo_qty_sentsec_tbl     out     pckclaudit.audit_smmry_qty_tbl%type,
     lo_res_tbl          out     pcktbtable_type.res_tbl%type
IS
BEGIN
     PckAudit.Sel_Smmry (pckclglobal.lg_pl_proc, lo_res_cd,
     lo_audit_id_tbl,
     lo_audit_dt_tbl,
lo_audit_type_tbl,
     lo_audit_status_tbl,
     lo_qty_selected_tbl,
     lo_qty_deselect_tbl,
     lo_qty_sent_tbl,
     lo_qty_follow_tbl,
     lo_qty_received_tbl,
     lo_qty_ncpl_tbl,
     lo_qty_security_tbl,
     lo_qty_closed_tbl,
     lo_qty_sentsec_tbl,
     lo_res_tbl
END Sel_Smmry;
END PckPLAudit;
also, pckclaudit.audit_id_tbl%type is defined as
TYPE audit_id_tbl_type IS TABLE OF disb_audit.disb_audit_id%TYPE
     INDEX BY BINARY_INTEGER ;
and disb_audit.disb_audit_id%TYPE is defined as
CREATE TABLE D5750.DISB_AUDIT
DISB_AUDIT_ID NUMBER(9,0) NOT NULL,
AUDIT_DT DATE NOT NULL,
AUDIT_CODE_TYPE_ID VARCHAR2(5) NOT NULL,
AUDIT_CODE_ID VARCHAR2(2) NOT NULL,
CRTN_ID VARCHAR2(8) NOT NULL,
CRTN_DT_TM DATE NOT NULL,
etc.

Similar Messages

  • Function which returns multiple values that can then be used in an SQL Sele

    I'd like to create a function which returns multiple values that can then be used in an SQL Select statement's IN( ) clause
    Currently, the select statement is like (well, this is a very simplified version):
    select application, clientid
    from tbl_apps, tbl_status
    where tbl_apps.statusid = tbl_status.statusid
    and tbl_status.approved > 0;
    I'd like to pull the checking of the tbl_status into a PL/SQL function so my select would look something like :
    select application, clientid
    from tbl_apps
    where tbl_apps.statusid in (myfunction);
    So my function would be running this sql:
    select statusid from tbl_status where approved > 0;
    ... will return values 1, 5, 15, 32 (and more)
    ... but I haven't been able to figure out how to return the results so they can be used in SQL.
    Thanks for any help you can give me!!
    Trisha Gorr

    Perhaps take a look at pipelined functions:
    Single column example:
    SQL> CREATE OR REPLACE TYPE split_tbl IS TABLE OF VARCHAR2(32767);
      2  /
    Type created.
    SQL> CREATE OR REPLACE FUNCTION split (p_list VARCHAR2, p_delim VARCHAR2:=' ') RETURN SPLIT_TBL PIPELINED IS
      2      l_idx    PLS_INTEGER;
      3      l_list   VARCHAR2(32767) := p_list;
      4      l_value  VARCHAR2(32767);
      5    BEGIN
      6      LOOP
      7        l_idx := INSTR(l_list, p_delim);
      8        IF l_idx > 0 THEN
      9          PIPE ROW(SUBSTR(l_list, 1, l_idx-1));
    10          l_list := SUBSTR(l_list, l_idx+LENGTH(p_delim));
    11        ELSE
    12          PIPE ROW(l_list);
    13          EXIT;
    14        END IF;
    15      END LOOP;
    16      RETURN;
    17    END SPLIT;
    18  /
    Function created.
    SQL> SELECT column_value
      2  FROM TABLE(split('FRED,JIM,BOB,TED,MARK',','));
    COLUMN_VALUE
    FRED
    JIM
    BOB
    TED
    MARK
    SQL> create table mytable (val VARCHAR2(20));
    Table created.
    SQL> insert into mytable
      2  select column_value
      3  from TABLE(split('FRED,JIM,BOB,TED,MARK',','));
    5 rows created.
    SQL> select * from mytable;
    VAL
    FRED
    JIM
    BOB
    TED
    MARK
    SQL>Multiple column example:
    SQL> CREATE OR REPLACE TYPE myrec AS OBJECT
      2  ( col1   VARCHAR2(10),
      3    col2   VARCHAR2(10)
      4  )
      5  /
    Type created.
    SQL>
    SQL> CREATE OR REPLACE TYPE myrectable AS TABLE OF myrec
      2  /
    Type created.
    SQL>
    SQL> CREATE OR REPLACE FUNCTION pipedata(p_str IN VARCHAR2) RETURN myrectable PIPELINED IS
      2    v_str VARCHAR2(4000) := REPLACE(REPLACE(p_str, '('),')');
      3    v_obj myrec := myrec(NULL,NULL);
      4  BEGIN
      5    LOOP
      6      EXIT WHEN v_str IS NULL;
      7      v_obj.col1 := SUBSTR(v_str,1,INSTR(v_str,',')-1);
      8      v_str := SUBSTR(v_str,INSTR(v_str,',')+1);
      9      IF INSTR(v_str,',')>0 THEN
    10        v_obj.col2 := SUBSTR(v_str,1,INSTR(v_str,',')-1);
    11        v_str := SUBSTR(v_str,INSTR(v_str,',')+1);
    12      ELSE
    13        v_obj.col2 := v_str;
    14        v_str := NULL;
    15      END IF;
    16      PIPE ROW (v_obj);
    17    END LOOP;
    18    RETURN;
    19  END;
    20  /
    Function created.
    SQL>
    SQL> create table mytab (col1 varchar2(10), col2 varchar2(10));
    Table created.
    SQL>
    SQL> insert into mytab (col1, col2) select col1, col2 from table(pipedata('(1,2),(2,3),(4,5)'));
    3 rows created.
    SQL>
    SQL> select * from mytab;
    COL1       COL2
    1          2
    2          3
    4          5

  • List of SQL tables and attributes used in SSRS reports

    Hi,
    I have around 450-500 reports deployed in SSRS reporting server.
    All these reports are built on SQL from multiple databases, and these databases are having unnecessary tables and attributes.
    My requirement is to clean the unused tables and attributes from the databases. For this, I need the list of SQL tables and attributes used in these 450-500 SSRS reports.
    Is there any way to get this data?
    Regards,
    RK

    Hi RK,
    According to your description, you want to get a list of the tables and attributes used in all reports.
    In your scenario, you can query the ReportServer.dbo.Catalog table to get Report name, data source name, dataset name, and query used in the dataset with query below:
    WITH XMLNAMESPACES ( DEFAULT 'http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition', 'http://schemas.microsoft.com/SQLServer/reporting/reportdesigner' AS rd )
    SELECT ReportName = name
    ,DataSetName = x.value('(@Name)[1]', 'VARCHAR(250)')
    ,DataSourceName = x.value('(Query/DataSourceName)[1]','VARCHAR(250)')
    ,CommandText = x.value('(Query/CommandText)[1]','VARCHAR(250)')
    ,Fields = df.value('(@Name)[1]','VARCHAR(250)')
    ,DataField = df.value('(DataField)[1]','VARCHAR(250)')
    ,DataType = df.value('(rd:TypeName)[1]','VARCHAR(250)')
    --,ConnectionString = x.value('(ConnectionProperties/ConnectString)[1]','VARCHAR(250)')
    FROM ( SELECT C.Name,CONVERT(XML,CONVERT(VARBINARY(MAX),C.Content)) AS reportXML
    FROM ReportServer.dbo.Catalog C
    WHERE C.Content is not null
    AND C.Type = 2
    ) a
    CROSS APPLY reportXML.nodes('/Report/DataSets/DataSet') r ( x )
    CROSS APPLY x.nodes('Fields/Field') f(df)
    ORDER BY name
    For more information, please refer to this similar thread:
    Extract metadata from report server database
    If you have any question, please feel free to ask.
    Best regards,
    Qiuyun Yu
    Qiuyun Yu
    TechNet Community Support

  • 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 create a function that returns multiple rows in table

    Dear all,
    I want to create a funtion that returns multiple rows from the table (ex: gl_balances). I done following:
    -- Create type (successfull)
    Create or replace type tp_gl_balance as Object
    PERIOD_NAME VARCHAR2(15),
    CURRENCY_CODE VARCHAR2(15),
    PERIOD_TYPE VARCHAR2(15),
    PERIOD_YEAR NUMBER(15),
    BEGIN_BALANCE_DR NUMBER,
    BEGIN_BALANCE_CR NUMBER
    -- successfull
    create type tp_tbl_gl_balance as table of tp_gl_balance;
    but i create a function for return some rows from gl_balances, i can't compile it
    create or replace function f_gl_balance(p_period varchar2) return tp_tbl_gl_balance pipelined
    as
    begin
    return
    (select gb.period_name, gb.currency_code, gb.period_type, gb.period_year, gb.begin_balance_dr, gb.begin_balance_cr
    from gl_balances gb
    where gb.period_name = p_period);
    end;
    I also try
    create or replace function f_gl_balance(p_period varchar2) return tp_tbl_gl_balance pipelined
    as
    begin
    select gb.period_name, gb.currency_code, gb.period_type, gb.period_year, gb.begin_balance_dr, gb.begin_balance_cr
    from gl_balances gb
    where gb.period_name = p_period;
    return;
    end;
    Please help me solve this function.
    thanks and best reguard

    hi,
    Use TABLE FUNCTIONS,
    [http://www.oracle-base.com/articles/9i/PipelinedTableFunctions9i.php]
    Regards,
    Danish

  • ERROR WHEN RETURNING A PL/SQL TABLE?

    Hi,
    I try to call a Oracle 9i function from Oracle 8i via TEST9.WORLD dblink.
    The function returns me a pl/sql table.
    It compiles but when I try to execute I get the following error
    The following error has occurred:
    ORA-02068: following severe error from TEST9.WORLD
    ORA-06512: at "TBSDEV.GETDATA", line 12
    ORA-06512: at line 2
    Note: I test the code in a single database instance
    and it works fine. The problem occurs when I move the getData function to 8i and
    call the package function via a dblink.
    What can I do?
    what might be the problem?
    Does not Oracle permit us move table of records between 2 database instances?
    ]f it does not, it is very tragic because we can get the SQL Server record sets to
    Oracle 9i through a gateway but we could not move these records sets within Oracle?
    !!!!!!!!!!! All of the code .} use is listed below.
    thanks in advance.
    --BELOW IS MY PACKAGE IN ORACLE 9i SERVER
    --THIS PACKAGE GETS DATA FROM SQL SERVER THROUGH TRASPARENT GATEWAY
    CREATE OR REPLACE package tgw is
    TYPE RefCursorType IS REF CURSOR;
    TYPE HisseRecordType IS RECORD( HisseAd VARCHAR2(20) := '' );
    TYPE HisseTableType IS TABLE OF HisseRecordType INDEX BY BINARY_INTEGER;
    mytable HisseTableType;
    myrecord HisseRecordType;
    function getRecords return HisseTableType ;
    end;
    CREATE OR REPLACE package body tgw is
    function getRecords return HisseTableType is
    rc RefCursorType;
    htable HisseTableType;
    hrec HisseRecordType;
    BEGIN
    "ahtha"."getHisseSenetleri"@ata(rc); --CALLS SQL SERVER STORED PROCEDURE
    FOR i IN 1..10 LOOP
    FETCH rc INTO htable(i);
    END LOOP;
    CLOSE rc;
    RETURN htable;
    END;
    end;
    --HERE IS THE PROCEDURE IN OUR MAIN ORACLE 8i SERVER
    -- TGW9i ]S THE dblink to the oracle 9i
    -- THE BELOW CODE COMPILES BUT GIVES THE ERROR I MENTIONED ABOVE
    PROCEDURE getdata is
    htable tgw9i.mytable%TYPE;
    hrec tgw9i.myrecord%TYPE;
    begin
    htable:=tgw9i.getRecords(10);
    FOR i IN 1..10 LOOP
    DBMS_OUTPUT.PUT_LINE(htable(i).HisseAd);
    END LOOP;
    end;

    The problem might be passing PL/SQL Tables or Records over your database link. You might run some more simple tests with PL/SQL Records and Tables over your link.
    1) I still suggest you use a GLOBAL TEMPORARY TABLE to pass your information, attempt to do everything in a few SQL statements to pass the informaiton. And then process it on the other side. Database links tend to be a bit slow, and so you want to try to reduce the number of times you extract information through the link.
    2) Someone else may have more experience with DB links, and calling procedures through them.
    I wish you luck that you find your answer soon,
    Eric Kamradt

  • Passing pl/sql table to Java using Oracle JDBC and vice - versa

    A small article on the given topic with sample code and comments, to make code crystal:
    http://mukx.blogspot.com/2007/12/passing-plsql-table-to-java-using.html
    --Mukul                                                                                                                                                                                                                                                                                                                                                           

    Tapash,
    I have seen people using Rosetta in almost all projects in previous years, frequently in couple of projects. I was not aware that Rosetta is an internal thing, anyways if that is the case y oracle is shipping rosetta jar file to customers?
    --Mukul                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Connecting to SQL Server from Solaris using Perl & Oracle.

    Hey All,
    Using the DBI.pm provided by the default Perl package that comes integrated with Oracle server, I am being able to connect to the Oracle database through Perl.
    But is there a way I can connect to SQL Server through Perl using any package provided by Oracle like ODBC or something else (on Solaris)
    I am using following version of Oracle server on Solaris 10
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    TIA
    Parag

    The problem is I cannot install any third party package but I found something. Have a look at this:
    bash-3.00$ pwd
    /opt/oracle/product/10.2.0.4.0/perl/lib/site_perl/5.8.3/sun4-solaris-thread-multi/Win32
    bash-3.00$ ls -l
    total 10
    -rwxr-xr-x 1 oracle dba 4532 Jul 7 2004 DBIODBC.pm
    bash-3.00$
    Will explore more and keep you all posted.
    Cheers,
    Parag

  • Unit test, how to test a function which returns a PL/SQL table.

    I've got the following type definition:
    create or replace type method_tbl as table of varchar2(255);
    /I've got the following function
    function abc(p_param1 in varchar2) return method_tbl;When I create a unit test for this I am not able to specify what the table should contain on return of the function, all I can see is an empty table. Which is off course one of the unit tests. But I also want to test where the table that is returned contains a number of rows.
    Is there something that I'm missing?
    Typically the function is called like this:
    select * from table(abc('a'));Thanks,
    Ronald

    >
    When I create a unit test for this I am not able to specify what the table should contain on return of the function, all I can see is an empty table. Which is off course one of the unit tests. But I also want to test where the table that is returned contains a number of rows.
    Is there something that I'm missing?
    >
    You will have to create a collection that represents the result set and then compare that to the actual result set.
    Assuming tables A and B you would typically have to do
    1. SELECT * FROM A MINUS SELECT * FROM B -- what is in A that is NOT in B
    2. SELECT * FROM B MINUS SELECT * FROM A -- what is in B that is NOT in A
    You could combine those two queries into one with a UNION ALL but since the results are tables and the comparison is more complex it is common to write a function to determine the comparison result.
    Here is sample code that shows how to create an expected result collection.
    DECLARE
    expectedItemList sys.OdciVarchar2List;
    functionItemList sys.OdciVarchar2List;
    newItemList sys.OdciVarchar2List;
    expectedCount INTEGER;
    countFunctionItemList INTEGER;
    BEGIN
    expectedItemList := sys.OdciVarchar2List('car','apple','orange','banana','kiwi');
    expectedCount := 5; -- or query to count them
    functionItemList := sys.OdciVarchar2List('car','apple','orange','peanut');
    -- use your function to get the records
    -- select * from myFunctino BULK COLLECT INTO functionItemList
    IF functionItemList.count != expectedCount THEN
      DBMS_OUTPUT.PUT_LINE('Count is ' || functionItemList.count || ' but should be ' || expectedCount);
    END IF;
    END;
    Count is 4 but should be 5If the collections are the same type you can use the MULTISET operators.
    See Solomon's reply in this thread for how to use the MULTISET operators on collections.
    PLS-00306: wrong number or type of argument in call to 'MULTISET_UNION_ALL'
    See MultisetOperators in the SQL Reference doc
    http://docs.oracle.com/cd/B13789_01/server.101/b10759/operators006.htm
    >
    Multiset operators combine the results of two nested tables into a single nested table.

  • Pl/sql block returning multiple rows

    Hi,
    I've created a plsql block which obtains an id from a name and then uses this id in another sql statement. The select statement to get the id works fine and the correct id is placed into the variable awardID.
    when i try to use this variable in another select statement it returns multiple rows. but when i just use the id in the select statement it works fine.
    select AwardID into awardID
    from award_objtabA
    where Name = awardName;
    this returns the correct id '5999'
    select Points into award_points
    from award_objtabA
    where AwardID = awardID;
    this returns multiple rows
    select Points into award_points
    from award_objtabA
    where AwardID = 5999;
    this works fine
    can anybody help with this confusing error?
    Cheers

    select AwardID
      into awardID               <= the same column
      from award_objtabA
    where Name = awardName;
    this returns the correct id '5999'
    select Points
      into award_points
      from award_objtabA
    where AwardID = awardID;    <= the same column
    this returns multiple rows
    to solve use different name not exactly the same as that of the column name
    select AwardID
      into vAwardID        
      from award_objtabA
    where Name = awardName;
    select Points
      into award_points
      from award_objtabA
    where AwardID = vAwardID;as Alex and Kamal have suggested use different name for your variable.

  • Using PL/SQL Table in Forms

    Hi,
    I am populating a PL/SQL table by fetching data through a explicit cursor. But when i am accessing the PL/SQL table after population, i am getting a "NO DATA FOUND" error.
    I am attaching the Forms local progam units which have the logic.
    PACKAGE f_get_bike_makers IS
    TYPE prectype_maker_dtls_pll IS RECORD (
    country_code ad_bike_maker_details.abmd_country_code%TYPE,
    country_name table_values.tvs_description%TYPE,
    manu_code ad_bike_maker_details.abmd_manufacturer_code%TYPE,
    maker_name ad_bike_maker_details.abmd_maker_name%TYPE,
    maker_name_kana ad_bike_maker_details.abmd_maker_name_kana%TYPE,
    const_by ad_bike_maker_details.abmd_constructed_by%TYPE,
    const_time ad_bike_maker_details.abmd_construction_time%TYPE,
    update_by ad_bike_maker_details.abmd_updated_by%TYPE,
    update_time ad_bike_maker_details.abmd_updated_time%TYPE
    TYPE ptabtype_maker_dtls_pll IS TABLE OF prectype_maker_dtls_pll
    INDEX BY BINARY_INTEGER;
    FUNCTION f_get_bike_makers_pll RETURN ptabtype_maker_dtls_pll;
    END;
    PACKAGE BODY f_get_bike_makers IS
    FUNCTION f_get_bike_makers_pll
    RETURN ptabtype_maker_dtls_pll
    IS
    CURSOR cur_maker_dtls
    IS
    SELECT abmd.abmd_country_code,
    tvs.tvs_description,
    abmd.abmd_manufacturer_code,
    abmd.abmd_maker_name,
    abmd.abmd_maker_name_kana,
    abmd.abmd_constructed_by,
    abmd.abmd_construction_time,
    abmd.abmd_updated_by,
    abmd.abmd_updated_time
    FROM ad_bike_maker_details abmd,
    table_values tvs
    WHERE abmd.abmd_country_code = tvs.tvs_code
    AND tvs.tvs_tad_code = 'COUNTRIES'
    ORDER BY abmd.abmd_country_code;
    ln_tab_index BINARY_INTEGER := 0;
    ltab_maker_dtls ptabtype_maker_dtls_pll;
    BEGIN
    FOR lcur_maker_dtls IN cur_maker_dtls
    LOOP
    ln_tab_index := ln_tab_index + 1;
    ltab_maker_dtls (ln_tab_index) := lcur_maker_dtls;
    END LOOP;
    RETURN ltab_maker_dtls;
    END f_get_bike_makers_pll;
    END;
    PROCEDURE f_populate_maker_names
    IS
    ltab_maker_dtls f_get_bike_makers.ptabtype_maker_dtls_pll;
    lb_record_group BOOLEAN;
    ln_ltab_maker_dtls_index BINARY_INTEGER;
    BEGIN
    -- read all the vehicle types from table_values
    -- get makers and countries
    ltab_maker_dtls := f_get_bike_makers.f_get_bike_makers_pll ;
    DELETE_GROUP_ROW ('REC_MAKER_NAME', all_rows);
    ln_ltab_maker_dtls_index := ltab_maker_dtls.FIRST;
    begin
    WHILE ln_ltab_maker_dtls_index IS NOT NULL
    LOOP
    lb_record_group := l_record_group.insert_value ('REC_MAKER_NAME',
    'ABMD_MANUFACTURER_CODE',
    ltab_maker_dtls (ln_ltab_maker_dtls_index).manu_code,
    ln_ltab_maker_dtls_index
    lb_record_group := l_record_group.insert_value ('REC_MAKER_NAME',
    'ABMD_MAKER_NAME',
    ltab_maker_dtls (ln_ltab_maker_dtls_index).maker_name,
    ln_ltab_maker_dtls_index
    lb_record_group := l_record_group.insert_value ('REC_MAKER_NAME',
    'COUNTRY_NAME',
    ltab_maker_dtls (ln_ltab_maker_dtls_index).country_name,
    ln_ltab_maker_dtls_index
    lb_record_group := l_record_group.insert_value ('REC_MAKER_NAME',
    'ABMD_COUNTRY_CODE',
    ltab_maker_dtls (ln_ltab_maker_dtls_index).country_code,
    ln_ltab_maker_dtls_index
    ln_ltab_maker_dtls_index := ltab_maker_dtls.NEXT (ln_ltab_maker_dtls_index);
    end;
    END LOOP;
    exception when no_data_found then
    message('ln_ltab_maker_dtls_index :'||ln_ltab_maker_dtls_index);
    message(' ');
    end;
    ltab_maker_dtls.DELETE;
    END;
    SQL> desc ad_bike_maker_details
    Name Null? Type
    ABMD_COUNTRY_CODE NOT NULL VARCHAR2(2)
    ABMD_MANUFACTURER_CODE NOT NULL VARCHAR2(2)
    ABMD_MAKER_NAME VARCHAR2(60)
    ABMD_MAKER_NAME_KANA VARCHAR2(60)
    ABMD_CONSTRUCTED_BY NOT NULL VARCHAR2(20)
    ABMD_CONSTRUCTION_TIME NOT NULL DATE
    ABMD_UPDATED_BY VARCHAR2(20)
    ABMD_UPDATED_TIME DATE
    SQL> desc table_values
    Name Null? Type
    TVS_TAD_CODE NOT NULL VARCHAR2(15)
    TVS_CODE NOT NULL VARCHAR2(15)
    TVS_DESCRIPTION NOT NULL VARCHAR2(70)
    Oracle Database Version
    =======================
    Oracle8 Enterprise Edition Release 8.0.6.1.0 - Production
    PL/SQL Release 8.0.6.1.0 - Production
    Forms Version
    ==============
    Forms [32 Bit] Version 5.0.6.8.0 (Production)
    PL/SQL Version 2.3.4.0.0 (Production)
    Please do let know what could be the possible source of error.
    Thanks in advance.
    Nitin

    But we have to use the PL/SQL table as per our design standards.
    We are implementing the population logic of the PL/SQL table in the database as a
    package function. We are then accessing the PL/SQL table in Forms to populate the record group.It is curious that you would have such a unique requirement -- something that might make forms run a tiny bit faster -- yet you are using an ancient version of Forms.
    Also the "NO DATA FOUND" error is not raised everytime the PL/SQL table is accessed.
    What could be the reason for this erratic behaviour?I wonder if there may be a bug in SQL Net in the Oracle-to-Forms communication where PL/SQL tables are passed as out parameters. I know there is one in Web Forms 6 (6.0.8.19.1) when passing a pl/sql table from the form to Oracle -- I had to write the pl/sql table to a database table to get my process to work.

  • Calling PL/SQL-package, returning PL/SQL-table

    Hi,
    I'm trying to call a PL/SQL-function returning a PL/SQL-table with two numbers. The below code gives me the cryptic error 'Invalid column index'. Does anyone know how to do this ? I want to display tab_innlogginger (1) and tab_innlogginger (2) in the report...
    <dataSet id="Innlogginger">
    <sql dataSourceRef="DWH-PL">
    <![CDATA[
    declare
    tab_innlogginger dwh_lib.tabdef_innlogginger;
    begin
    tab_innlogginger := dwh_lib.tellinnlogginger (:l_fra_dato, :l_til_dato);
    end
    ]]>
    </sql>
    <input id="l_fra_dato" value="${l_fra_dato}" dataType="xsd:date"/>
    <input id="l_til_dato" value="${l_til_dato}" dataType="xsd:date"/>
    </dataSet>
    The dwh_lib.tabdef_innlogginger is defined as:
    type tabdef_innlogginger is table of number index by binary_integer;
    Regards
    Erik

    OK, found something here:
    Re: steps to create BI publisher report through oracle stored procedure
    Seems pipelined functions using Oracle-objects should work.

  • PLSQL web service returning multiple records

    Hello,
    I am trying to create a web service using oracle 11g which should be able to return multiple records.
    Based on hints and code samples found on the internet here is my code :
    CREATE OR REPLACE TYPE test_rec is OBJECT (
        s_nume_adre                    NUMBER ,
        c_eta_civi                     VARCHAR2(4 BYTE),
        l_nom1_comp                    VARCHAR2(40 BYTE),
        l_nom2_comp                    VARCHAR2(40 BYTE),
        l_nom3_comp                    VARCHAR2(40 BYTE),
        l_pren_comp                    VARCHAR2(30 BYTE),
        d_date_nais                    DATE);
    CREATE OR REPLACE TYPE test_array AS TABLE OF test_rec;
    CREATE OR REPLACE PACKAGE test_pkg AS
      function get_rows(snume_adre in number) return test_array;
    END;
    CREATE OR REPLACE PACKAGE BODY test_pkg AS
      function get_rows(snume_adre in number) return test_array is
        v_rtn   test_array := test_array(null);
        v_first boolean := true;
        cursor c_get_rows(snume_adre in number) is
          SELECT a.s_nume_adre,
                 nvl(a.c_eta_civi, '') c_eta_civi,
                 nvl(a.l_nom1_comp, '') l_nom1_comp,
                 nvl(a.l_nom2_comp, '') l_nom2_comp,
                 nvl(a.l_nom3_comp, '') l_nom3_comp,
                 nvl(a.l_pren_comp, '') l_pren_comp,
                 nvl(a.d_date_nais, to_date('01.01.1900', 'dd.mm.yyyy')) d_date_nais
        FROM bro.z45 a
      where a.s_nume_adre = snume_adre or snume_adre is null;
      begin
        for rec in c_get_rows(snume_adre) loop
          if v_first then
            v_first := false;
          else
            v_rtn.extend;
          end if;
        v_rtn(v_rtn.last) := test_rec(rec.s_nume_adre, rec.c_eta_civi, rec.l_nom1_comp, rec.l_nom2_comp,
                                    rec.l_nom3_comp, rec.l_pren_comp, rec.d_date_nais);
        end loop;  
        return v_rtn;
      end;
    END;
    --select * from table (test_pkg.get_rows(null));
    I am able to retrieve the data using the select.
    However when I try to access its wsdl I get an error :
    <soap:Envelope>
       <soap:Body>
          <soap:Fault>
             <faultcode>soap:Client</faultcode>
             <faultstring>Error processing input</faultstring>
             <detail>
                <OracleErrors></OracleErrors>
             </detail>
          </soap:Fault>
       </soap:Body>
    </soap:Envelope>
    If I comment the function call in the package declaration I get a "correct" wsdl :
    <definitions name="GET_ROWS" targetNamespace="http://xmlns.oracle.com/orawsv/TEST/TEST_PKG/GET_ROWS" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://xmlns.oracle.com/orawsv/TEST/TEST_PKG/GET_ROWS" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
      <types>
        <xsd:schema targetNamespace="http://xmlns.oracle.com/orawsv/TEST/TEST_PKG/GET_ROWS" elementFormDefault="qualified">
          <xsd:element name="GET_ROWSInput">
            <xsd:complexType>
              </xsd:complexType>
          </xsd:element>
          <xsd:element name="GET_ROWSOutput">
            <xsd:complexType>
              </xsd:complexType>
          </xsd:element>
       </xsd:schema>
      </types>
      <message name="GET_ROWSInputMessage">
        <part name="parameters" element="tns:GET_ROWSInput"/>
      </message>
      <message name="GET_ROWSOutputMessage">
        <part name="parameters" element="tns:GET_ROWSOutput"/>
      </message>
      <portType name="GET_ROWSPortType">
      <operation name="GET_ROWS">
          <input message="tns:GET_ROWSInputMessage"/>
          <output message="tns:GET_ROWSOutputMessage"/>
        </operation>
      </portType>
      <binding name="GET_ROWSBinding" type="tns:GET_ROWSPortType">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <operation name="GET_ROWS">
          <soap:operation soapAction="GET_ROWS"/>
          <input>
            <soap:body parts="parameters" use="literal"/>
          </input>
          <output>
            <soap:body parts="parameters" use="literal"/>
          </output>
        </operation>
      </binding>
      <service name="GET_ROWSService">
        <documentation>Oracle Web Service</documentation>
        <port name="GET_ROWSPort" binding="tns:GET_ROWSBinding">
           <soap:address location="http://server.domain.ch:8080/orawsv/TEST/TEST_PKG/GET_ROWS"/>
         </port>
      </service>
    </definitions>
    Any hint as how to create and access pl sql web service returning multiple rows?
    I don't use java and don't have access to tools like JDeveloper.
    Thanks!

    The actual issue is that collection types are not supported for return parameters.
    The solution is to wrap the collection into another object.
    Here's a working example based on your settings :
    CREATE OR REPLACE TYPE test_rec is OBJECT ( 
      empno  number(4)
    , ename  varchar2(10)
    , hiredate date
    CREATE OR REPLACE TYPE test_array AS TABLE OF test_rec; 
    CREATE OR REPLACE TYPE test_array_wrapper is OBJECT ( arr test_array );
    CREATE OR REPLACE PACKAGE test_pkg AS 
      function get_rows(p_deptno in number) return test_array_wrapper; 
    END; 
    CREATE OR REPLACE PACKAGE BODY test_pkg AS 
      function get_rows(p_deptno in number) return test_array_wrapper is 
        results  test_array; 
      begin 
        select test_rec(empno, ename, hiredate)
        bulk collect into results
        from scott.emp
        where deptno = p_deptno;    
        return test_array_wrapper(results); 
      end; 
    END; 
    The wsdl is then generated correctly :
    SQL> select httpuritype('http://DEV:dev@localhost:8080/orawsv/DEV/TEST_PKG/GET_ROWS?wsdl').getxml() from dual;
    HTTPURITYPE('HTTP://DEV:DEV@LOCALHOST:8080/ORAWSV/DEV/TEST_PKG/GET_ROWS?WSDL').GETXML()
    <definitions name="GET_ROWS" targetNamespace="http://xmlns.oracle.com/orawsv/DEV/TEST_PKG/GET_ROWS" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://xmlns.oracle.com/orawsv/DEV/TEST_PKG/GET_
    ROWS" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
      <types>
        <xsd:schema targetNamespace="http://xmlns.oracle.com/orawsv/DEV/TEST_PKG/GET_ROWS" elementFormDefault="qualified">
          <xsd:element name="CTEST_ARRAY_WRAPPER-GET_ROWSInput">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="P_DEPTNO-NUMBER-IN" type="xsd:double"/>
              </xsd:sequence>
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="GET_ROWSOutput">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="RETURN" type="tns:TEST_ARRAY_WRAPPERType"/>
              </xsd:sequence>
            </xsd:complexType>
          </xsd:element>
          <xsd:complexType name="TEST_ARRAY_WRAPPERType">
            <xsd:sequence>
              <xsd:element name="TEST_ARRAY_WRAPPER">
                <xsd:complexType>
                  <xsd:sequence>
                    <xsd:element name="ARR">
                      <xsd:complexType>
                        <xsd:sequence>
                          <xsd:element name="TEST_REC" type="tns:TEST_REC_IntType" maxOccurs="unbounded" minOccurs="0"/>
                        </xsd:sequence>
                      </xsd:complexType>
                    </xsd:element>
                  </xsd:sequence>
                </xsd:complexType>
              </xsd:element>
            </xsd:sequence>
          </xsd:complexType>
          <xsd:complexType name="TEST_REC_IntType">
            <xsd:sequence>
              <xsd:element name="EMPNO" type="xsd:double"/>
              <xsd:element name="ENAME">
                <xsd:simpleType>
                  <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="10"/>
                  </xsd:restriction>
                </xsd:simpleType>
              </xsd:element>
              <xsd:element name="HIREDATE" type="xsd:date"/>
            </xsd:sequence>
          </xsd:complexType>
        </xsd:schema>
      </types>
      <message name="GET_ROWSInputMessage">
        <part name="parameters" element="tns:CTEST_ARRAY_WRAPPER-GET_ROWSInput"/>
      </message>
      <message name="GET_ROWSOutputMessage">
        <part name="parameters" element="tns:GET_ROWSOutput"/>
      </message>
      <portType name="GET_ROWSPortType">
        <operation name="GET_ROWS">
          <input message="tns:GET_ROWSInputMessage"/>
          <output message="tns:GET_ROWSOutputMessage"/>
        </operation>
      </portType>
      <binding name="GET_ROWSBinding" type="tns:GET_ROWSPortType">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <operation name="GET_ROWS">
          <soap:operation soapAction="GET_ROWS"/>
          <input>
            <soap:body parts="parameters" use="literal"/>
          </input>
          <output>
            <soap:body parts="parameters" use="literal"/>
          </output>
        </operation>
      </binding>
      <service name="GET_ROWSService">
        <documentation>Oracle Web Service</documentation>
        <port name="GET_ROWSPort" binding="tns:GET_ROWSBinding">
          <soap:address location="http://localhost:8080/orawsv/DEV/TEST_PKG/GET_ROWS"/>
        </port>
      </service>
    </definitions>

  • Ps/sql Table in Forms

    Hi all ..
    I am using Forms 6i ....
    on WHEN-BUTTON-PRESSED Trigger i am calling a procedure ..
    pkg_test.display_proc( Code_ID     IN varchar2,
    keyword IN varchar2,
    v_tab_ret OUT tab_type )
    The procedure is returning a PL/SQL table type .... which consist of 5 fields.....
    Problem :- How can i display this v_tab_ret ( PL/SQL Table) in the Display Item in the form canvas ... This v_tab_ret is supposed to return variable number of rows depending on the conditions in the procedure ...
    Thanks ,

    HI,
    In forms6i, you can define the variable based on the PL/SQL table as you do in the packages.
    In the WHEN-BUTTON-PRESSED trigger, do the following
    DECLARE
    v_tab_ret tab_type
    BEGIN
    -- call your procedure:
    pkg_test.display_proc( Code_ID ,
    keyword,
    v_tab_ret
    -- Now you have the pl/sql table populated from the procedure.
    END;
    Depends on the type of block (single / multi record), you can decide how to manipulate and show the value you got in the PL/SQL tabe.
    Regards,
    Venkat

  • Pl/sql table

    How do i add rows to a pl/sql table and then use the table to open a ref cursor.

    There are several types of PL/SQL tables: Nested Table, Associative Array (pka Index By table) and VARRAY. I am assuming that you refer to the first type. In that case, this is code to declare the Collection and add some values:
    declare
    type num_tbl is table of number;
    l_num_tbl num_tbl;
    l_idx integer;
    begin
    l_num_tbl:= num_tbl(10,20);
    l_num_tbl.extend(5);
    l_num_tbl(l_num_tbl.last):= 30;
    l_num_tbl.extend;
    l_num_tbl(l_num_tbl.last):= 40;
    l_idx:= l_num_tbl.first;
    loop
    dbms_output.put_line(l_num_tbl(l_idx));
    l_idx:= l_num_tbl.next(l_idx);
    exit when l_idx is null;
    end loop;
    l_num_tbl.delete(2,3);
    dbms_output.put_line('Count after Delete:'||l_num_tbl.count);
    end;
    What you mean by your second question: "use the table to open a ref cursor" I am not entirely sure. What you can do is something like this:
    create type num_tbl is table of number
    create or replace
    function get_num_cursor
    return sys_refcursor
    is
    l_num_tbl num_tbl;
    l_idx integer;
    l_refcursor sys_refcursor;
    begin
    l_num_tbl:= num_tbl(10,20);
    l_num_tbl.extend(5);
    l_num_tbl(l_num_tbl.last):= 30;
    l_num_tbl.extend;
    l_num_tbl(l_num_tbl.last):= 40;
    open l_refcursor for select * from table(cast (l_num_tbl as num_tbl));
    return l_refcursor;
    end;
    In SQL*Plus you can then select this ref cursor:
    SQL> select get_num_cursor from d
    2 /
    GET_NUM_CURSOR
    CURSOR STATEMENT : 1
    CURSOR STATEMENT : 1
    COLUMN_VALUE
    10
    20
    30
    40
    8 rows selected.
    I hope this is what you were looking for.
    betst regards
    Lucas

Maybe you are looking for

  • Itunes skipping tracks, Apple ID/password combo suspected

    Installed Itunes Match yesterday as it seemed a good way to have my tracks available everywhere. My library consists of a mix of ripped CD's and tracks bought via the ITunes Store (2007-present), all very legal. The music itself is in a library on a

  • Updating iPOD with a song without using iTunes

    Hi all, I was wondering if it was possible to:- 1) Connect an iPOD to a computer 2) Automatically add a song to the iPOD from the computer 3) Disconnect the iPOD once the song has been added and synced. This system must work with multiple iPODs, henc

  • OBIEE 11.1.1.6.0 insatallation - creating domain configuaration error

    Hi, I am trying to install OBIEE 11.1.1.6.0 on a windows 7 Home basic machine. i have selected 'Enterprise install'. At step 14 -i got error i.e creating domain has failed.In logs i found below message: Please check logs file and give me any suggesti

  • Help with images in Spry menus

    I need help making this work: I want my menu buttons and submenu buttons to be images rather than text. I've been able to set it up to use different images for each of the main and sub-level buttons, but only for the active state. I cannot figure out

  • How to mke deep links into application

    Hallo, i want to provide 2 ways to login to my app. One is to fill out the login jsp and the other ist to give login parameter in the request with an automatic login. I have done this before with struts an an request to an action with request the par