Oracle Stored Procedure Not Accepting Comma delimited values in database

I have a stored procedure which does the following, declares variables and assigns values retrieved from a parameter temp_table database to each variable, then it reads column headings from a master table. Using the variables assigned to each parameter from the temp_table as a filter, the rows from the MASTER TABLE are finally output by the procedure. The stored procedure works fine when dealing with single value string values passed from the parameter temp_table.
The problem comes in when multiple values are selected and stored in the database parameter field as a comma separated string, eg. A045, A012
So, the strored procedure has been modified to use a function to split the string into separate values: 'A045' and 'A012'. So that: A045, A012 from the database will be returned to the stored procedure variable as *('A045', 'A012')* . When testing the stored procedure using the static values *('A045', 'A012')* , data is returned.
eg. EMPLOYEE_MASTER.CODE IN ('*A045*', '*A012*') will return results
However, when *('A045', 'A012')* is dynamically concatenated from the function and assigned to variable:
paramCode := split_str(paramCode) with paramCode eventually being passed: *('A045', 'A012')*
to become:
EMPLOYEE_MASTER.CODE IN (paramCode)
then NO DATA is returned.
I am stuck and don't know what the problem is. If anyone has any ideas, please feel free to help. I have included the Actual Stored Procedure below for a better understanding.
--------------------------------------------- STORED PROCEDURE-------------------------------------------------------
create or replace
PROCEDURE GETEMPLOYEEDATA
( sesId IN VARCHAR2,
l_cursor in out sys_refcursor
) is
compCode varchar(200);
businessUnit varchar(200);
locCode varchar(200);
hrDeptID varchar(200);
glDept varchar(200);     plat varchar(200);
deptFunc varchar(200);     empType varchar(200);
unionCode varchar(200);     jobCode varchar(200);     
careerLvl varchar(200);     
empStatus varchar(200);
zid varchar(200);
superID varchar(200);
counter varchar(200) ;
token_index number;
--v_errm VARCHAR2(256);
BEGIN
dbms_output.put_line('Start of BEGIN');
/* Counter to get number of Unique Employee ID based on valid Session ID */
select count(*) into counter from XXCCHRWEB.hr_web_sessionid_tmp where parameter_20=sesId;
open l_cursor for SELECT counter EMPLOYEE_ID, '' LAST_NAME,
'' FIRST_NAME from dual;
dbms_output.put_line('OPENING FIRST CURSOR');
/* If no valid session ID returned then error gently */
if counter=0 then
open l_cursor for SELECT '' EMPLOYEE_ID, '' LAST_NAME,
'' FIRST_NAME,'' MIDDLE_NAME,'' NAME,
'' EMPLOYEE_TYPE, '' COMPANY, '' COMPANY_DESCRIPTION,
'' BUSINESS_UNIT, '' BUSINESS_UNIT_DESCRIPTION, '' LOCATION,
'' LOCATION_NAME, '' HR_DEPARTMENT_ID,'' DEPARTMENT_NAME,
'' DEPARTMENT_FUNCTION, '' PLATFORM, '' JOB_CODE,
'' JOB_TITLE, '' BUSINESS_TITLE, '' MANAGER_LEVEL,
'' JOB_FUNCTION, '' GL_DEPARTMENT_ID, '' GL_OP_UNIT,
'' GL_RESPONSIBILITY_CENTER, '' HR_CHANNEL,'' FULL_OR_PART_TIME,
'' REGULAR_OR_TEMP, '' GRADE,'' UNION_CODE,
'' BARGAINING_UNIT, '' ANNUAL_RATE,'' HOURLY_RATE,
'' HIRE_DATE, '' BIRTH_DATE, '' REHIRE_DATE,
'' SERVICE_DATE, '' POSITION_NUMBER, '' REPORTS_TO,
'' REPORTS_TO_TITLE, '' SUPERVISOR_ID, '' SUPERVISOR_NAME,
'' LAN_ID from dual;
dbms_output.put_line('End of counter=0');
-- return;
end if;
/* read from hr_web_sessionid_tmp */
select
parameter_1,parameter_2, parameter_3, parameter_4,
parameter_5,parameter_6, parameter_7, parameter_8,
parameter_9,parameter_10, parameter_11, parameter_12,
parameter_13, parameter_14
into
compCode,     businessUnit,     locCode, hrDeptID,
glDept,     plat,     deptFunc,     empType,
unionCode, jobCode,     careerLvl, empStatus,
zid, superID
from
XXCCHRWEB.hr_web_sessionid_tmp
where
parameter_20= sesId;
/*Assigning All Value to NULL superID*/
IF superid is null then
superID:= 'All';
END IF;
jobCode:='('''|| get_token(jobCode, 1)||''')'||','||'('''|| get_token(jobCode, 2)||''')';
dbms_output.put_line('SELECTING PARAMETERS FROM TEMP TABLE WITH ROW COUNT : '||l_cursor%ROWCOUNT);
/* read from Employee Master */
open l_cursor for SELECT DISTINCT * FROM ( SELECT HR_EMPLOYEE_MASTER.EMPLOYEE_ID, HR_EMPLOYEE_MASTER.LAST_NAME,
HR_EMPLOYEE_MASTER.FIRST_NAME, HR_EMPLOYEE_MASTER.MIDDLE_NAME, HR_EMPLOYEE_MASTER.NAME,
HR_EMPLOYEE_MASTER.EMPLOYEE_TYPE, HR_EMPLOYEE_MASTER.COMPANY, HR_EMPLOYEE_MASTER.COMPANY_DESCRIPTION,
HR_EMPLOYEE_MASTER.BUSINESS_UNIT, HR_EMPLOYEE_MASTER.BUSINESS_UNIT_DESCRIPTION, HR_EMPLOYEE_MASTER.LOCATION,
HR_EMPLOYEE_MASTER.LOCATION_NAME, HR_EMPLOYEE_MASTER.HR_DEPARTMENT_ID, HR_EMPLOYEE_MASTER.DEPARTMENT_NAME,
HR_EMPLOYEE_MASTER.DEPARTMENT_FUNCTION, HR_EMPLOYEE_MASTER.PLATFORM, HR_EMPLOYEE_MASTER.JOB_CODE,
HR_EMPLOYEE_MASTER.JOB_TITLE, HR_EMPLOYEE_MASTER.BUSINESS_TITLE, HR_EMPLOYEE_MASTER.MANAGER_LEVEL,
HR_EMPLOYEE_MASTER.JOB_FUNCTION, HR_EMPLOYEE_MASTER.GL_DEPARTMENT_ID, HR_EMPLOYEE_MASTER.GL_OP_UNIT,
HR_EMPLOYEE_MASTER.GL_RESPONSIBILITY_CENTER, HR_EMPLOYEE_MASTER.HR_CHANNEL, HR_EMPLOYEE_MASTER.FULL_OR_PART_TIME,
HR_EMPLOYEE_MASTER.REGULAR_OR_TEMP, HR_EMPLOYEE_MASTER.GRADE, HR_EMPLOYEE_MASTER.UNION_CODE,
HR_EMPLOYEE_MASTER.BARGAINING_UNIT, HR_EMPLOYEE_MASTER.ANNUAL_RATE, HR_EMPLOYEE_MASTER.HOURLY_RATE,
HR_EMPLOYEE_MASTER.HIRE_DATE, HR_EMPLOYEE_MASTER .BIRTH_DATE, HR_EMPLOYEE_MASTER.REHIRE_DATE,
HR_EMPLOYEE_MASTER.SERVICE_DATE, HR_EMPLOYEE_MASTER.POSITION_NUMBER, HR_EMPLOYEE_MASTER.REPORTS_TO,
HR_EMPLOYEE_MASTER.REPORTS_TO_TITLE, HR_EMPLOYEE_MASTER.SUPERVISOR_ID, HR_EMPLOYEE_MASTER.SUPERVISOR_NAME, HR_EMPLOYEE_MASTER.GENDER,
HR_EMPLOYEE_MASTER_1.LAN_ID
FROM
(XXCCHR.HR_EMPLOYEE_MASTER HR_EMPLOYEE_MASTER_1
LEFT OUTER JOIN
XXCCHR.HR_DEPARTMENT_SECURITY HR_DEPARTMENT_SECURITY
ON
HR_EMPLOYEE_MASTER_1.EMPLOYEE_ID=HR_DEPARTMENT_SECURITY.EMPLOYEE_ID)
LEFT OUTER JOIN
XXCCHR.HR_EMPLOYEE_MASTER HR_EMPLOYEE_MASTER
ON
-- HR_DEPARTMENT_SECURITY.DEPARTMENT_SECURITY=HR_EMPLOYEE_MASTER.HR_DEPARTMENT_ID
(HR_DEPARTMENT_SECURITY.DEPARTMENT_SECURITY=HR_EMPLOYEE_MASTER.HR_DEPARTMENT_ID
or
HR_DEPARTMENT_SECURITY.DEPARTMENT_SECURITY in ('DPALL','DPCAG009'))
WHERE
HR_EMPLOYEE_MASTER_1.LAN_ID=upper(zid) and
(compCode = 'All' or HR_EMPLOYEE_MASTER.COMPANY IN compCode)
(jobCode = 'All' or HR_EMPLOYEE_MASTER.JOB_CODE IN (jobCode) ) ) ;
dbms_output.put_line('END OF SELECT for counter number : ' || counter ||' Cursor row count : '|| l_cursor%ROWCOUNT || ' with Job Code : ' || (jobCode));
dbms_output.put_line('Company Code is:' || compCode);
COMMIT;
dbms_output.put_line('Data has been Output with session id:' || sesId);
--delete from XXCCHRWEB.hr_web_sessionid_tmp where parameter_20= sesId;
dbms_output.put_line('Data should have been DELETED, please check the session temp table');
commit;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('AN EXCEPTION HAS BEEN CAUGHT for counter number : ' || counter ||' Cursor row count : '|| l_cursor%ROWCOUNT || ' from session id : ' || sesId);
dbms_output.put_line('The error code is ' || SQLERRM);
END GETEMPLOYEEDATA;
Edited by: user10384134 on Nov 4, 2009 8:37 AM

This seems to work for me:
define param="'ABC','XYZ'"; --- Set up a test in clause
--- Test data
with test as
(select 'ABC' fld from dual union all
select 'DEF' from dual union all
select 'PQR' from dual union all
select 'XYZ' from dual)
--- Query starts here.
select fld
from test,
       table (sys.ODCIVarchar2List (&param)) p
where fld = p.column_valueOr Using an actual "IN" clause:
define param="'ABC','XYZ'";
with test as
(select 'ABC' fld from dual union all
select 'DEF' from dual union all
select 'PQR' from dual union all
select 'XYZ' from dual
p as
(select column_value from table (sys.ODCIVarchar2List (&param))
select fld
from test
where fld in (select column_value from p)Edited by: AlanWms on Nov 4, 2009 9:08 AM

Similar Messages

  • Oracle Stored Procedure not working

    Hi Guy's,
    I want to connect directly from Visual Composer to Oracle Database 10.2.x.x using Oracle Stored Procedure and JDBC System to demonstrate how easy you can show data vith VC. So I have created a simple Oracle Stored Procedure, a JDBC System with a valid alias, User mapping (Portal User --> Oracle User).
    When I invoke the stored procedure I receive the following error: "Portal request Failed (Could not execute stored procedure)". The Stored Procedure is working fine in Oracle iSQL*Plus.
    Any idea's?
    Thanks,
    Ridouan

    Hi,
    did you use the portal JDBC as it is described here:
    <a href="https://wiki.sdn.sap.com/wiki/display/VC/Cannotseetables">https://wiki.sdn.sap.com/wiki/display/VC/Cannotseetables</a>
    Best Regards,
    Marcel

  • Oracle stored procedure in PHP fetching XML values

    Hi,
    I have the below table created in oracle
    CREATE TABLE TEST_XML(
    ID NUMBER(5),
    DATA VARCHAR2(4000)
    INSERT INTO TEST_XML VALUES(100,'<student><name>Ruck</name><id>1</id></student>');
    I have created a procedure:
    CREATE OR REPLACE PROCEDURE SP_TEST_XML
    ( ID IN NUMBER,
    DATA OUT VARCHAR2
    IS
    -- local variables
    v_ID      NUMBER(5);
    v_DATA VARCHAR2(4000);
    BEGIN
         v_ID := ID;
    SELECT     DATA
         INTO     v_DATA
         FROM      TEST_XML
         WHERE     ID = v_ID;
         DATA := v_DATA;
    EXCEPTION
    WHEN OTHERS THEN
         DBMS_OUTPUT.PUT_LINE(SQLERRM);
    END;
    When i run the below block in sqlplus:
    DECLARE
    a VARCHAR2(4000);
    BEGIN
    SP_TEST_XML(100,a);
    DBMS_OUTPUT.PUT_LINE('The value is: ' || a);
    EXCEPTION
    WHEN OTHERS THEN
         DBMS_OUTPUT.PUT_LINE(SQLERRM);
    END;
    I get the below output:
    'The value is: <student><name>Ruck</name><id>1</id></student>
    But i tried to call the same procedure and fetch the data value using below php code:
    <?php
    $conn = OCILogon("username", "password", "dbhost");
    $sql = 'BEGIN SP_TEST_XML(:ID, :DATA); END;';
    $stmt = OCIParse($conn,$sql);
    //Bind the input parameters
    $p = OCIBindByName($stmt,':ID',$ID,5);
    // Bind the output parameter
    $q = OCIBindByName($stmt,':DATA',$DATA,4000);
    // Assign values to input parameters
    $ID = 100;
    OCIExecute($stmt);
    echo " Data = $DATA <br>";
    OCIFreeStatement($stmt);
    OCILogoff($conn);
    ?>
    I get the following result : Ruck1
    Why is the complete string not outputed?why are tags eliminated from output?
    only the values are concatenated and returned?
    Pls help me.
    Thanks.
    srinath.

    Hi, I have the below table created in oracle
    CREATE TABLE TEST_XML(
    ID NUMBER(5),
    DATA VARCHAR2(4000) );
    INSERT INTO TEST_XML VALUES(100,'<student><name>Ruck</name><id>1</id></student>');
    I have created a procedure:
    CREATE OR REPLACE PROCEDURE SP_TEST_XML
    ( ID IN NUMBER, DATA OUT VARCHAR2 )
    IS -- local variables v_ID NUMBER(5); v_DATA VARCHAR2(4000);
    BEGIN
    v_ID := ID;
    SELECT DATA INTO v_DATA FROM TEST_XML WHERE ID = v_ID;
    DATA := v_DATA;
    EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE(SQLERRM); END; /
    When i run the below block in sqlplus:
    DECLARE a VARCHAR2(4000);
    BEGIN SP_TEST_XML(100,a);
    DBMS_OUTPUT.PUT_LINE('The value is: ' || a);
    EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE(SQLERRM); END; /
    I get the below output: 'The value is: <student><name>Ruck</name><id>1</id></student>
    But i tried to call the same procedure and fetch the data value using below php code:
    <?php $conn = OCILogon("username", "password", "dbhost");
    $sql = 'BEGIN SP_TEST_XML(:ID, :DATA); END;';
    $stmt = OCIParse($conn,$sql);
    //Bind the input parameters $p = OCIBindByName($stmt,':ID',$ID,5);
    // Bind the output parameter $q = OCIBindByName($stmt,':DATA',$DATA,4000);
    // Assign values to input parameters $ID = 100;
    OCIExecute($stmt); echo " Data = $DATA
    "; OCIFreeStatement($stmt); OCILogoff($conn); ?>
    I get the following result : Ruck1
    Why is the complete string not outputed?why are tags eliminated from output? only the values are concatenated and returned? Pls help me. Thanks. srinath.

  • Not able to get Oracle stored procedure return value passed to Powerbuilder

    I have an Oracle Stored Procedure that receives a string value and returns a string value..  When I call it from Powerbuilder, it executes but does not send the return value of a string back.  I am trying to encrypt a string in Powerbuilder, pass it to a .net web page and then decrypt so I can check the security tables for permissions to view the web page.  I have tried creating a simple stored procedure that takes a string and returns a string to Powerbuilder; but even that is not working.  Any suggesstions?
    Oracle Procedure:
    CREATE OR REPLACE
    PROCEDURE               TESTINOUT_VARCHAR
    ( P_STRING IN VARCHAR2, P_OUT OUT VARCHAR2)
    IS
       BEGIN  
          P_OUT := P_STRING || 'TESTING';
    END TESTINOUT_VARCHAR;
    Powerbuilder Call:
    string p_string ='                                 '
    Declare TestingString procedure for TESTINOUT_VARCHAR(:ls_group, :p_out) using SQLCA
    Execute TestingString;
    IF SQLCA.CODE = 0 THEN
    FETCH TestingString into:p_out;
    End If
    p_string = p_out;

    Hello John,
    I'm not sure if you already found a solution using an ODBC connection.
    Below the solution with an RPC call:
    Create a user object (uo_trans) of type transaction with the following local external function:
    subroutine TESTINOUT_VARCHAR(string P_STRING,ref string P_OUT) RPCFUNC
    Execute this script
    uo_trans l_transaction
    string ls_outparam
    l_transaction = CREATE uo_trans
    // Profile ODBC_ORA
    l_transaction.DBMS = "ODBC"
    l_transaction.AutoCommit = False
    l_transaction.DBParm = "ConnectString='DSN=ODBC_ORA;UID=system;PWD=<xxxxxx>'"
    connect using l_transaction;
    ls_outparam = space (30)
    l_transaction.testinout_varchar( sle_1.text, ls_outparam)
    messagebox("OUT parameter", ls_outparam)
    disconnect using l_transaction;
    DESTROY l_transaction

  • Not able to retrive the recordset from oracle stored procedure in VC++

    Hi,
    I am trying to retrieve the records from the reference cursor which is an out parameter for an oracle 9i store procedure in VC++ application. But it is giving the record count as -1 always. Meanwhile i am able to get the required output in VB application from the same oracle 9i store procedure .
    Find the code below which i used.
    Thanks,
    Shenba
    //// Oracle Stored Procedure
    <PRE lang=sql>CREATE OR REPLACE
    PROCEDURE GetEmpRS1 (p_recordset1 OUT SYS_REFCURSOR,
    p_recordset2 OUT SYS_REFCURSOR,
    PARAM IN STRING) AS
    BEGIN
    OPEN p_recordset1 FOR
    SELECT RET1
    FROM MYTABLE
    WHERE LOOKUPVALUE > PARAM;
    OPEN p_recordset2 FOR
    SELECT RET2
    FROM MYTABLE
    WHERE LOOKUPVALUE >= PARAM;
    END GetEmpRS1;</PRE>
    ///// VC++ code
    <PRE lang=c++ id=pre1 style="MARGIN-TOP: 0px">ConnectionPtr mpConn;
    _RecordsetPtr pRecordset;
    _CommandPtr pCommand;
    _ParameterPtr pParam1;
    //We will use pParam1 for the sole input parameter.
    //NOTE: We must not append (hence need not create)
    //the REF CURSOR parameters. If your stored proc has
    //normal OUT parameters that are not REF CURSORS, you need
    //to create and append them too. But not the REF CURSOR ones!
    //Hardcoding the value of i/p paramter in this example...
    variantt vt;
    vt.SetString("2");
    m_pConn.CreateInstance (__uuidof (Connection));
    pCommand.CreateInstance (__uuidof (Command));
    //NOTE the "PLSQLRSet=1" part in
    //the connection string. You can either
    //do that or can set the property separately using
    //pCommand->Properties->GetItem("PLSQLRSet")->Value = true;
    //But beware if you are not working with ORACLE, trying to GetItem()
    //a property that does not exist
    //will throw the adErrItemNotFound exception.
    m_pConn->Open (
    bstrt ("Provider=OraOLEDB.Oracle;PLSQLRSet=1;Data Source=XXX"),
    bstrt ("CP"), bstrt ("CP"), adModeUnknown);
    pCommand->ActiveConnection = m_pConn;
    pParam1 = pCommand->CreateParameter( bstrt ("pParam1"),
    adSmallInt,adParamInput, sizeof(int),( VARIANT ) vt);
    pCommand->Parameters->Append(pParam1);
    pRecordset.CreateInstance (__uuidof (Recordset));
    //NOTE: We need to specify the stored procedure name as COMMANDTEXT
    //with proper ODBC escape sequence.
    //If we assign COMMANDTYPE to adCmdStoredProc and COMMANDTEXT
    //to stored procedure name, it will not work in this case.
    //NOTE that in the escape sequence, the number '?'-s correspond to the
    //number of parameters that are NOT REF CURSORS.
    pCommand->CommandText = "{CALL GetEmpRS1(?)}";
    //NOTE the options set for Execute. It did not work with most other
    //combinations. Note that we are using a _RecordsetPtr object
    //to trap the return value of Execute call. That single _RecordsetPtr
    //object will contain ALL the REF CURSOR outputs as adjacent recordsets.
    pRecordset = pCommand->Execute(NULL, NULL,
    adCmdStoredProc | adCmdUnspecified );
    //After this, traverse the pRecordset object to retrieve all
    //the adjacent recordsets. They will be in the order of the
    //REF CURSOR parameters of the stored procedure. In this example,
    //there will be 2 recordsets, as there were 2 REF CURSOR OUT params.
    while( pRecordset !=NULL ) )
    while( !pRecordset->GetadoEOF() )
    //traverse through all the records of current recordset...
    long lngRec = 0;
    pRecordset = pRecordset->NextRecordset((VARIANT *)lngRec);
    //Error handling and cleanup code (like closing recordset/ connection)
    //etc are not shown here.</PRE>

    It can be linked to internal conversion. In some case, the value of internal or extranal value is not the same.
    When you run SE16 (or transaction N), you have in option mode the possibility to use the exit conversion or not.
    Christophe

  • How in ColdFusion with in variables get a Oracle stored procedure to return values?

    How in ColdFusion with in variables get a Oracle stored procedure to return values?
    We have tried several things, we can get  a stored procedure to return a result set if we are not passing in variables but we cannot get them when we are passing in variables.
    We know how to do it calling  MS SQL.
    Thanks for any help,
    Nathan Sr
    P.S. we have heard this may not be possible with the current Oracle Driver is there a different Oracle driver?

    I can only barely understand what you're asking here (not from a technical perspective, but from understanding your written English), but I suspect you're wanting to know how to pass back values other than recordsets from Oracle?
    You should be able to pass them back via a type=out proc param, shouldn't you?
    If you could reword your post so it's a bit more coherent, and possibly post some code, that might help.
    Adam

  • BO v5.1 - creating a report from an oracle stored procedure

    Post Author: newrochelle
    CA Forum: Publishing
    hi to all,
    im using BO 5.1 and i need to create a document from an oracle stored procedure that have only one IN parameter and ten OUT parameters.
    Creating the new report I selected the database connection then I choose the stored procedure name from the list, I inserted the value for the IN parameter and finally I click on Run button.
    I got the following error message:
    ORA-06550: line 1, column 38: :PLS-00103: Encountered the symbol
    "," when expecting one of the following: : : ( - + case mod
    new not null others <an identifier> : <a double-quoted
    delimited-identifier> <a bind variable> avg : count current
    exists max min prior sql stddev sum variance : execute forall
    merge time timestamp interval date : <a string literal with
    character set specification> : <a number> <a single-quoted SQL
    string> pipe : <an alternatively-quoted string literal with
    character set specification> : <an alternatively-q :-6550
    it seems to be caused by the OUT parameters!
    i leaved them without any value.
    it's the first time that I used a stored procedure to create a BO report, but I think the OUT parameters are needed to do that, otherwise what data will be presented in the report???
    can you help me?
    please answear me ASAP.
    Thank's in advance
    Regards
    Andrea

    Post Author: synapsevampire
    CA Forum: Publishing
    Try posting in a BO forum, this is Crystal Reports.
    -k

  • Oracle Stored Procedure with out parameter

    Good morning,
    Is it possible to use an Oracle stored procedure with out parameters in MII ?
    If yes, what is the manipulation to see the values of parameters Out?
    Thank you

    Michael,
    This is the  MII query template  :
    DECLARE
    STRCOMPTERENDU NVARCHAR2(200);
    BEGIN
    STRCOMPTERENDU := NULL;
    XMII.SP_VALIDATEPROCESSORDERSLIST2 ( STRCOMPTERENDU => [Param.1]  );
    COMMIT;
    END;
    and the stocked procedure code
    CREATE OR REPLACE PROCEDURE XMII.SP_ValidateProcessOrdersList2(strCompteRendu OUT nVarchar2) IS
    tmpVar NUMBER;
    debugmode INT;
    strClauseSql varchar(2048);
    strListPOactif varchar(1024);
    dtmTimeStamp DATE;
       NAME:       SP_ValidateProcessOrdersList
       PURPOSE:   
       REVISIONS:
       Ver        Date        Author           Description
       1.0        18/06/2008          1. Created this procedure.
       NOTES:
       Automatically available Auto Replace Keywords:
          Object Name:     SP_ValidateProcessOrdersList
          Sysdate:         18/06/2008
          Date and Time:   18/06/2008, 18:45:32, and 18/06/2008 18:45:32
          Username:         (set in TOAD Options, Procedure Editor)
          Table Name:       (set in the "New PL/SQL Object" dialog)
    BEGIN
       tmpVar := 0;
       debugmode := 0;
       -- lecture date systeme pour time stamp
       select sysdate  into dtmTimeStamp from dual;
       if debugmode = 1 then
        DBMS_OUTPUT.put_line('SP_ValidateProcessOrdersList');
       end if;
       -- insertion du bloc dans le log
       insert into LOG_ORDER
        (DATE_ORDER,BLOCK_ORDER,ID_LOG_ORDER)
       values
       (dtmTimeStamp,'SP_ValidateProcessOrdersList',ID_LOG_ORDER.nextval);
       Commit;
        if debugmode = 1 then
        DBMS_OUTPUT.put_line('insertion LOG OK');
       end if;
    strCompteRendu := '0123456-896;0123456-897';
    commit; 
       EXCEPTION
         WHEN NO_DATA_FOUND THEN
           NULL;
         WHEN OTHERS THEN
         ROLLBACK;
         -- insertion du bloc dans le log
       insert into LOG_ORDER
        (DATE_ORDER,BLOCK_ORDER,ID_LOG_ORDER)
       values
       (dtmTimeStamp,' ',ID_LOG_ORDER.nextval);
       COMMIT;
           -- Consider logging the error and then re-raise
           RAISE;
    END SP_ValidateProcessOrdersList2;
    Thanks for your help
    Alexandre

  • Oracle Stored Procedure in Java

    I am try to write a stored procedure which is to written using java and then loaded into oracle. What this stored procedure does is insert some values into an oracle table. Here is a piece of code that i have tested before doing the whole real thing. But the stored procedure compiled, loaded into oracle without problems. Once the stored procedure is executed, it does nothing.
    Heres the code -
    import java.sql.*;
    import oracle.jdbc.driver.*;
    public class test{
    public static void insert()
    Connection cn = null;
    PreparedStatement ps = null;
    String sql ="INSERT INTO Testing.test VALUES ('JEFF')";
    try{
    cn = new OracleDriver().defaultConnection();
    ps.execute(sql);
    ps.close();
    cn.commit();
    cn.close();
    }catch(Exception e){
    Here is the table structure in Oracle 9i -
    Name Null? Type
    USER NOT NULL CHAR(12)
    Hope u guys can help me out.

    Once the stored procedure is executed, it does nothing.Actually it DOES do something - it throws a NullPointerException. You have a catch block with nothing in it, so your code doesn't report the problem.
    How do you execute this? Is there another class that calls it?
    This doesn't use a stored procedure. You need a java.sql.CallableStatement for that.
    Where did you get this code? Does it even compile?
    When I tried to create a table named "user" in my Oracle instance it complained. I made it "application_user" instead. How did you ever try this problem?
    I think you need a JDBC tutorial:
    http://java.sun.com/docs/books/tutorial/jdbc/
    Here's how I'd write it:
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    public class OracleInsertTest
        public static final String DRIVER   = "oracle.jdbc.driver.OracleDriver";
        // Substitute your host, database, username, and password
        public static final String DATABASE = "jdbc:oracle:thin:@host:1521:database";
        public static final String USERNAME = "username";
        public static final String PASSWORD = "password";
        public static void main(String [] args)
            if (args.length > 0)
                try
                    Class.forName(DRIVER);
                    Connection connection = DriverManager.getConnection(DATABASE, USERNAME, PASSWORD);
                    String sql = "INSERT INTO application_user(name) VALUES(?)";
                    PreparedStatement statement = connection.prepareStatement(sql);
                    statement.setString(1, args[0]);
                    int numRowsInserted = statement.executeUpdate();
                    System.out.println("# rows inserted: " + numRowsInserted);
                    statement.close();
                    connection.close();
                catch (Exception e)
                    // Empty catch blocks are usually a very bad idea.
                    e.printStackTrace();
            else
                System.err.println("No command line argument given");
    }MOD

  • Passing parameters to oracle stored procedure in business objects universe

    Hello,
    Wanted to create a web intelligence usind oracle stored procedure.
    Create the  following SP
    create or replace procedure proc_name1
        proc_freq in number,
        proc_cur1 in out sys_refcursor
    as
    begin
        INSERT INTO
                cc    VALUES
                ( 'Frequency Value = ' || proc_freq, SYSDATE) ;
        COMMIT ;   
        --daily
            if(proc_freq = 2) then
            open proc_cur1 for SELECT
                        EVENT_DATE
                    FROM rqm_mapsigng_dly_stats;
            end if;
    end;
    tried using the above SP in universe, it is needed to pass the parameter for proc_freq, when i pass value 2 , in oracle it is passed as 0(is being traced in rqm_checkpoint  table)
    Hence the table cannot be inserted in the universe.
    Can anyone tell why the value is not being passed correctly

    I believe when you're doing it with an insert, you're saying "execute this insert statement a bunch of times, here's all the values in advance", which is different than passing an array to a stored procedure where you want it to execute once.
    Oracle's ODBC driver doesnt support Associative Arrays (aka index-by tables).
    Hope it helps,
    Greg

  • Call to Oracle stored procedure that returns ref cursor doesn't work

    I'm trying to use an OData service operation with Entity Framework to call an Oracle stored procedure that takes an number as an input parameter and returns a ref cursor. The client is javascript so I'm using the rest console to test my endpoints. I have been able to successful call a regular Oracle stored procedure that takes a number parameter but doesn't return anything so I think I have the different component interactions correct. When I try calling the proc that has an ref cursor for the output I get the following an error "Invalid number or type of parameters". Here are my specifics:
    App.config
    <oracle.dataaccess.client>
    <settings>
    <add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursor.P_RESULTS" value="implicitRefCursor bindinfo='mode=Output'" />
    <add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.0" value="implicitRefCursor metadata='ColumnName=WINDFARM_ID;BaseColumnName=WINDFARM_ID;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Number;ProviderType=Int32'" />
    <add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.1" value="implicitRefCursor metadata='ColumnName=STARTTIME;BaseColumnName=STARTTIME;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
    <add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.2" value="implicitRefCursor metadata='ColumnName=ENDTIME;BaseColumnName=ENDTIME;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
    <add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.3" value="implicitRefCursor metadata='ColumnName=TURBINE_NUMBER;BaseColumnName=TURBINE_NUMBER;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
    <add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.4" value="implicitRefCursor metadata='ColumnName=NOTES;BaseColumnName=NOTES;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
    <add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.5" value="implicitRefCursor metadata='ColumnName=TECHNICIAN_NAME;BaseColumnName=TECHNICIAN_NAME;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
    <add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYID.RefCursor.P_RESULTS" value="implicitRefCursor bindinfo='mode=Output'" />
    </settings>
    OData Service Operation:
    public class OracleODataService : DataService<OracleEntities>
    // This method is called only once to initialize service-wide policies.
    public static void InitializeService(DataServiceConfiguration config)
    // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
    // Examples:
    config.SetEntitySetAccessRule("*", EntitySetRights.All);
    config.SetServiceOperationAccessRule("GetWorkOrdersByWindfarmId", ServiceOperationRights.All);
    config.SetServiceOperationAccessRule("CreateWorkOrder", ServiceOperationRights.All);
    config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
    [WebGet]
    public IQueryable<GetWorkOrdersByWindfarmId_Result> GetWorkOrdersByWindfarmId(int WindfarmId)
    return this.CurrentDataSource.GetWorkOrdersByWindfarmId(WindfarmId).AsQueryable();
    [WebGet]
    public void CreateWorkOrder(int WindfarmId)
    this.CurrentDataSource.CreateWorkOrder(WindfarmId);
    Here is the stored procedure:
    procedure GetWorkOrdersByWindFarmId(WINDFARMID IN NUMBER,
    P_RESULTS OUT REF_CUR) is
    begin
    OPEN P_RESULTS FOR
    select WINDFARM_ID,
    STARTTIME,
    ENDTIME,
    TURBINE_NUMBER,
    NOTES,
    TECHNICIAN_NAME
    from WORKORDERS
    where WINDFARM_ID = WINDFARMID;
    end GetWorkOrdersByWindFarmId;
    I defined a function import for the stored procedure using the directions I found online by creating a new complex type. I don't know if I should be defining the input parameter, WindfarmId, in my app.config? If I should what would that format look like? I also don't know if I'm invoking the stored procedure correctly in my service operation? I'm testing everything through the rest console because the client consuming this information is written in javascript and expecting a json format. Any help is appreciated!
    Edited by: 1001323 on Apr 20, 2013 8:04 AM
    Edited by: jennyh on Apr 22, 2013 9:00 AM

    Making the change you suggested still resulted in the same Oracle.DataAccess.Client.OracleException {"ORA-06550: line 1, column 8:\nPLS-00306: wrong number or types of arguments in call to 'GETWORKORDERSBYWINDFARMID'\nORA-06550: line 1, column 8:\nPL/SQL: Statement ignored"}     System.Exception {Oracle.DataAccess.Client.OracleException}
    I keep thinking it has to do with my oracle.dataaccess.client settings in App.Config because I don't actually put the WindfarmId and an input parameter. I tried a few different ways to do this but can't find the correct format.

  • JDBC Sender - Oracle Stored procedures

    hi all
    i am working on JDBC sender - File receiver
    I am fetching data from Oracle database
    if i write select query directly in sender adapter the scenario is working properly but when try to write stored procedure in oracle and use execute statement in JDBC, adapter is throwing error.
    As in oracle to fetch multiple rows i have to use cursors .
    i read lot of articles in forum but still not clear on following issues :can any one solve them?
    1 . To get multiple rows can i write SP without cursors?
    2 . If SP is using cursor do my XI accept it or it only accepts  resultset? in that     case how to write sp.
    thanks & regards
    sheetal

    Sheetal,
    Adding to Jai Shankar's reply, Like pointed out, Oracle Stored Procedures return Cursors and XI sender JDBC adapter expects resultsets and so it is not possible to call Oracle SP's from Sender JDBC adapters.
    But, I have also come across a few recent threads where there have been discussions that this is possible  from SP 16 onwards. I have not been able to check and confirm on this, but, maybe you can check your SP level and see if you are below SP 16 . If yes, definetly not possible. If SP 16, or above, a Quick OSS to SAP should surely give the answer if it is possible or not!
    Do let us know your findings.
    Regards
    Bhavesh

  • Errors in calling Oracle stored procedure using java CallableStatement

    Hello,
    I have an oracle stored procedure below, it has been tested in PL/SQL without errors. During testing, in_c_file_type="F"; out_n_seqno_freeformat=120139596 and out_n_seqno_commaseprated is null (empty in value column).
    When I run the program in Eclipse (windows xp), error messages is below: (It stopped at line 'cstme.execute();' )
    Message:ORA-06550: line 1, column 26: PLS-00103: Encountered the symbol "" when expecting one of the following:   . ( ) , * @ % & | = - + < / > at in is mod remainder not   range rem => .. <an exponent (**)> <> or != or ~= >= <= <>   and or like LIKE2_ LIKE4_ LIKEC_ as between from using ||   indicator multiset member SUBMULTISET_ The symbol ", was inserted before "" to continue. Error code:6550 SQL statement:65000 {code} Does anyone know what cause the error? It seems like something is missing in the stored procedure. But the stored procedure passes the test in the PL/SQL. The oracla driver I used is Oracle thin driver. Oracle version is 10.2.g Thanks in advance. northcloud {code} create or replace procedure SP_GET_SEQNO_2( in_c_file_type in char, out_n_seqno_freeformat out integer, out_n_seqno_commaseprated out integer) is n_seqno_commaseprated    integer; n_seqno_freeformat        integer; begin if in_c_file_type ='F' THEN  SELECT message_counter.nextval INTO n_seqno_freeformat FROM dual; insert into temp_stroperations (record_id,OUTPUT_STR,INPROCESS_STR) values (n_seqno_freeformat,empty_clob(),empty_clob()); elsif in_c_file_type ='C' THEN  SELECT message_counter.nextval INTO n_seqno_commaseprated FROM dual; insert into temp_stroperations (record_id,OUTPUT_STR,INPROCESS_STR) values (n_seqno_commaseprated,empty_clob(),empty_clob()); else SELECT message_counter.nextval INTO n_seqno_freeformat FROM dual; insert into temp_stroperations (record_id,OUTPUT_STR,INPROCESS_STR) values (n_seqno_freeformat,empty_clob(),empty_clob()); SELECT message_counter.nextval INTO n_seqno_commaseprated FROM dual; insert into temp_stroperations (record_id,OUTPUT_STR,INPROCESS_STR) values (n_seqno_commaseprated,empty_clob(),empty_clob()); end if; out_n_seqno_freeformat        := n_seqno_freeformat; out_n_seqno_commaseprated    := n_seqno_commaseprated; end SP_GET_SEQNO_2; {code} ----- A part of java code I used to call the stored procedure is here. {code} String escapeString = "{call SP_GET_SEQNO_2 (? ? ?)}"; CallableStatement cstme = null; try { cstme = con.prepareCall(escapeString); cstme.setString(1, "F"); cstme.registerOutParameter(2, java.sql.Types.INTEGER); cstme.registerOutParameter(3, java.sql.Types.INTEGER); cstme.execute(); int seqNoFreeformat=0, seqNocommasepreted=0; seqNoFreeformat = cstme.getInt(2); seqNocommasepreted = cstme.getInt(3); System.out.println ("In ConvertXML.processStoredProcedure(), seqNoFreeformat= "+seqNoFreeformat+";seqNocommasepreted="+seqNocommasepreted); } catch (SQLException e) { //System.out.println ("In ConvertXML.processStoredProcedure(), SQLException: "+e); System.err.println("Message:"+e.getMessage()); System.err.println("Error code:"+e.getErrorCode()); System.err.println("SQL statement:"+e.getSQLState()); log.log(Level.INFO, log.getName() + " - SQLException : "+e); } {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    es5f2000 wrote:
    jschell wrote:
    That works?I dunno. The below definitely works, but like I said, I've only
    ever done it with one output parameter (and that has always
    been a ResultSet).
    String callableQuery = "{?= call my_package.my_call(?, ?)}"
    Yes I have done that and at least in terms of my code it wasn't just a result set.
    But not with two.

  • Calling Oracle Stored Procedure through COBOL

    I am calling a Oracle Stored Procedure through COBOL program. Here is the procedure that is in Oracle.
    PROCEDURE sp_sel_m_event_subs_profile (
    eventID IN EventIDTyp,
    subscribed IN NUMBER,
    v_profileRef OUT profileRefWithDSID_cv
    IS
    BEGIN
    sp_check_event_id(eventID);
    OPEN v_profileRef FOR
    SELECT
    sub.profile_i,
    ref.datasource_i,
    ref.primary_key_x
    FROM
    ccf_event_subscribe sub,
    ccf_profile_reference ref
    WHERE
    sub.event_i = eventID
    AND
    sub.is_subscribed_i = subscribed
    AND
    sub.profile_i = ref.profile_i;
    END sp_sel_m_event_subs_profile ;
    So while trying to call this procedure in COBOL program I am getting error as wrong number or types of arguments in call to 'SP_SEL_M_EVENT_SUBS_PROFILE'
    Here is the call statement in COBOL. I tried with many other options by adding some more fields but did not work.
    EXEC SQL EXECUTE
    BEGIN
    TWSUSER_OWN.PKG_CCF.SP_SEL_M_EVENT_SUBS_PROFILE
    (:EVENT-I, :SUBSCRIBED);
    END;
    END-EXEC
    Please someone let me know how should I pass arguments EVENT-I and SUBSCRIBED to this Procedure so that I will get PROFILE-I, DATASOURCE-I and PRIMARY-KEY-X
    Note: The above procedure is working good by other software. But there is no example as How to use Call statement through COBOL.
    Thanks

    Here is the cobol declaration of each variable.
    01 EVENT-I PIC X(06) VALUE SPACES.
    01 SUBSCRIBED PIC 9(01) VALUE ZEROS.
    01 PROFILE-I PIC X(08) VALUE SPACES.
    01 DATA-SRC-I PIC X(08) VALUE SPACES.
    01 PRIMARY-KEY-X PIC X(08) VALUE SPACES.
    I tried with this layout, but still not working
    01 EVENT-I PIC 9(06) VALUE ZEROS.
    01 SUBSCRIBED PIC 9(01) VALUE ZEROS.
    01 PROFILE-I PIC 9(08) VALUE ZEROS.
    01 DATA-SRC-I PIC 9(08) VALUE ZEROS.
    01 PRIMARY-KEY-X PIC 9(08) VALUE ZEROS.
    Here are some of them I tried.
    EXEC SQL EXECUTE
    BEGIN
    TWSUSER_OWN.PKG_CCF.SP_SEL_M_EVENT_SUBS_PROFILE
    ( :EVENT-I
    , :SUBSCRIBED
    , :PROFILE-I);
    END;
    END-EXEC
    EXEC SQL EXECUTE
    BEGIN
    TWSUSER_OWN.PKG_CCF.SP_SEL_M_EVENT_SUBS_PROFILE
    ( :EVENT-I
    , :SUBSCRIBED
    , :PROFILE-I
    , :DATA-SRC-I
    , :PRIMARY-KEY-X);
    END;
    END-EXEC
    EXEC SQL EXECUTE
    BEGIN
    TWSUSER_OWN.PKG_CCF.SP_SEL_M_EVENT_SUBS_PROFILE
    ( :EVENT-I
    , :SUBSCRIBED );
    END;
    END-EXEC
    EXEC SQL EXECUTE
    BEGIN
    TWSUSER_OWN.PKG_CCF.SP_SEL_M_EVENT_SUBS_PROFILE
    ( :PROFILE-I
    , :DATA-SRC-I
    , :PRIMARY-KEY-X);
    END;
    END-EXEC

  • Passing XMLType Data into oracle stored procedure using JDBC

    Hi Friends,
    I have requirement where my oracle stored procedure accepts XML file as an input. This XML File is generated in runtime using java, I need to pass that xml file using JDBC to oracle stored procedure. Please let me know the fesibile solution for this problem.
    Following are the environment details
    JDK Version: 1.6
    Oracle: 10g
    Server: Tomcat 6.x
    Thanks in Advance

    user4898687 wrote:
    I have requirement where my oracle stored procedure accepts XML file as an input. This XML File is generated in runtime using java, I need to pass that xml file using JDBC to oracle stored procedure. Please let me know the fesibile solution for this problem.As stated - no.
    A 'file' is a file system entity. There is no way to pass a 'file' anywhere. Not PL/SQL. Not java.
    Now you can pass a file path (a string) in java and to PL/SQL.
    Or you can pass xml data (a string) in java and to PL/SQL. For PL/SQL you could use eithe a varchar2, if the xml is rather small, or a blob/clob.

Maybe you are looking for