Cursor in stored procedure fails

Hi,
In our application we have a stored procedure which is called with in parameters to generate data into some table. This procedure is being called from another procedure.
This procedure has been used to generate data into the table without any problem since oracle 9i. Last year we have upgraded to oracle 11g after that this procedure is failing intermittently to generate data. When this procedure is executed 50 times it fails atleast once to generate data. If we rerun the procedure for the failed case it generates the data without any change to program code nor any change in underlying data. It doesn't fail if we rerun. Therefore we are unable to simulate the problem.
Procedure has got a very simple code.
proc1 (p1 date,p2 date) is
begin
for c1_rec in c1 (select col1,col2
from x,y where x.......)
loop
end loop;
end;
First we thought for some reason this procedure was not executed at all. But it is not the case. Actually it calls the procedure but the cursor inside the procedure doesn't fetch any records. Also it doesn't report any oracle error.
Appreciate if any one can help me in this.
Thanks & Regards,
Raja

vaidyanathanraja wrote:
4. If there is a logical error, the same procedure should not generate data when it is rerun. Behaviour should be the same at all times.Incorrect. Something like NLS settings for example can make the same code, behave differently. E.g. a date string is passed and implicitly converted to a date. And this will work for most dates from different session using different NLS settings (e.g. yyyy/mm/dd versus yyyy/dd/mm). And these sessions will provide different results using the same parameters calling the same application code.
There are a number of such run-time factors that influences code.
5. Failed means it didn't generate the expected output. Which means that there is a problem with that SQL being executed the way it is, with the parameters used. You need to isolate the problem further.
6. Parameter values are right.Have you proved that by using a test case that runs the very same SQL via a test proc, using the same parameter, via a job? Ran that test case interactively via sqlplus?
You need to pop the hood and isolate the problem.
7. I came across one blog saying different behaviour for REF CURSOR between oracle 10g and 11g and he says it is oracle bug. I don't know whether it is applicable for this case also.Bahumbug. There are many Oracle bugs. As there is in all software. However, you have not provided any evidence of a bug.
Application code is behaving inconsistently. That is the symptom. Oracle system code is not relevant until you can prove that the inconsistency is not in the application code, but lower down the call stack.

Similar Messages

  • Returning SQL cursor from Stored Procedure

    Hi,
    I have a query regarding returning sql cursor from stored procedure to java in oracle 11g.
    I want to query some data ex: my query returns A, B, C. Also, now I want to query some other data ex: D, E, F. Now I want to return this data as an sql cursor as a single row . Example: A,B,C,D,E,F. Is it possible to return/create a cursor in stored procedure?
    assume both query returns equal number of rows.. however both are not related to each other..

    RP wrote:
    Hi,
    I have a query regarding returning sql cursor from stored procedure to java in oracle 11g.
    I want to query some data ex: my query returns A, B, C. Also, now I want to query some other data ex: D, E, F. Now I want to return this data as an sql cursor as a single row . Example: A,B,C,D,E,F. Is it possible to return/create a cursor in stored procedure?
    assume both query returns equal number of rows.. however both are not related to each other..It sounds like what you need is a ref cursor.
    First thing to remember though is that cursors do not hold any data (see: {thread:id=886365})
    In it's simplest form you would be creating a procedure along these lines...
    SQL> create or replace procedure get_data(p_sql in varchar2, p_rc out sys_refcursor) is
      2  begin
      3    open p_rc for p_sql;
      4  end;
      5  /
    Procedure created.
    SQL> var rc refcursor;
    SQL> exec get_data('select empno, ename, deptno from emp', :rc);
    PL/SQL procedure successfully completed.
    SQL> print rc;
         EMPNO ENAME          DEPTNO
          7369 SMITH              20
          7499 ALLEN              30
          7521 WARD               30
          7566 JONES              20
          7654 MARTIN             30
          7698 BLAKE              30
          7782 CLARK              10
          7788 SCOTT              20
          7839 KING               10
          7844 TURNER             30
          7876 ADAMS              20
          7900 JAMES              30
          7902 FORD               20
          7934 MILLER             10
    14 rows selected.
    SQL> exec get_data('select deptno, dname from dept', :rc);
    PL/SQL procedure successfully completed.
    SQL> print rc
        DEPTNO DNAME
            10 ACCOUNTING
            20 RESEARCH
            30 SALES
            40 OPERATIONS
            50 IT SUPPORTWhich takes an SQL statement (as you said that both your queries were unrelated), and returns a ref cursor, and then your Java code would fetch the data using that cursor.
    Now, as for getting your rows to columns and combining two queries that do that... something along these lines...
    SQL> select * from x;
    C
    A
    B
    C
    SQL> select * from y;
    C
    D
    E
    F
    SQL> ed
    Wrote file afiedt.buf
      1  select x.col1, x.col2, x.col3
      2        ,y.col1 as col4
      3        ,y.col2 as col5
      4        ,y.col3 as col6
      5  from (
      6        select max(decode(rn,1,col1)) as col1
      7              ,max(decode(rn,2,col1)) as col2
      8              ,max(decode(rn,3,col1)) as col3
      9        from (select col1, rownum rn from (select * from x order by col1))
    10       ) x
    11  cross join
    12       (
    13        select max(decode(rn,1,col1)) as col1
    14              ,max(decode(rn,2,col1)) as col2
    15              ,max(decode(rn,3,col1)) as col3
    16        from (select col1, rownum rn from (select * from y order by col1))
    17*      ) y
    SQL> /
    C C C C C C
    A B C D E F... will do what you ask. For further information about turning rows to columns read the FAQ: {message:id=9360005}

  • Scrollable Cursor in Stored Procedure

    I am trying to implement a scrollable cursor that exists in a stored procedure. Here is my situation:
    o Oracle 9i (9.2.0.1.0) for both client and server.
    o OCI Interface in purely C++ environment
    o I am able to compile/link program with 9i client library, and successfully fetch data from a stored proc that contains a nonscrollable/forward only/traditional cursor without any problems.
    I have a stored proc that looks like this:
    procedure test(
    testcursor out cv_types.cv_fit_data
    ) as
    begin
    open testcursor
    for select data_id,
    text
    from data;
    end test;
    This is where I run into problems:
    First I allocate an OCIStmt handle and bind it to the proc. Then using the stmt handle that points to the proc, I bind a secondary handle that points to the cursor (testcursor above) by calling OCIBindByPos with type=SQLT_REF (See OCI ref manual on binding ref cursor). Next, I execute the proc via OCIStmtExecute with the mode=OCI_STMT_SCROLLABLE_READONLY using the statement handle that points to the procedure. Then I use that secondary stmt handle to fetch the rows via OCIStmtFetch2(). I am able to fetch the rows if I stick to OCI_FETCH_NEXT, but when I attempt to use any scrollable features such as OCI_FETCH_ABSOLUTE, it bails with an ORA-24391 error. Upon further investigation, I found out that this error occurs when the stmt is not executed with mode=OCI_STMT_SCROLLABLE_READONLY. The clincher is that I did execute in that mode... Has anyone been faced with a similar situation? Am I tackling this the wrong way? Any help, even pointers to any docs I missed on the subject, is greatly appreciated.
    Thanks,
    Bryan
    I am using OCI in C++ to fetch the data via OCIStmtFetch2(...) method.

    vaidyanathanraja wrote:
    4. If there is a logical error, the same procedure should not generate data when it is rerun. Behaviour should be the same at all times.Incorrect. Something like NLS settings for example can make the same code, behave differently. E.g. a date string is passed and implicitly converted to a date. And this will work for most dates from different session using different NLS settings (e.g. yyyy/mm/dd versus yyyy/dd/mm). And these sessions will provide different results using the same parameters calling the same application code.
    There are a number of such run-time factors that influences code.
    5. Failed means it didn't generate the expected output. Which means that there is a problem with that SQL being executed the way it is, with the parameters used. You need to isolate the problem further.
    6. Parameter values are right.Have you proved that by using a test case that runs the very same SQL via a test proc, using the same parameter, via a job? Ran that test case interactively via sqlplus?
    You need to pop the hood and isolate the problem.
    7. I came across one blog saying different behaviour for REF CURSOR between oracle 10g and 11g and he says it is oracle bug. I don't know whether it is applicable for this case also.Bahumbug. There are many Oracle bugs. As there is in all software. However, you have not provided any evidence of a bug.
    Application code is behaving inconsistently. That is the symptom. Oracle system code is not relevant until you can prove that the inconsistency is not in the application code, but lower down the call stack.

  • OCI8: returning cursors from stored procedures

    The short version of my question is:
    In OCI8, how do open a cursor from the database stored procedure, return it to my C++ program and fetch from it, given that in OCI8 cursors and cursor functions are becoming obsoleted?
    The long version of the same question is:
    I am converting my C++ code from the Oracle 7.3 OCI driver to the Oracle8 OCI driver. One thing I did very frequently in Oracle 7.3 OCI code is open a multi-row select cursor within a stored procedure and return that cursor to my program. In the program, I would then do the fetching with the returned cursor. This was very useful, as it allows me to change the queries in the stored procedure (for example, to append information to certain columns or make some data in all uppercase) without recompiling the application due to a changed SQL string.
    My 7.3 psuedocode is as follows:
    stored procedure def:
    TYPE refCurTyp IS REF CURSOR;
    FUNCTION LoadEmployeeData RETURN refCurTyp;
    stored procedure body:
    FUNCTION LoadEmployeeData RETURN refCurTyp IS
    aCur refCurTyp;
    BEGIN
    OPEN aCur FOR
    SELECT emp_id, emp_name
    FROM employee_table
    ORDER BY emp_name;
    return aCur;
    END;
    OCI code: // all functions are simplified, not actual parameter listing
    // declare main cursor variable #1 and return cursor variable #2
    Cda_Def m_CDAstmt, m_CDAfunction;
    // open both cursors
    oopen(m_CDAstmt, ...);
    oopen(m_CDAfunction, ...);
    // bind cursor variable to cursor #2
    oparse(&m_CDAstmt, "BEGIN :CUR := MYPACKAGE.LoadEmployeeData; END;");
    obindps(&m_CDAstmt, SQLT_CUR, ":CUR", &m_CDAfunction);
    // run cursor #1
    oexn(&m_CDAstmt);
    // bind variables from cursor #2, and fetch
    odefineps(&m_CDAfunction, 1, SQLT_INT, &m_iEmpId);
    odefineps(&m_CDAfunction, 2, SQLT_CHAR, &m_pEmpName);
    while (!ofen(&m_CDAfunction))
    // loop: do something with fetch
    // values placed in m_iEmpID and m_pEmpName
    This works perfectly, and has really helped to make my code more maintainable. Problem is, in Oracle 8 OCI both cursors and the cursor functions (such as oopen()) are becoming obsoleted. Now it uses statement and environment handles. I know I can still use Cda_Def and cursors--for a while--within OCI8, but I need to know the official up-to-date method of returning a cursor from the database and fetching within my C++ code. Any code fragment, or explanation of what I need to do in OCI8 would be appreciated (perhaps I need to bind to a statement handle instead? But the stored procedure still returns a cursor.)
    The Oracle8 OCI has a new SQLT_ type, SQLT_RSET, which the header file defines as "result set type". Unfortunately, it's almost completely undocumented in the official documentation. Am I supposed to use this instead of the obsolete SQLT_CUR?
    Thanks,
    Glen Mazza

    Email me diorectly and I will get you some code that might help. I fail to see the relevance of posting this type of information in the JDeveloper forum.

  • Calling Java Stored Procedure failed SQLXML

    I tried to upload a simple class to Oracle in which I want to use java.sql.SQLXML class using:
    loadjava -u user/passwd@host:1521:xyz -v -resolve C:\develop\workspaces\Test\src\lbb\apc\test\JavaStoredProcedureTest.java
    loadjava answers with:
    creating : source lbb/apc/test/JavaStoredProcedureTest
    loading  : source lbb/apc/test/JavaStoredProcedureTest
    resolving: source lbb/apc/test/JavaStoredProcedureTest
    errors   : source lbb/apc/test/JavaStoredProcedureTest
        ORA-29535: Quelle erfordert Neukompilierung
        lbb/apc/test/JavaStoredProcedureTest:6: cannot find symbol
        symbol  : class SQLXML
        location: package java.sql
        import java.sql.SQLXML;Then I found that the Oracle JDBC driver does not support the SQLXML type, thus changing my program to use XMLType:
    XMLType sqlXml = (XMLType)rs.getSQLXML(1);but it doesn't help as well as it doesn't help to use
    Clob clob = rs.getClob(1);Finally I tried (and failed) to use
    Object obj = rs.getObject(1);
    results in:
    java.sql.SQLException: ORA-29532:Java call terminated by uncaught Java exception:What can I do to solve this problem?

    I wrote it for an example. sorry i should be clear.
    Here is the code i am running check WORKING & NOT WORKING lines. What am i missing
    PL SQL package
    CREATE OR REPLACE PACKAGE BODY APPS.hypr_Reference_designator as
    function hypr_xsl ( dbInstance IN VARCHAR2, Parent_ItemNum IN VARCHAR2)
    return varchar2
    as language java name 'hypr_ref_designator_xsl.hypr_xsl(java.lang.String,java.lang.String) return java.lang.String';
    procedure hypr_xsl(dbInstance IN VARCHAR2, Parent_ItemNum IN VARCHAR2)
       is
       itemNum VARCHAR2(30);
       db Varchar2(30);
       print_string varchar2(200);
       begin
          db:=dbInstance;
            itemNum:=Parent_ItemNum;
          print_string := hypr_xsl(db,itemNum);  --NOT WORKING
                print_string := hypr_xsl('DEV','123'); --WORKING
          commit;
          DBMS_OUTPUT.PUT_LINE(print_string || db || itemNum);
       end hypr_xsl;
    END hypr_Reference_designator;Java Stored Procedure
    CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED APPS.HYPR_REF_DESIGNATOR_XSL as import java.io.File;
    import java.io.FileOutputStream;
    import java.io.InputStream;
    import jxl.*;
    import oracle.jdbc.driver.*;
    import java.sql.*;
    import java.util.Properties;
    public class hypr_ref_designator_xsl {
        public hypr_ref_designator_xsl() {
        public static void main(String[] args) {
    public static String hypr_xsl(String  dbinstance, String parent_itemNum) {
    System.out.print(dbinstance);
    System.out.print(parent_itemNum);
    return "";
    //does some process here
    }

  • Cursor in stored procedure

    Hi,
    1. I am using a cursor XYZ to store some data into a variable @abc and then using this variable as one of the conditions in filling a #TEMP_TABLE in my STORE_PROC procedure. The #TEMP_TABLE does not get populated.
    It works fine when I create a temp table and run the same query outside of the stored procedure.
    Here is a sample:
    DECLARE CURSOR XYZ FOR
    SELECT DISTINCT column-name
    FROM database name..Table Name
    WHERE condition
    OPEN XYZ
    FETCH XYZ INTO @abc
    IF (@@sqlstatus = 2)
    BEGIN
    ........returns an error code
    END
    WHILE(@@sqlstatus = 0)
    BEGIN
    INSERT INTO #TEMP_TABLE
    SELECT
    FROM
    WHERE
    AND .............. = @abc
    END
    Please facilitate a solution as to how to get this to work in a stored procedure?
    Thank you,
    Developer.

    Seems you question is concerned with MS SQL Server syntax. Here is
    the Oracle forum. Nevertheless all you are doing can be completed
    using the single sql statement:
    INSERT INTO <<temp table>>
    SELECT ... FROM ...
    WHERE ...
    AND ... IN (SELECT UNIQUE column-name
    FROM database name..Table Name
    WHERE condition)
    Rgds.

  • Importing function with multiple ref cursors in Stored Procedure of Oracle 12c database Using EF6

    Hi Good day!
    I can able to import function for stored procedure of oracle db and able to add the complex type and get the output but i tried to import the procedure which having two ref cursors and unable to retrieve the column information. Only able to retrieve the
    columns of first ref cursor.  Please help me to get the result of two ref cursors which acting as out parameters.

    Having to ref cursors return mutiple recordsets in an Oracle package is like haveng two resultsets return from a MS SQL Server sparc.
    The link may point you in the right direction.
    http://www.codeproject.com/Articles/675933/Returning-Multiple-Result-Sets-from-an-Entity-Fram

  • Extending a Cursor (for stored procedure)

    (Embedded image moved to file: PIC19643.PCX) Dan Christopher @ SUNLIFE
    03-13-97 04:39 PM
    I receive the following message when I try to extend a cursor for an
    execute of a stored procedure. I believe my problem has to do with using
    ODBC as my driver (to attach to a MS-SQL Server 6.5 database) , but does
    anyone have any other insight to what my problem may be.
    SYSTEM ERROR: Invalid state transition from FETCH to EXTENDED for statement of
    type qqdb_OdbcCursor.
    Class: qqdb_UsageException with ReasonCode: DB_ER_INVALIDSTATE
    Error #: [801, 152]
    Detected at: qqdb_Statement::ValidTransition
    Last TOOL statement: method w_connect.ExecStoredProc, line 53
    Error Time: Thu Mar 13 13:55:59
    Exception occurred (remotely) on partition "Dan_Connect_CL0_Part1",
    (partitionId = 210EC99B-811A-11D0-8D72-82F2A190AA77:0x22f:0x20, taskId =
    [210EC99B-811A-11D0-8D72-82F2A190AA77:0x23d:0x3.25]) in application
    "Forte
    Runtime", pid 314 on node 543SZAD in environment dusgroup.
    Here is a example of my code.
    constant NUM_ROWS_FETCH = 2; //default to fetch 50 rows
    //at a time.
    l_inputDataSet :DBDataSet = new; //input parameters for
    Forte
    l_statementtype :integer;
    l_return :integer; //return value for
    open/extend
    //cursor functions
    l_numRows :integer; //the number of rows fetch
    l_DBStatement :DBStatementHandle; //statement handle for
    sp
    l_statementtype = DB_CV_EXECUTE ;
    l_DBStatement = p_dbsession.Prepare(
    commandString = p_exec,
    inputDataSet = l_inputdataset,
    cmdType = l_statementtype);
    // fill in the parameter values
    for i in 1 to p_parameters.items do
    //integer parameter
    if (p_parameters.GetParmIndicator() = 'I') then
    l_inputdataset.SetValue(position = i,
    Value = p_parameters[i].GetParmValue().integervalue);
    else
    l_inputdataset.SetValue(position = i,
    Value = p_parameters[i].GetParmValue());
    end if;
    end for;
    //open the cursor
    l_return = p_dbsession.OpenCursor(
    StatementHandle = l_DBStatement,
    inputDataSet = l_inputdataset,
    resultDataSet = p_outputdataset);
    // Continue to Fetch and Extend the Cursor untill all rows have been
    retrieved.
    while (l_return != DB_RS_NONE) do
    l_numRows = p_dbsession.FetchCursor(
    StatementHandle = l_DBStatement,
    resultDataSet = p_outputdataset,
    maxRows = NUM_ROWS_FETCH);
    if (l_numRows = NUM_ROWS_FETCH) then //extend the cursor
    l_return = p_dbsession.ExtendCursor(
    StatementHandle = l_DBStatement,
    resultDataSet = p_outputdataset);
    else
    exit;
    end if;
    end while;
    //close the cursor
    p_dbsession.CloseCursor(statementHandle = l_DBStateMent);
    return l_numRows;

    Hi Dan,
    Thanks for the Calrification on Cursors, We solved it here.
    As for your Extend problem goes the Fetch should go outside the while
    loop I think.
    You first fetch and then get the next data set in a loop. I feel
    that this should solve your problem.
    Thankx
    Bala
    [email protected]
    Sage Solutions
    353 Sacramento
    Suite 1360
    San Francisco
    CA 94111.

  • UPDATE via REF CURSORS in STORED PROCEDURE

    Hello,
    Can I Get REF CURSOR as INPUT in STORED PROCEDURE and make an UPDATE according the input data ?
    Thanks

    Having to ref cursors return mutiple recordsets in an Oracle package is like haveng two resultsets return from a MS SQL Server sparc.
    The link may point you in the right direction.
    http://www.codeproject.com/Articles/675933/Returning-Multiple-Result-Sets-from-an-Entity-Fram

  • Stored procedure fails when called through jdbc

    Stored procedure returns incorrect results
    Hi!
    I am really puzzled about this and would really appreciate some help.
    We are migrating an servlet/jsp-application from websphere application server 3.5.3 to
    Oracle Application Server 10g. The backend is an Oracle 9i database server. Most of the application
    is build upon stored procedures in oracle. So the migration part is to make the servlets and JSPs
    to work in their new environment, creating deployment descriptors and so on.
    We are using JDeveloper 9.0.5.2 for development on Windows XP OS
    Java version is 1.4.2_03-b02 (ojvm)
    and also have an Oracle Application Server Enterprise Edition 9.0.4.0.0
    running on a W2K SP6. Java version is 1.4.2_03-b02, for development and testing.
    When running standalone (that comes width JDeveloper) OC4J the Java version is 1.4.2-b28 (client VM)
    The problem:
    When calling a stored procedure that calls another user defined procedure the returned result is wrong.
    The example snippet I've enclosed only success on my standalone OC4J.
    When I run the Java-app in JDeveloper using embedded OC4J it behaves incorrectly.
    When I run the Java-app deployed at the standalone OC4J that comes with JDeveloper it runs just fine.
    When I deploy the Java-app at the Oracle Application Server it behaves bad again.
    It looks like the procedure called by the procedure cannot execute correctly or that it got null value as in-parameter.
    What puzzles me is that this procedure did work correctly on websphere (JVM 1.2.2 and Oracle jdbc-drivers classes12.jar)
    and it does executes just fine on the standalone OC4J.
    I have tried different classes12.jar, ojdbc14.jar, different datasources (com.evermind.sql.DriverManagerDataSource,
    oracle.jdbc.pool.OracleConnectionCacheImpl) width no succes.
    /Mats Nord
    The code follows....
    - The java code
    CallableStatement cs =
         con.prepareCall("{ call oden.sp_tidGetProjForMember( ?, ?, ?, ?, ? ) }");
    cs.registerOutParameter(1, OracleTypes.CURSOR);
    cs.setLong(2, employeeNo);
    cs.setLong(3, projId);
    cs.setLong(4, actId);
    cs.setLong(5, period);
    cs.execute();
    ResultSet rs = (ResultSet) cs.getObject(1);
    while (rs.next()) {
         MyItem aItem =
              new MyItem(
                   Long.toString(employeeNo),
                   rs.getString(1),
                   rs.getString(2),
                   rs.getString(3),
                   rs.getString(4),
                   rs.getString(5),
                   rs.getString(6),
                   rs.getString(7),
                   rs.getString(8),     // (Actually a number). This row returns "0" but it shuold return a value greater than "0"
                   rs.getString(9));
              items.addElement(aItem);
    - The stored procedure:
    PROCEDURE sp_tidGetProjForMember (
    rs_Proj IN OUT report_types.weakCur -- recordset
    ,p_pnr IN V_ADMANV.anv_PNR%TYPE -- pnr projektmedlem, NUMBER(12)
    ,p_projid IN PROJ.PROJ_ID%TYPE -- projekt-id, NUMBER(5), kan vara tomt
    ,p_aktid IN AKT.AKT_ID%TYPE -- aktivitets-id, NUMBER(5), kan vara tomt
    ,p_yyyymm IN NUMBER) -- period NUMBER(6), YYYYMM, kan vara tomt
    &lt;&lt; Removed som lenghtly code from the post &gt;&gt;
    OPEN rs_Proj FOR
    SELECT
    DECODE(TIDPROJ.prj_status, v_skickad_id, 0, -- godkänd
         v_godknd_id, 0, -- godkänd
         NULL, 1, -- under bearbetning
                        v_ejgodk_id, 2, -- ej godkänd
                        v_undknd_id, 2 -- ej godkänd
              ) AS STATUS -- skickad 0: godkänd, 1: under bearbetning, 2: underkänd
         ,TIDPROJ.prj_projid
         ,PROJ.proj_namn
         ,V_ADMANV.anv_namn AS PLEDNAMN
         ,V_ADMANV.anv_PNR AS PLEDPNR
         ,TIDPROJ.prj_aktid
         ,AKT.AKT_NAMN AS AKTNAMN
    ,NVL(SUM(NVL(UTILITY.sp_ds2Decnum(TIDPROJ.prj_tid), 0)), 0) -- when calling the fuction UTILTY.sp_ds2Decnum
         ,NVL(TIDPROJKOMMENT.tpk_kommentar, ' ')
    FROM TIDPROJ
    &lt;&lt; Removed som lenghtly code from this post &gt;&gt;
    v_utdata := 'Recordset';
    Utility.sp_putLogg (v_spname, 0, v_indata, v_utdata, SQLCODE, SQLERRM); -- commits
    EXCEPTION
         WHEN OTHERS THEN
    v_utdata := 'FEL';
    Utility.sp_putLogg (v_spname, 0, v_indata, v_utdata, SQLCODE, SQLERRM); -- rollbacks
    END sp_tidGetProjForMember;

    Hi Kevin,
    Just an addition. To create SSIS package programmatically, please refer to the document:
    http://msdn.microsoft.com/en-us/library/ms345167.aspx 
    To implement dynamic column mapping through SSIS Script Component, please refer to:
    http://wikiprogrammer.wordpress.com/2011/04/08/dynamic-column-mapping-in-ssis-part-1/ 
    http://blog.quasarinc.com/ssis/best-solution-to-load-dynamically-change-csv-file-in-ssis-etl-package/ 
    Regards,
    Mike Yin
    TechNet Community Support

  • Stored procedure fails when run from SSIS DataFlow task

    I'hv a stored procedure (with dynamis SQL), taking colums names as parameters to run and returns dynamic columns in output. E.g. if I pass @ipselect = '*' it will returns all columns in output, when I pass @ipselect =  'column1, column2, column3'  
    ,it will returns 3 columns in output.
    Now I have SSIS package. I've Data Flow task in foreach loop container and it is taking parameter from client table. e.g
    clientid       column name
    1                        *
    2                columns1,columns2,column3
    3               columns1,columns2,column3,columns4,columns5,column6
    4                       *
    Foreach container loop through each client id and set ipselect parameter with
    column name  and that value is being passed to @ipselect stored procedure in Dataflow task. When there is @ipselect = '*' it runs fine ,returns all columns and write to destination. But when there is ipselect = 'columns1,columns2,column3',
    it fails with below error:
    [OLE DB Source [1]] Error: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80040E55.
    An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 10.0"  Hresult: 0x80040E55  Description: "Column does not exist.".
    [SSIS.Pipeline] Error: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED.  The PrimeOutput method on component "OLE DB Source" (1) returned error code 0xC0202009.  The component returned a failure code when the pipeline engine called PrimeOutput().
    The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing.  There may be error messages posted before this with more information about the failure.
    Any suggestion or solution would be really helpful.
    Thanks!!

    Hi Kevin,
    Just an addition. To create SSIS package programmatically, please refer to the document:
    http://msdn.microsoft.com/en-us/library/ms345167.aspx 
    To implement dynamic column mapping through SSIS Script Component, please refer to:
    http://wikiprogrammer.wordpress.com/2011/04/08/dynamic-column-mapping-in-ssis-part-1/ 
    http://blog.quasarinc.com/ssis/best-solution-to-load-dynamically-change-csv-file-in-ssis-etl-package/ 
    Regards,
    Mike Yin
    TechNet Community Support

  • Stored Procedure fails to return all rows of data.

    Our HR database uses a procedure to build a list of employee IDs (ie. 1,3,14,...1210,1215) then calls a procedure to with a variable to extract details per employee. Unfortunately the list is 947 ids, however only 887 rows are returned.
    As a test I split the list in two and called the procedure. If I add the data rows together I get 947, hence I know the employees are valid. Can anyone suggest why a long list of Ids should fail? Is there a limit a stored procedure can return?
    The procedure (simplified down a bit) is:
    ALTER PROCEDURE [dbo].[sp_Employee_CreateTable]
     @EmpIds varchar(4000)
    AS
    SELECT    E.empid as EmpId ,E.Surname
        FROM    Employee E
        WHERE  (E.[EmpID] IN (select * from GetAllUsersUnderManager(@EmpIds))) AND EJ.id=dbo.GetCurrentEmployeeJobRecord(EJ.empid)--EJ.dateto IS NULL
    I can run the procedure as:
    "exec sp_Employee_CreateTable @EmpIds=N'1,3,14.....999'" which returns (say) 700 rows  and  "exec sp_Employee_CreateTable @EmpIds=N'1001,.....1215'" which returns 247 rows. (ie. 700+247 = 947 which is correct.
    But exec sp_Employee_CreateTable @EmpIds=N'1,3,14......1215' only returns 887 rows.
    I have looked at the length of the data passed to the procedure (1,3,...1215) which equals 4126 chars, therefore I bumped the varchar space from 4,000 to 6,000 which is still within limits, however the number of rows returned was still 887.
    Any help would be gratefully received.

    Hi Scott. I run the script you suggested (thank you), the var EmpIds was set to a string with over 930 ids. The returned data set started with 0 but only had 888 rows. As mentioned above I refer the 930+ list as full list, and the 888 as the short list.
    The difference (around 47) were the last values in the full list.
    Although EmpIds was set to 6K it definately seems like it gets to around 4K chars then ignores any other values.
    Re "since you pass....". Absolutely. I have modified the Employee_CreateTable with the var update to 6K/
    ALTER PROCEDURE [dbo].[sp_Employee_CreateTable]
     @EmpIds varchar(6000),
     @IncludeLeavers Bit
    AS
        SELECT    E.empid as EmpId ,E.Surname, E.Firstname as Forename,E.PayrollID, E.intextno as Extension, EJ.position as Position, [dbo].[GetEmployeeDepartment](E.empid) as Department, [dbo].[GetEmployeeLocation](E.empid) as Location,
    E.title as Title, EJ.ReportsTo,
                CoEmail,E.[left]
        FROM    Employee E INNER JOIN EmployeeJobs EJ
        ON        E.empid = EJ.empid
        WHERE  (E.[EmpID] IN (select * from GetAllUsersUnderManager(@EmpIds))) AND EJ.id=dbo.GetCurrentEmployeeJobRecord(EJ.empid)--EJ.dateto IS NULL
                AND (E.[left]=0 or E.[left]=@IncludeLeavers)
        ORDER BY E.Surname, E.Firstname, E.empid

  • PL\SQL Stored Procedure failing.

    Hi,
    I have a collection of stored PL\SQL procedures in an Oracle 8i database. I call these stored procedures from Java code through OracleCallableStatement.
    I am experiencing a very strange problem. The system will run fine for a number of hours/days, during which time there will be many hundreds of successful calls to the stored procedures through the JDBC.
    Then, seemingly at random a call will fail. The error originates in the stored procedure and is reported as TABLE OR VIEW DOES NOT EXIST. I must stress here that a procedure that has run successfully many times before, will suddenly fail with this error.
    To my knowledge the stored procedures and schema have not been altered at all. Recompiling the PL\SQL procedure solves the problem.
    Could someone please help me to understand this strange behaviour.
    Thanks in advance,
    Max
    Oracle 8.1.7
    Java 1.3.1
    Classes12.zip

    Hi Max,
    If the error you are receiving is "TABLE OR VIEW DOES NOT EXIST", then you are indeed trying to access a non-existent table. Either the table has been "dropped" or you are using the wrong name to access it. Is the table a temporary table? Are you dynamically generating the name of the table in your java (or PL/SQL) code? When the error occurs, are you verifying whether the table does exist (or not)? Are there any background processes running (like backups, or statistics gathering) that may interfere with your stored procedures? Are these stored procedures in (PL/SQL) packages (that rely on "global" variables that suddenly have their values changed)?
    Solving the problem is easy. Finding the cause of the problem is hard. The error message can sometimes be misleading.
    Good Luck,
    Avi.

  • Java stored procedure failes to create.

    Hi All,
    I have a java program with following import statement.
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.net.URLConnection;
    Basically I am trying to make a HTTP post inside the jave code.
    My code complies properly but when I try to create the stored precudere I get the error
    "Procedure created with compilation errors."
    Any Idea what is causing the problem.
    Thanks in advance,
    Bikram

    Hi Schoeib,
    Thanks for your reply.
    I found the problem, the env variable Path was not properly defined.
    I am getting another issue now.Is there any restriction in accessing non static reference from the main class (which is used for creating the stored procedure).
    Static Wrapper --> non static class (All in one Jar).
    The compilation is okay ,even java stored proc got created,but when I execute the proc I get "no method mymethod in class myclass"
    Any Idea.
    Thanks & regards,
    Bikram

  • Cursors in Stored Procedures

    Hi,
    Hope someone can give me few ideas about this:
    I have a database table from which I will take each record in a cursor at one time, use that record as IN parameters in a procedure to do modifications on another table and then once it completes it will take the next record from the cursor and execute the procedure again with the new IN parameters from the second record of table1.
    Sample Code:
    PROCEDURE p_procedure (p_id IN table1.id%TYPE,
    p_date IN table1.date%TYPE,
    p_code IN table1.code%TYPE) IS
    CURSOR c1 IS
    SELECT id, date, code
    FROM table1
    WHERE id = p_id
    and date = p_date
    and code = p_code;
    BEGIN
    For crec in c1 LOOP
    BEGIN LOOP
    UPDATE table2
    SET ID = NULL, DATE = NULL, CODE = NULL, PRINT = NULL, TRAN = NULL --updates to columns in table2
    WHERE table2.id = p_id
    and table2.date = p_date
    and table2.code = p_code;
    COMMIT;
    END LOOP;
    END p_procedure;
    Is this the right process or is my code wrong???
    Thanks
    Manoj

    What is wrong in having a COMMIT inside a loop? It might only increase the I/O, but the code does work right?The COMMIT says you've finished and can release resources, the loop says you haven't finished and still need them. It's asking for trouble (traditionally in the form of ORA-01555 "Snapshot too old" errors, which confuse developers who thought they were doing the database a favour by saving their work like it was MS Word). It can also complicate restartability, although perversely developers sometimes claim it is necessary in order to allow restarting if a long-running process fails (which it isn't) or to allow monitoring of how far it's got.
    At the very least, try COMMIT WRITE BATCH NOWAIT ;)

Maybe you are looking for

  • Error in execution of  Web Services on WebLogic --ArrayIndexOutOfBoundsExc

    Hi, I Have an error with web services hosted on weblogic server and it is throwing the following exception stack trace. <MS1> <[ACTIVE] ExecuteThread: '15' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1329818512003> <BEA-

  • Converting a PDF to Excel

    I just paid for a subscription so I could convert PDF files to Excel. The first file I tried to convert (an Excel file that was converted to PDF) came out a jumbled mess. Help!

  • HT4623 My apps are stalled during updates after installing IO6 on my IPhone 4

    Since I downloaded IO6 on my Iphone4 last week, many apps showed updates and when I tried to download them, the Iphone shows installing, but this has been about 1 week and the apps are not usable.

  • Problem compiling file through Runtime.exec

    Hi all, I execute the following code : Runtime r = Runtime.getRuntime() Process p = r.exec("javac /home/test/temp dir/helloworld.java"); The command i give has a directory with space ("temp dir"). Iam not able to run the above code in Linux. Kindly h

  • No sound signal into the film

    Hello, everyone I am using iMac i52.8 RAM 12g, I recently editing canon 5d movie, found that more than 2 minutes movie clip audio signal loss will occur, but the original film with Quick Time Preview is normal, the film into Premiere Pro CS5.5.2 edit