Stored procedure, returning array output

i am new to oracle and stored procedure and i have tried to do this but, still no luck, can anyone help me out?
my stored procedure & package is as follows;
create or replace package prebooking
is
    type tr_contract_data
    is
        record (
                custcode  customer_all.custcode%TYPE        ,
                des       rateplan.des%TYPE                 ,
                dn_num    directory_number.dn_num%TYPE      ,
                cd_sm_num contr_devices.cd_sm_num%TYPE
    type tt_contract_data
    is
        table of tr_contract_data
        index by binary_integer;
    procedure customer_data (
                                pc_custcode             in  customer_all.custcode%TYPE,
                                pc_customer_name        out varchar2                  ,
                                pc_customer_address_1   out varchar2                  ,
                                pc_customer_address_2   out varchar2                  ,
                                pc_user_lastmod         out varchar2
    procedure contract_data (
                                pc_custcode             in  customer_all.custcode%TYPE,
                                pt_contract_data        out tt_contract_data
end prebooking;
drop public synonym prebooking;
create public synonym prebooking for prebooking;
grant execute on prebooking to wpa;
-- EOF: PREBOOKING.plh
create or replace package body prebooking
is
    procedure customer_data (
                                pc_custcode             in  customer_all.custcode%TYPE,
                                pc_customer_name        out varchar2                  ,
                                pc_customer_address_1   out varchar2                  ,
                                pc_customer_address_2   out varchar2                  ,
                                pc_user_lastmod         out varchar2
    is
        cursor c_customer_data ( pc_custcode customer_all.custcode%TYPE )
        is
            select ccline1  || ' ' || ccfname || ' ' || cclname         customer_name,
                   ccstreet || ' ' || ccaddr2 || ' '     || ccaddr3 ||
                               ' ' || cccity  || ' zip ' || cczip   ||
                               ' ' || ccline4                           customer_address_1,
                   ccstate  || ' ' || ccline6                           customer_address_2,
                   b.user_lastmod                                       user_lastmod
            from ccontact_all a,
                 customer_all b
            where b.customer_id = a.customer_id
              and a.ccbill = 'X'
              and b.custcode = pc_custcode;
    begin
        open c_customer_data ( pc_custcode );
        fetch c_customer_data into pc_customer_name     ,
                                   pc_customer_address_1,
                                   pc_customer_address_2,
                                   pc_user_lastmod      ;
        close c_customer_data;
    end customer_data;
    procedure contract_data (
                                pc_custcode             in  customer_all.custcode%TYPE,
                                pt_contract_data        out tt_contract_data
    is
        cursor c_contract_date ( pc_custcode customer_all.custcode%TYPE )
        is
            select h.custcode,
                   g.des,
                   e.dn_num,
                   d.cd_sm_num
            from curr_co_status      a,
                 contract_all        b,
                 contr_services_cap  c,
                 contr_devices       d,
                 directory_number    e,
                 rateplan            g,
                 customer_all        h
            where h.customer_id = b.customer_id
              and b.co_id = a.co_id
              and b.co_id = c.co_id
              and b.co_id = d.co_id
              and c.dn_id = e.dn_id
              and b.tmcode = g.tmcode
              and c.cs_deactiv_date is null
              and h.custcode = pc_custcode;
    begin
        for c in c_contract_date ( pc_custcode )
        loop
            pt_contract_data (nvl (pt_contract_data.last, -1) + 1).custcode  := c.custcode ;
            pt_contract_data (     pt_contract_data.last         ).des       := c.des      ;
            pt_contract_data (     pt_contract_data.last         ).dn_num    := c.dn_num   ;
            pt_contract_data (     pt_contract_data.last         ).cd_sm_num := c.cd_sm_num;
        end loop;
    end contract_data;
end prebooking;
-- EOF: PREBOOKING.plhand i am using the following php code to do this
<?php
  $conn=OCILogon("USER", "USER", "DB");
  if ( ! $conn ) {
     echo "Unable to connect: " . var_dump( OCIError() );
     die();
  $collection_name = 1.1;     
  $stmt = OCIParse($conn,"begin PREBOOKING.CONTRACT_DATA(:INN, :OUTT); end;");
  OCIBindByName($stmt, ":INN", $collection_name, 200);
  //OCIBindByName($stmt, ":", $collection_desc, 100);
  $blobdesc = OCINewDescriptor($conn, OCI_D_LOB);
  OCIBindByName($stmt, ":OUTT", $blobdesc, -1, OCI_B_BLOB);
  $blobdesc->WriteTemporary($binary_junk, OCI_B_BLOB);
  OCIExecute($stmt);
  OCILogoff($conn);
?>the error i get when i run this code is;
Warning: OCI-Lob::writetemporary() [function.writetemporary]: Cannot save a lob that is less than 1 byte in C:\apachefriends\xampp\htdocs\POSP\oci53.php on line 18
Fatal error: Call to undefined function OCIDefineArrayOfStruct() in C:\apachefriends\xampp\htdocs\POSP\oci53.php on line 19

Hi Varun,
To combine the first xml-formatted column to one XML, If you want to do that in SQL server, you can reference the below sample.
CREATE PROC proc1 -- the procedure returning the resultset with 3 columns
AS
DECLARE @XML1 VARCHAR(MAX),
@XML2 VARCHAR(MAX),
@XML3 VARCHAR(MAX);
SET @XML1='<person><name>Eric</name></person>'
SET @XML2='<book><name>war and peace</name></book>'
SET @XML3='<product><name>product1</name></product>'
SELECT @XML1 AS col1,1 AS col2,2 AS col3
UNION ALL
SELECT @XML2,2,3
UNION ALL
SELECT @XML3,2,3
GO
CREATE PROC proc2
AS
DECLARE @TbL TABLE(id INT IDENTITY, col1 VARCHAR(MAX),col2 INT,col3 INT)
INSERT INTO @TbL EXEC proc1
SELECT id as '@row' ,cast(col1 as xml) FROM @TbL FOR XML PATH('XML'),TYPE
GO
EXEC proc2
DROP PROC proc1,proc2
/*output
<XML row="1">
<person>
<name>Eric</name>
</person>
</XML>
<XML row="2">
<book>
<name>war and peace</name>
</book>
</XML>
<XML row="3">
<product>
<name>product1</name>
</product>
</XML>
If you have any question, feel free to let me know.
Eric Zhang
TechNet Community Support

Similar Messages

  • SSRS - Oracle Stored procedure returns no data but does in SQL Developer Sudio

    HI there,
    Stored procedure returns no data when executed on the report but when i execute the stored procedure in Sql Developer it returns required rows.
    Thanks for your help!

    Hi Simon,
    When i test with simple query, i get the data.
    For your convenience, my stored proc looks lyk :
    PROCEDURE pr_REPORT_data(P_STARTDATE IN DATE, P_ENDDATE IN DATE, data_rows OUT T_CURSOR) AS 
    OPEN completed_Reinstatement FOR
      SELECT 
                 value1,.......value5
      FROM table1
    WHERE
        To_Date(createdDate, 'YYYY/MM/DD') BETWEEN To_Date(P_STARTDATE, 'YYY/MM/DD') AND To_Date(P_ENDDATE, 'YYYY/MM/DD');
    END pr_REPORT_data;          
    T_CURSOR is of type cursor which is declared on the package.
    I'm assuming the problem is with date parameters, however i converted the date before passing to
    WHERE clause. 

  • Error in calling Stored procedure returns REFCURSOR

    Hi,
    I've written a oracle stored procedure returning REFCURSOR. say,extractorderdespatchconfirmsp('','','','','','H1','ACG','','','','',:rc).
    Following statement throwing error.
    CallableStatement cs = con.PrepareCall("{extractorderdespatchconfirmsp('','','','','','H1','ACG','','','','',:rc)}");
    rs = cs.executeQuery();
    Could you rectify this problem and give me the currect code.
    riyaz

    Your naming convention leaves a little to be desired.
    String command = "{CALL extractorderdespatchconfirmsp(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}";
    CallableStatement cstmt = conn.prepareCall(command);
    //set the variables here ie, dates need to be a timestamp format. use set timestamp.
    cstmt.setInt(1, 2);
    cstmt.setString(2, "a string");
    cstmt.setInt(3, 0);
    //for return values
    cstmt.registerOutParameter(3, Types.INTEGER);
    cstmt.registerOutParameter(2, Types.INTEGER);
    cstmt.execute();
    int status = cstmt.getInt(3);
    int status2 = cstmt.getInt(2);
    cstmt.close();
    It took me awhile too to get JDBC to call these right.

  • Problem calling Stored Procedure returning SETOF UDT (Using Spring)

    I am using Spring's StoredProcedure class to call a stored procedure from a PostgreSql database. It returns a set of user defined data types. I'm having a problem in parsing the results returned.
    The user defined data type :
    CREATE TYPE process_states AS (
    process_name text,
    process_type text
    The stored procedure returns a SET of "process_state" :
    CREATE FUNTION inquire_process_state (.....)
    RETURNS SETOF process_state AS '
    SELECT ....
    I hava a Java class extending the Spring StoredProcedure classs.
    public MyProcStats extends StoredProcedure {
    private class ProcStateCallBackHandler implements RowCallBackHandler {
    public void processRow(ResultSet rs) throws SQLException {
    System.out.println(rs.getString(1));
    public MyProcStats (DataSource ds) {
    super(ds, "inquire_process_state");
    super.setFunction(true);
    declareParameter(new SqlOutparameter("rs", Types.OTHER, new ProcStateCallBackHandler());
    declareParameter(new SqlParameter("family_name", Types.VARCHAR) ;
    While testing this class, I get an errormessage
    "java.sql.SQLException:ERROR: cannot display a value of type record"
    I would appreciate if anyone can point out my mistakes. I tried declaring
    new SqlOutParameter("rs", Types.OTHER, "process_state"), but that didn't help.

    As the related posts suggest, you will need to use direct JDBC code for this.
    Also I'm not sure JDBC supports the RECORD type, so you may need to wrap your stored functions with ones that either flatten the record out, or take OBJECT types.

  • Error saving map. Stored procedure returned non-zero result BizTalk Bug

    Hallo all
    MSDN is reporting this Bug.
    "Error saving map. Stored procedure returned non-zero result." error message when you deploy the BizTalk Server 2010 applications in BizTalk Server 2010 Administration Console"
    http://support.microsoft.com/kb/2673264/en-us
    I am having this problem in BizTalk 2013. Is this correct? or I am doing something wrong..
    This error occured as I was about to deploy BizTalk application from Visual studio 2012 to BizTalk 2013.
    If this bug is available in 2013, where can I get a fix for it..
    Thanks in Advance
    AKE

    Hi AKE,
    Fix for this bug in BizTalk Server 2013 is not publicly available yet. Only option to get the fix for this bug is to contact:
    http://support.microsoft.com/contactus/?ws=support
    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful.

  • Error saving map. Stored procedure returned non-zero result. Check if source and target schemas are present.

    I am using VS 2012 and BizTalk 2013 and attempting to deploy an application to BizTalk when I get these errors:
    Error 47
    at Microsoft.BizTalk.Deployment.Assembly.BtsMap.Save()
       at Microsoft.BizTalk.Deployment.Assembly.BtsArtifactCollection.Save()
       at Microsoft.BizTalk.Deployment.Assembly.BtsAssembly.Save(String applicationName)
       at Microsoft.BizTalk.Deployment.BizTalkAssembly.PrivateDeploy(String server, String database, String assemblyPathname, String applicationName)
       at Microsoft.BizTalk.Deployment.BizTalkAssembly.Deploy(Boolean redeploy, String server, String database, String assemblyPathname, String group, String applicationName, ApplicationLog log)
    0 0
    Error 49
    Failed to add resource(s). Change requests failed for some resources. BizTalkAssemblyResourceManager failed to complete end type change request. Failed to deploy map "XXX.BTS2013.XXX.Maps.map_XXXX_R01_InsLabProc".
    Error saving map. Stored procedure returned non-zero result. Check if source and target schemas are present. Error saving map. Stored procedure returned non-zero result. Check if source and target schemas are present.
    0 0
    Error 46
    Failed to deploy map "XXX.BTS2013.XXX.Maps.map_XXXX_R01_InsLabProc".
    Error saving map. Stored procedure returned non-zero result. Check if source and target schemas are present.
    0 0
    I also tried to Import a MSI file from our test environment to see if that would work...got the same errors.  After spending hours (not kidding) looking for an answer, all I could find is that a hotfix would work.  So, I got the hotfix from Microsoft
    Support and applied it then rebooted.  Still getting the same errors.  I'm absolutely at a stand still.  Interesting that I got this application to deploy yesterday and then the next time I deployed it I started getting these errors.  I'm
    ready to pull my hair out!
    Is there an answer for this out there somewhere?  Any help would be appreciated.
    Thanks,
    Dave

    Hi Dave,
    Which hotfix have you applied? I don't think a hotfix of this issue is available for BizTalk 2013 yet. You should create a
    support ticket with Microsoft to get a solution.
    If this answers your question please mark as answer. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

  • If the result from the stored procedure returns 0 rows I get this error returned:

    If the result from the following stored procedure returns 0
    rows I get this error returned:
    faultCode:Server.Processing faultString:'Variable transfers
    is undefined.' faultDetail:''
    How can I get round this?

    Well if I try this in a cfm page:
    <cfstoredproc procedure="GetTransfers"
    datasource="datasource" returncode="true">
    <cfprocparam type="in" cfsqltype="CF_SQL_VARCHAR"
    value="4">
    <cfprocparam type="in" cfsqltype="cf_sql_date"
    value="12/09/2006 08:42:00">
    <cfprocparam type="in" cfsqltype="cf_sql_date"
    value="12/09/2008 08:42:00">
    <cfprocresult name="transfers">
    I get an error like:
    [Macromedia][SQLServer JDBC Driver][SQLServer]Procedure or
    function 'GetTransfers' expects parameter '@fromdate', which was
    not supplied.
    But this procedure only accepts 3 parameters.

  • Stored Procedure returning 5GB data in sinle out parameter.

    Hi,
    A stored procedure takes data from the tables of database. Stored Procedure have one output parameter which should out put 5gb data (Prefer in 100k chunks if possible).
    PROBLEM IS "A stored procedure local variable can not keep Data>34k".
    If out put data size in output parameter < 34k every thing works properly. But when data in output param increases 34k. Oracle raise error.
    Define SOLUTION.
    I'm using OLEDB to call stored procedures. Is it possible to have 5GB data out from stored procedure in output parameter.
    Looking forward for Help,
    SE YA
    [email protected]
    [email protected]

    My stored procedure is ...
    *****************Create Table**************************
    Create Table SBG100 ( DESIGN1 NUMBER(10), DESIGN2 NUMBER(10), DESIGN3 NUMBER(30), DESIGNSOA NUMBER(10), DESIGN4 NUMBER(10) );
    INSERT INTO SBG100 values ( 124, 123, 123, 123, 123);
    *****************Create Stored Procedure ***************
    CREATE OR REPLACE PROCEDURE NODE1001(varOutPut OUT LONG) AS
    CURSOR CUR IS
    Select NODE1001.rowid NODE1001 FROM DBDIRECT.SBG100 NODE1001;
    N001DESIGN1 NUMBER(10); N001DESIGN2 NUMBER(10); N001DESIGN3 NUMBER(30);
    N001DESIGNSOA NUMBER(10); N001DESIGN4 NUMBER(10); tempnum NUMBER := 0;
    VarOutPutN2 LONG; VarTemp LONG; i number(10):= 0; ntotal_Rows NUMBER(10) := 0;
    BEGIN
         Select count(1) into ntotal_Rows from DBDIRECT.SBG100;
    FOR REC IN CUR LOOP
    Select NODE1001.DESIGN1, NODE1001.DESIGN2, NODE1001.DESIGN3, NODE1001.DESIGNSOA
    into N001DESIGN1, N001DESIGN2, N001DESIGN3, N001DESIGNSOA
    from DBDIRECT.SBG100 NODE1001 Where NODE1001.ROWID = REC.NODE1001 ;
         varTemp := rpad(2||chr(0),4,' ') || rpad(1||chr(0),4,' ') || rpad(N001DESIGN1||chr(0),8, ' ') || rpad(N001DESIGN2||chr(0),8,' ')
    || rpad(N001DESIGN3||chr(0), 8,' ') || rpad(N001DESIGNSOA||chr(0), 8,' ');
    -- NODE1002(VarOutPutN2, ntotal_Rows - i);
         varOutPut := varOutPut || varTemp || varOutPutN2;
         i := i + 1;
    END LOOP;
    END;
    TO execute above stored procedure n see output data Call this stored procedure.
    *************To Execute above Stored Procedure********
    CREATE OR REPLACE PROCEDURE NMAIN AS
    VAROUTPUT LONG;
    BEGIN
    --dbms_output.enable(50000);
    node1001(varoutput);
    dbms_output.put_line(substr(varoutput,250));
    end;
    *************How to execute all :)******************
    only type exec nmain on SQL prompt. You'll see result.

  • With JDBC, calling a stored procedure with ARRAY as out parameter

    Hi,
    I want to use the data type ARRAY as an out parameter in an Oracle stored procedure. I want to call the stored procedure from
    my java program using JDBC.
    The problem it's i use a 8.1.7 client to acces with oci to a 7.1.3 Database.
    With this configuration I can get back a Cursor but not an Array.
    Does it's possible ?
    Thanks for your help !
    Michakl

    Originally posted by JDBC Development Team:
    It's very similar to other datatype except that it uses OracleTypes.ARRAY typecode and the value is mapped to a oracle.sql.ARRAY instance. The code looks as follows --
    cstmt.registerOutParameter (idx, OracleTypes.ARRAY, "VARRAY_TYPE_NAME_HERE");
    cstmt.execute ();
    ARRAY array = (ARRAY) cstmt.getObject (idx);
    Thanks for your reply.
    I have to use:-
    OracleCallableStatement cs1 = (OracleCallableStatement )conn.prepareCall
    ( "{call proj_array(?)}" ) ;
    for retrieving a collection as an OUT parameter.
    This gives me the errors:-
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Blob getBlob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Array getArray(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Clob getClob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Ref getRef(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    How do I get rid of these errors?
    null

  • Execute SQL Task, OLE DB, Stored Procedure, Returns unexpected value upon second run

    when debugging SSIS, the "Execute SQL Task" runs a stored procedure and returns the expected value. When running the package a second time, the task returns an unexpected value. When running in VS2012 SQL editor, everything operates as expected.
    Please help me debug how to get the stored proc to return the same value every time the SSIS Package is run. thanks!
    Here is the sequence of events and what happens....
    Look for a Positor that matches the Application, Host, and User
    No matching PositorId is found, Creates new Positor row, returns that new PositorId
    Use PositorId to upload some data (Every thing works)
    re-run/debug the ssis pacakge
    Look for a Positor that matches the Application, Host, and User 
    <No clue what is happening>
    Returns -1 (SHOULD BE the same PositorId value returned in #2)
    "Execute SQL Task" Setup: No edits to Result Set nor Expressions
    "Execute SQL Task" Setup: GENERAL
    "Execute SQL Task" Setup: PARAMETER MAPPING
    SP called by "Execute SQL Task"
    CREATE PROCEDURE [posit].[Return_PositorId]
    AS
    BEGIN
    DECLARE @PositorId INT = [posit].[Get_PositorId]();
    IF (@PositorId IS NULL)
    BEGIN
    DECLARE @ProcedureDesc NVARCHAR(257) = OBJECT_SCHEMA_NAME(@@PROCID) + N'.' + OBJECT_NAME(@@PROCID);
    DECLARE @PositorNote NVARCHAR(348) = N'Automatically created by: ' + @ProcedureDesc;
    EXECUTE @PositorId = [posit].[Insert_Positor] @PositorNote;
    END;
    RETURN @PositorId;
    END;
    Supporting SQL Objects:
    CREATE FUNCTION [posit].[Get_PositorId]
    RETURNS INT
    AS
    BEGIN
    DECLARE @PositorId INT = NULL;
    SELECT TOP 1
    @PositorId = [p].[PO_PositorId]
    FROM [posit].[PO_Positor] [p]
    WHERE [p].[PO_PositorApp] = APP_NAME()
    AND [p].[PO_PositorHost] = HOST_NAME()
    AND [p].[PO_PositorUID] = SUSER_ID();
    RETURN @PositorId;
    END;
    GO
    CREATE PROCEDURE [posit].[Insert_Positor]
    @PositorNote NVARCHAR(348) = NULL
    AS
    BEGIN
    DECLARE @ProcedureDesc NVARCHAR(257) = OBJECT_SCHEMA_NAME(@@PROCID) + N'.' + OBJECT_NAME(@@PROCID);
    SET @PositorNote = COALESCE(@PositorNote, N'Automatically created by: ' + @ProcedureDesc);
    DECLARE @Id TABLE
    [Id] INT NOT NULL
    INSERT INTO [posit].[PO_Positor]([PO_PositorNote])
    OUTPUT [INSERTED].[PO_PositorId]
    INTO @Id([Id])
    VALUES(@PositorNote);
    RETURN (SELECT TOP 1 [Id] FROM @Id);
    END;
    GO
    CREATE TABLE [posit].[PO_Positor]
    [PO_PositorId] INT NOT NULL IDENTITY(0, 1),
    [PO_PositorApp] NVARCHAR(128) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorApp] DEFAULT(APP_NAME()),
    CONSTRAINT [CL__PO_Positor_PO_PositorApp] CHECK([PO_PositorApp] <> ''),
    [PO_PositorName] NVARCHAR(256) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorName] DEFAULT(SUSER_SNAME()),
    CONSTRAINT [CL__PO_Positor_PO_PositorName] CHECK([PO_PositorName] <> ''),
    [PO_PositorHost] NVARCHAR(128) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorHost] DEFAULT(HOST_NAME()),
    CONSTRAINT [CL__PO_Positor_PO_PositorHost] CHECK([PO_PositorHost] <> ''),
    [PO_PositorSID] VARBINARY(85) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorSID] DEFAULT(SUSER_SID()),
    [PO_PositorUID] INT NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorUID] DEFAULT(SUSER_ID()),
    [PO_PositorNote] VARCHAR(348) NULL CONSTRAINT [CL__PO_Positor_PO_PositorNote] CHECK([PO_PositorNote] <> ''),
    [PO_tsInserted] DATETIMEOFFSET(7) NOT NULL CONSTRAINT [DF__PO_Positor_PO_tsInserted] DEFAULT(SYSDATETIMEOFFSET()),
    [PO_RowGuid] UNIQUEIDENTIFIER NOT NULL CONSTRAINT [DF__PO_Positor_PO_RowGuid] DEFAULT(NEWSEQUENTIALID()) ROWGUIDCOL,
    CONSTRAINT [UX__PO_Positor_PO_RowGuid] UNIQUE NONCLUSTERED([PO_RowGuid]),
    CONSTRAINT [UK__Positor] UNIQUE CLUSTERED ([PO_PositorApp] ASC, [PO_PositorHost] ASC, [PO_PositorUID] ASC),
    CONSTRAINT [PK__Positor] PRIMARY KEY ([PO_PositorId] ASC)
    GO
    ssd

    The error is in item 7: Returns -1 (SHOULD BE the same PositorId value returned in #2); but no error message is returned or thrown from SSIS.
    The error message indicated referential integrity is not upheld when inserting records. This error message occurs AFTER the Execute SQL Task successfully completes; the E.SQL Task returns -1.  The executed SQL code will not allow values less than 0
    ([PO_PositorId] INT NOT NULL IDENTITY(0, 1),)
    [Platts Valid [41]] Error: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80040E2F.
    An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 11.0"  Hresult: 0x80040E2F  Description: "The statement has been terminated.".
    An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 11.0"  Hresult: 0x80040E2F  Description:
    "The INSERT statement conflicted with the FOREIGN KEY constraint "FK__PricingPlatts_Posit_PositorId". The conflict occurred in database "Pricing", table "posit.PO_Positor", column 'PO_PositorId'.".
    The aforementioned FOREIGN KEY constraint is due to the value being returned by the Execute SQL Task.; therefore, the error lies in the value returned by the Execute SQL Task.

  • Java stored proc: returning array?

    Hi,
    I have had to implement a Java stored procedure that accepts a nested table as an argument from aPL/SQL package. The class must manipulate the data and then create an object or an array that can be returned to the package for subsequent interpretation and use.
    I'd assuemd that I could reverse the process when the argument was accepted; i.e. assemble the data as an oracle.sql.ARRAY type and return that. The Javadoc I have advises that the constructors for this class are for 'internal' use only. Also, it requires a connection and I don'treally want to have to open another connection to the schema.
    Another alternative was to return an array of BigDecimal but this would require an equivalent VARRAY on the PL/SQL side. As I don't know the side of the array until run-time I cannot safely declare a VARRAY of an arbitrary size.
    As you acn probalby tell, I'm a bit of a novice so any help would be greatly appreciated.
    Thanks

    Thanks for the reply Avi.
    That's fine: it's a valid question! I started to explain the original problem but it became too long. Basically I needed the ability to define an array that could be dynamically sized depending on the rowcount resulting from a BULK COLLECT during runtime. As admitted, I'm a novice and believed this couldn't be done in PL/SQL, and, to cut a very long-winded story short after seeking more experienced advice, used the dynamic allocation techniques in Java which is more familiar terriory to me.
    I nearly have the Java solution working, thanks to Oracle documentation and a couple of hints towards the end of this thread. I'd also been perusing those links you recommended.
    I have since realised I can simulate a dynamic array with a nested table and using EXTEND. If thre are other techniques available, I'd be grateful or some pointers! All in all the whole process has been beneficial if a little time consuming.
    Thanks again
    The original problem is as follows: I have a nested table, each row of which contains one column for each month of the year recording payments. Some of these months can contain 0 and therefore, a 5,000 foot view shows that result set is fragmented. Basically the payments have to be rearranged as though they were contiguous monthly payments prior to subsequent processing. Because of the way the rows needed to be grouped for processing, the algorithms for defragmentation were becoming really complex. Admitting my PL/SQL limitations I slunk off to ask further advice and

  • XI/PI: jdbc receiver using stored procedure with arrays

    The company needs an interface to search for header data and detail to a legacy system.
    This interface from ERP  to legacy system is synchronous and uses stored procedure.
    The definition of the stored procedure is as follows:
    PROCEDURE
    Generar_Detalle_Vtas_Pagadas
        (p_cvendedor                 IN bdc_vendedores.cvendedor%TYPE,
        p_fdesde                   IN DATE,
        p_fhasta                     IN DATE,
        v_encabezado_ct           OUT encabezado_ct,
        v_detalle_vtas_pagadas_ct OUT detalle_vtas_pagadas_ct,
        err_num                 OUT NUMBER
    Data types used in stored procedure:
    TYPE encabezado_ct AS OBJECT
    ( CREGION         NUMBER(22),
      XREGION         VARCHAR2(50),
      CMERCADO        NUMBER(22),
      XMERCADO        VARCHAR2(50),
      CTVENDEDOR      VARCHAR2(5),
      XCTVENDEDOR     VARCHAR2(50),
      XDENOMINACION   VARCHAR2(15))
    TYPE detalle_vtas_pagadas_ct AS OBJECT
    (     CITEM           VARCHAR2(10),
          XIDENTIFICADOR  VARCHAR2(15),
          XCONTRATO       VARCHAR2(15),
          XVALOR          VARCHAR2(30),
          CCUENTA         VARCHAR2(15),
          FACTIVACION     DATE,
          XDOMINIO        VARCHAR2(30),
          CCED            VARCHAR2(20),
          XCLIENTE        VARCHAR2(161),
          CCPO            VARCHAR2(60) )
    As shown, this has three input parameters varchar and date respectively and has three output parameters, two of which are defined with a data
    type such as table and the other number.
    The problem is to define the signature of the stored procedure in XI when defining the data type request, the message type and mapping system
    legacy because the data type is not supported (tables: detalle_vtas_pagadas_ct,encabezado_ct  )

    FORM 2:
    defined as an array, but the error tells me that we need to define the attribute either input or output
    <?xml version="1.0" encoding="UTF-8"?>
         <ns0:MT_VtasPagadas_VYC xmlns:ns0="urn:VentasPagadas:VE_ALTASDEDCALIDAD_SD_VYC">
          <VtasPagadasRequest><Generar_Detalle_Vtas_Pagadas action="EXECUTE">
             <table>vyc.Vyc_Pack_Reportes_Sap.Generar_Detalle_Vtas_Pagadas</table>
             <p_cvendedor type="VARCHAR"></p_cvendedor>
             <p_fdesde type="DATE"></p_fdesde>
             <p_fhasta type="DATE"></p_fhasta>
             <v_encabezado_ct>
                 <CREGION isOutput="1" type="NUMERIC">X</CREGION>
                 <XREGION isOutput="1" type="VARCHAR">X</XREGION>
                 <CMERCADO isOutput="1" type="NUMERIC">X</CMERCADO>
                 <XMERCADO isOutput="1" type="VARCHAR">X</XMERCADO>
                 <CTVENDEDOR isOutput="1" type="VARCHAR">X</CTVENDEDOR>
                 <XCTVENDEDOR isOutput="1" type="VARCHAR">X</XCTVENDEDOR>
                 <XDENOMINACION isOutput="1" type="VARCHAR">X</XDENOMINACION>
            </v_encabezado_ct>
            <v_detalle_vtas_pagadas_ct>
                 <CITEM isOutput="1" type="VARCHAR">X</CITEM>
                 <XIDENTIFICADOR isOutput="1" type="VARCHAR">X</XIDENTIFICADOR>
                 <XCONTRATO isOutput="1" type="VARCHAR">X</XCONTRATO>
                 <XVALOR type="VARCHAR">X</XVALOR>
                 <CCUENTA isOutput="1" type="VARCHAR">X</CCUENTA>
                 <FACTIVACION isOutput="1" type="DATE">X</FACTIVACION>
                 <ICTA isOutput="1" type="VARCHAR">X</ICTA>
                 <CCED isOutput="1" type="VARCHAR">X</CCED>
                 <XCLIENTE isOutput="1" type="VARCHAR">X</XCLIENTE>
                 <CCPO isOutput="1" type="VARCHAR">X</CCPO>
            </v_detalle_vtas_pagadas_ct>
            <err_num isOutput="1" type="NUMERIC">X</err_num>
         </Generar_Detalle_Vtas_Pagadas>
      </VtasPagadasRequest></ns0:MT_VtasPagadas_VYC>
    Edited by: ymonasterio on Mar 31, 2010 4:48 PM

  • Stored Procedure with Input & output parameter as XML

    Hi
    I have a requirement wherein i need to have a stored procedure with accepts huge XML from Java and the SP has to process all the records in the XML and return XML output with some messages in it.
    Currenty, I have a stored procedure to process the xml stored in Oracle Database.
    I am using the following SQL statement to read the data from the XML column.
    select xmltest1.id,xmltest1.name
      from xmltest,
           XMLTABLE(
              XMLNamespaces(default 'syncpsna/schemas'),
              '/XMLTestRequest/insert/row'
                    PASSING xmltest.data_xml
                    COLUMNS
                    "ID" number(10) PATH 'id',
                    "NAME" varchar2(50) PATH 'name') xmltest1
    where xmltest.id = 2;I want to execute similary queries to fetch data from the XML Passed as an input parameter from JAVA.
    if i could get some examples of reading the XML and sending the xml back to the calling program.
    Regards

    Hi,
    if i could get some examples of reading the XML and sending the xml back to the calling program.What kind of process do you want to perform on the input XML?
    You said "reading", but for what purpose? Storing data in the database, or just transform the XML into another form?
    Anyway, you'll probably need a function, something like :
    create or replace function processXML (inputXML in xmltype)
    return xmltype
    is
      outputXML xmltype;
    begin
    -- process inputXML here, and construct outputXML
    return outputXML;
    end;Back in Java, you can use the oracle.xdb.XMLType class to map the XMLType SQL datatype to a Java object and manipulate it.

  • PLS-00306:NET to call Oracle stored procedure,Use Array parameters

    Development Environment:Windows 2003 SP2+Oracle 10g
    . NET to call Oracle stored procedure, use an array of types of parameters
    Step1:(In the Oracle database define an array of types)
    CREATE OR REPLACE TYPE STRING_VARRAY AS VARRAY (1000) OF NVARCHAR2(255)
    OR
    CREATE OR REPLACE type string_array is table of nvarchar2(255)
    Step2:
    CREATE OR REPLACE PROCEDURE Test
    (i_test in string_varray,o_result out int)
    IS
    BEGIN
    o_result:=i_test.count;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    NULL;
    WHEN OTHERS
    THEN
    o_result:=0;
    END arraytest;
    Step3:
    ODP.NET(Oracle 10g)
    OracleConnection conn = new OracleConnection("User Id=test;Password=test;Data Source=test");
    OracleCommand cmd = new OracleCommand("Test", conn);
    cmd.CommandType = CommandType.StoredProcedure;
    string[] str = new string[2] { "11", "222" };
    cmd.ArrayBindCount=2;
    OracleParameter p1 = new OracleParameter("i_test", OracleDbType.NVarChar);
    p1.Direction = ParameterDirection.Input;
    p1.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
    p1.Value = str;
    p1.ArrayBindSize=new int[2]{2,3};
    p1.ArrayBindStatus = new OracleParameterStatus[2]{
    OracleParameterStatus.Success,
    OracleParameterStatus.Success
    cmd.Parameters.Add(p1);
    OracleParameter p2 = new OracleParameter("o_result", OracleDbType.Int32);
    p2.Direction = ParameterDirection.Output;
    P2.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
    p2.Value=0;
    cmd.Parameters.Add(p2);
    int i = 0;
    try
    conn.Open();
    cmd.ExecuteNonQuery();
    i =(int) p2.Value;
    catch (Exception ex)
    finally
    conn.Close();
    Error:
    Execution Failed:ORA-06550:Line 1,Column 7:
    PLS-00306:Test parameters when calling the number or types of errors
    ORA-06550:Line 1,Column 7:
    PL/SQL:Statement ignored

    Hi,
    See the answer in [this thread|http://forums.oracle.com/forums/thread.jspa?threadID=909564&tstart=0]
    Hope it helps,
    Greg

  • Stored procedure returning multiple records without using SYS_REFCURSOR

    Hello,
    I am new to oracle stored procedures, have done stored procs in SQL server in past. I am trying to write single stored proc which will return multiple records. I have the stored proc as below and that is compiled without any errors.
    We don't want to use SYS_REFCURSOR as output param b'coz the place from which this proc is gonna call, that system doesn't support SYS_REFCURSOR param.
    create or replace
    PROCEDURE p_get5500DATA_MB (
    IN_plan_ID IN T_5500DATA_QWP.Plan_ID%TYPE,
    IN_plan_ID_col OUT T_5500DATA_QWP.Plan_ID%TYPE,
    p_SEQNUM OUT T_5500DATA_QWP.SEQNUM%TYPE,
    p_HEADER_CD OUT T_5500DATA_QWP.HEADER_CD%TYPE,
    p_VALUE1 OUT T_5500DATA_QWP.VALUE1%TYPE,
    p_VALUE2 OUT T_5500DATA_QWP.VALUE2%TYPE
    ) AS
    BEGIN
    SELECT
    Plan_ID,
    SEQNUM,
    HEADER_CD,
    VALUE1,
    VALUE2
    INTO
    IN_plan_ID_col,
    p_SEQNUM,
    p_HEADER_CD,
    p_VALUE1,
    p_VALUE2
    FROM TRS1DBO.T_5500DATA_QWP
    WHERE Plan_ID = IN_plan_ID
    ORDER BY SeqNum;
    -- EXCEPTION
    -- WHEN OTHERS THEN
    -- RAISE_APPLICATION_ERROR(-210001, 'Error in fetching data from T_5500DATA_QWP....');
    END;
    Error:
    ORA-01422: exact fetch returns more than requested number of rows
    ORA-06512: at "TRS1DBO.P_GET5500DATA_MB", line 10
    ORA-06512: at line 11
    My questions is:
    - What would be the best practice for this type of simple stored procedures?
    - Is there any alternate or is there anything i can fix in above stored proc which return multiple records?
    Thank you,
    Vimal

    Just out of curiosity, what are you using for API or driver that doesn't support a ref cursor? Ref cursors are pretty much the defacto standard for passing multiple records out of an Oracle procedure. Oracle's ODP.NET, OLEDB, ODBC, JDBC, OCI, all support ref cursors. Chances are that if the driver you're using doesn't support something as basic/fundamental as a ref cursor, it's probably also not going to support something else either.
    You'll most likely want to check with the driver/api vendor on their recommended approach.

Maybe you are looking for

  • Old problem with a new twist !

    My Ipod mini is frozen on the do not disconnect screen (not flashing) I accidentally disconnected it without ejecting/stopping the device I have tried to reset it several times using the - toggle hold press menu/play - method and the 5 r's method (ex

  • How to parse xml file

    Hi, I am having an XML file which is having set of repeated tags like <gender> <male> <name>sk</name> <age>19</age> </male> <male> <name>raj</name> <age>20</age> </male> <male> <name>kris</name> <age>18</age> </male> </gender> Like this i am having t

  • Unable to Install Windows 7 using Boot Camp Assistant

    I recently suffered a hard disk failure. After replacing the disk, I have recovered all data with the exception of being unable to install windows 7 on a new boot camp partition.  I am able to create the partition using boot camp assistant, but I am

  • ABAP objects design patterns

    hi all,     can any one send me the Design patterns used for ABAP objects programming in ABAP. eg mvc and sample code which uses the design patterns cheers senthil

  • WebGalileo tree integration with adf components

    Hi all: I have a project using adf faces, and in one page i am trying to use WebGalileo tree component The thing is that i have this page, in the left side is the webgalileo tree, and in the right side are the adf components (inputText, outputText, f