Issue in Calling PL/SQL packages using callable statement

Hi ,
I have the requirement of calling two pl/sql packages , After call of first package is successful , i need to pass the output of that first package as input to second package.
Since i have called both the packages in same method of AM, first package gets executed successfully but second package doesnt get the input values required from first package and results in error.
Looks like since commit is happening in the single session second package is passed with NULL values.
Need suggestion for proper way of calling pl/sql packages when second package is dependant on first one:
Code used inside AM Method:
if("PENDING_XXX".equals(regVORow.getRegStatus()))
regVORow.setRegStatus("VENDOR_CREATED");
getOADBTransaction().commit();
OracleCallableStatement cStmt = null;
OADBTransaction dbTxn = getOADBTransaction();
NUMBER vendor_id = new NUMBER(-1);
NUMBER vendor_site_id = new NUMBER(-1);
int vendor_id_value = -2000;
String vendor_number = null;
try
cStmt = (OracleCallableStatement)dbTxn.createCallableStatement("begin *XXB_POS_PVT.create_vendo*r( p_vendor_name => :1, p_supplier_reg_id => :2, p_vendor_id=>:3); end;", 1);
cStmt.setString(1, regVORow.getSupplierName());
cStmt.setNUMBER(2, new Number(Integer.parseInt(supplierId)));
cStmt.registerOutParameter(3, 4);
cStmt.execute();
vendor_id = cStmt.getNUMBER(3);
vendor_id_value = vendor_id.intValue();
catch(SQLException e)
throw new OAException(e.getMessage());
Number vendorId = new Number(vendor_id_value);
regVORow.setVendorId(vendorId);
if(vendorId != null)
vendor_number = getSupplierVendorNumber(vendorId);
getOADBTransaction().commit();
AsiPosSupplierOpCosVOImpl regOpCosVO = (AsiPosSupplierOpCosVOImpl)this.getAsiPosSupplierOpCosVO1();
AsiPosSupplierOpCosVORowImpl row = null;
int fetchedRowCount = regOpCosVO.getFetchedRowCount();
RowSetIterator createIter1 = regOpCosVO.createRowSetIterator("createIter1");
if(fetchedRowCount > 0)
createIter1.setRangeStart(0);
createIter1.setRangeSize(fetchedRowCount);
for(int i = 0; i < fetchedRowCount; i++)
row = (AsiPosSupplierOpCosVORowImpl)createIter1.getRowAtRangeIndex(i);
if(row.getApprovalStatus().equalsIgnoreCase("HEAD_APPROVED"))
try
oadbtransactionimpl.writeDiagnostics(this,"Creating Site - " + vendor_id_value+" "+row.getSupplierOpcoCode()+" "+supplierId,1);
cStmt = (OracleCallableStatement)dbTxn.createCallableStatement("begin *XXB_POS_PVT.create_vendor_sites*(p_supplier_reg_id => :1, p_vendor_id=>:2, p_opco_code=>:3, p_vendor_site_id=>:4); end;", 1);
cStmt.setNUMBER(1, new Number(Integer.parseInt(supplierId)));
cStmt.setNUMBER(2, new Number(vendor_id_value));
cStmt.setString(3,row.getSupplierOpcoCode());
cStmt.registerOutParameter(4, 4);
cStmt.execute();
vendor_site_id = cStmt.getNUMBER(4);
getOADBTransaction().commit();                                    
catch(SQLException e)
throw new OAException(e.getMessage());
createIter1.closeRowSetIterator();

Hi ,
There are some validation that can be performed from Entity level ( EO ) , you can go through them in Jdev guide .
It depends on the business requirement , not all validation can be performed from Entity level .
Let us know your business requirement , will try to clear your doubt .
--Keerthi                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • Calling a procedure/function in CO using Callable Statement

    Hi,
    Please help me in understanding this:
    __method1__
    BEGIN
    :1 := Package.Function(
    param1 => :2"
    ,param2 => :3"
    ,param3 => :4"
    ,param4 => :5"
    END;
    method2
    BEGIN
    Package.Function(:1, :2, :3, :4, :5);"
    END;
    Whats the significance of using method1?
    I have seen the callable statements written as in method1 but, the parameters passed are not in order and not all params are passed.
    When i tried writing similar code, I got "Invalid Column Index" exception. Please let me know how to overcome this.
    Thanks

    Hi,
    You can call a function using Callable Statement as
    public String checkprimarycontact(String pri_loc_id,String org_id,String party_id)
    int p_location_id = 0;
    int p_org_id = 0;
    int p_party_id = 0;
    p_location_id = Integer.parseInt(pri_loc_id);
    p_org_id = Integer.parseInt(org_id);
    p_party_id = Integer.parseInt(party_id);
    String priflag = "";
    try
    Connection conn1 = getOADBTransaction().getJdbcConnection();
    CallableStatement cstmt1 = conn1.prepareCall("{? = call GET_PRIMARY_FUNCTION(?,?,?)}");
    cstmt1.registerOutParameter(1,Types.VARCHAR);
    cstmt1.setInt(2,p_location_id);
    cstmt1.setInt(3,p_org_id);
    cstmt1.setInt(4,p_party_id);
    cstmt1.execute();
    priflag = cstmt1.getString(1);
    catch(Exception e1)
    e1.printStackTrace();
    return priflag;
    Thanks,
    Gaurav

  • Call PL/SQL packages in JSP

    I would like to call PL/SQL packages in JSP. I am new in Java world. So, kindly tell code about to call packages from oracle. I will be thankful to all those experts who will help a student such as me.
    I will be anxious to your response.
    plz
    plz

    Dear sir,
    I am really thankful to you. I have to verify password in oracle.
    Id and password verification is writting in package's function. Id and password are oracle users. Like scott in Oracle. I think it is possible.
    Kindly assist me.
    If u feel easy then kindly contact me at [email protected] or tell me your email address. Plz

  • Calling pl/sql package on different database in process flow

    Hi there
    Have a process flow which calls procedure on different database. This procedure truncates a table on the remote database.
    Please could somebody confirm we would need to set up dblinks from the owf_mgr schema to the remote database.
    New to wokflow - am i Correct in assuming the process flows run on the owf_mgr
    rather than the control center owbrt.
    Many Thanks

    Hi there,
    Thanks for the reply.
    If my understanding is correct I could have a procedure as follows.
    hkeeping.trunc_table@dblinkname('TABLE_NAME');
    Is this the case?
    Another alternative was to call directly the transformation in the process flow
    e.g. we have pl/sql package on remote database whioch truncates the remote table.
    When we try this with same procedure on same databas as owb user exists on then works fine.
    However on remote database get message below. Does this mean anything to you? How could we sort this?
    RPE-01003: An infrastructure condition prevented the request from completing.
      TEMP_PLOW:TRUNC_TABLE
    Error
    RPE-01038: Failed to evaluate expression null. Please modify the expression, redeploy and retry again.
       TEMP_PLOW:TRUNC_TABLE
    Error
    RPE-01003: An infrastructure condition prevented the request from completing.
       TEMP_PLOW:TRUNC_TABLE
    Error
    RPE-02226: Cannot test Control Center user REMOTEUSERNAME. This user must match the login credentials of the deployment location.
       TEMP_PLOW:TRUNC_TABLE
    Error
    ORA-01937: missing or invalid role name
    Many Thanks

  • Calling PL/SQL Package in the same connection

    I have a PL/SQL Package MYPCKG, stored in the database, with a function GETDFLT(). I need it to initiate the default values for fields (Attributes) of an EntityImpl Object (EOImpl) in its create method.
    I used JPublisher to generate a wrapper class of the package, named MyPckg. It has three Constructors: MyPckg (),MyPckg (ConnectionContext c) and MyPckg (Connection c). The problem is that I dont know how to use the existing connection of EntityImpl object (or of ApplicationModuleImpl) to create a new MyPckg object.
    The example below makes a new connection to database:
    public class EOImpl extends oracle.jbo.server.EntityImpl {
    public void create(AttributeList attributeList) {
    Oracle.connect("jdbc:oracle:thin:@host:1521:DB1", "user", "pwd");
    MyPckg dflts = new MyPckg ();
    setField1 (dflts.getDflt ());
    I believed that I can do it through DBTransaction but I couldnt find a relationship between DBTransaction and java.sql.Connection or sqlj.runtime.ConnectionContext.
    In MetaLink, I found a couple of items with the same problem, but they appear not to be answered.
    Thanks in advance
    Mirza
    null

    Thank you very much for replay.
    The suggested technique uses JDBC. In fact, I wanted to use BC4J Entity Object and embedded SQLJ (generated by JPublisher). In the JDeveloper Help Topic Embedding SQL in Java Programs with JDBCstays: JDBC provides Java programs with low-level access to databases. If your application or applet uses purely static SQL, where you know the database schema at compile time, you should consider using SQLJ instead. So what I am looking for is how to get a java.sql.Connection or sqlj.runtime.ConnectionContext or sqlj.runtime.ref.DefaultContext Object from some BC4J Object (ApplicationModule or Entity).
    Thanks in advance
    Mirza

  • How to use Callable statements.

    Hi.
    I'm just new in using JSP. I just want to ask how to call stored procedures (ex. from SQL Server) using the Callable statements. A sample code will be very helpful......
    Ex. I have these parameters for my stored proc:
    name = "sentiments"; //value will always vary
    add = "NJ"; //value will always vary
    stored proc name is => usp_updateFile
    Thank you very much for your time.

    See http://developer.java.sun.com/developer/onlineTraining/Database/JDBC20Intro/JDBC20.html#JDBC2013_4

  • How to return Multiple ResultSets Using Callable Statement

    hi everybody,
    while i was working with callable statements i came across a problem of how to fetch Multiple Resultsets by means of Stored Procedures written for tables in Oracle.
    If any one can help me, pls do help me with a detailed explanation, and if possible do get me a example source code too.
    khumaar

    I have a similar problem with oracle and jdbc:
    I want to send a sql query like:
    sqlQuery = "select n1, n2 from table1; select n1, n2
    from table2"
    I used a prepared statement, but when I call
    .execute(sqlQuery)
    oracle doesn't like this,
    can someone help on this?Try putting a begin/end around it. Play with the syntax first in sqlplus.
    You do realize that you MUST extract using the syntax for extracting multiple result sets correct? It will NOT work as one result set.

  • Statement closed when using callable statements with oracle xe

    hi all, i've got this problem with oracle express edition 10g. I am using also oc4j v10.1.2.0.2. When working with a normal oracle database it was working fine (i think the code was the same, it's some time since i last tried, but you can see the code is very simple).
    So i just create a callable statement like this:
    CallableStatement cs = con.prepareCall(sentencia.toString(), ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE, ResultSet.HOLD_CURSORS_OVER_COMMIT);
    and then when trying to access the statement to register an out parameter like this
    cs.registerOutParameter(1, parámetros[0].getTipo());
    it gives this error:
    java.sql.SQLException: Statement was closed
    It's puzzling me because, as i said before, i think the same code was working ok with a normal oracle database.
    Any idea what can it be?
    cheers

    Ah okay, sorry I've re-read your post.
    I believe you need to create a clob object that encapsulates your xml file.
    I've never done this but I would image it involves creating a class that implements the clob interface and passing an instantiation of this class to the callablestatement.
    Let me know how you get on.

  • Call PL/SQL Package to Create DB User and assign Privileges

    Hi All,
    I'm sure this has been covered before but I couldn't find anything relevant....
    I'm calling a PL/SQL Process from within an Apex (version 2.0) Page, that ultimately Creates a New DB user.
    I am receiving an ORA-01031: insufficient privileges error. My Application User and the Package owner both have privileges to Create a DB user.
    What am I missing?
    Thanks,
    Mike

    Never, ever grant additional privileges to the apex_public_user account. It achieves nothing and makes the account over-privileged. The only privilege it needs is CREATE SESSION.
    Mike - Your application's parsing schema (I assume that's the package owner) needs to be granted privileges directly and not through roles. I don't know what you mean by your application user's privileges. Those users are not database accounts (unless you are using a dedicated DAD, etc.).
    Scott

  • Issue with Calling Rest Web Service using Designer workflow

    Hello all
    I am calling a Rest web service- HTTP Post (yammer API)-
    http://www.yammer.com/api/v1/messages.json?data-app-id=myappid&group_id=groupid&body=MyPost in yammer  using sharepoint 2013 designer workflow.(My Requirement is to create a yammer post when I approve an item in sharepoint).
    but my header parameters are creating issue while executing workflow.
    Currently I have these many parameters configured in request header
    Accept -application/json; odata=verbose
    Content Type -application/json; odata=verbose
    content length header -255
    Is there anything wrong or I need to additionally pass some values in call web service action?
    Any help would be highly appreciated

    Hi Mahesh,
    One you are missing is authentication token or credentials.
    Please refer to the following articles.
    http://www.cleverworkarounds.com/2014/02/05/tips-for-using-spd-workflows-to-talk-to-3rd-party-web-services/
    A Series of articles related to Web Service in SPD Workflow
    Trials or tribulation?
    Inside SharePoint 2013 workflows–Part 1
    Trials or tribulation?
    Inside SharePoint 2013 workflows–Part 2
    Trials or tribulation?
    Inside SharePoint 2013 workflows–Part 3
    Trials or tribulation?
    Inside SharePoint 2013 workflows–Part 4
    Trials or tribulation?
    Inside SharePoint 2013 workflows–Part 5
    Trials or tribulation?
    Inside SharePoint 2013 workflows–Part 6
    Trials or tribulation?
    Inside SharePoint 2013 workflows–Part 7
    Trials or tribulation?
    Inside SharePoint 2013 workflows–Part 8
    Trials or tribulation?
    Inside SharePoint 2013 workflows–Part 9
    Trials or tribulation?
    Inside SharePoint 2013 workflows–Part 10
    Trials or tribulation?
    Inside SharePoint 2013 workflows–Part 11
    Trials or tribulation?
    Inside SharePoint 2013 workflows–Part 12
    Please don't forget to mark it answered, if your problem resolved or helpful

  • How can I call functions in packages using flash builder?

    a new guy in flash developnet, I need to find out a way to import multiple packages into frames and call functions. I know how to import packages, but an error occurs error 1120 : access of undefined property. How can ı solve them?
    Is there any easy way to add Mediapomise object to the stage form the package? "addChild(loader);" does not work? or ı do not know whether it works or not, ı could not see the photo that ı took from camerauı object in android.
    thank you 

    I need to find out a way to import multiple packages into frames
    Usually, no matter where you use any classes of any package, the imports happen always in the beginning.
    If you have a specific problem with flashbuilder you should post in this forum:
    http://forums.adobe.com/community/flash_builder

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

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

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

  • How to call stored procedure in SYBASE using callable statement

    Hi all,
    Im using jdbc code to execute a stored procedure in sybase but while running the code i get an error saying
    java.sql.SQLException: JZ0R2: No result set for this query.
    at com.sybase.jdbc2.jdbc.ErrorMessage.raiseError(ErrorMessage.java:506)
    at com.sybase.jdbc2.jdbc.SybStatement.queryLoop(SybStatement.java:1552)
    at com.sybase.jdbc2.jdbc.SybStatement.executeQuery(SybStatement.java:1522)
    at com.sybase.jdbc2.jdbc.SybCallableStatement.executeQuery(SybCallableStatement.java:76)
    but when i execute the same procedure in sybase it returns some result but i know its not in resultset format .I want to know is anyone experienced same problem in their side.
    My question is how to obtain the result which is not in the format result set obtained by executing the stored procedure.
    Thanks n advance
    work machine

    Check this post out:
    http://forum.java.sun.com/thread.jspa?threadID=638768&messageID=3785982
    But I think you should be getting results right? What do you mean you want it in a format other than resultset?

  • PL/SQL package using utl_file.fopen gets invalid_path error

    The init.ora file has utl_file_dir = * in it. When writing a package trying to utilize the utl_file.fopen the invalid_path error always occurs. What is the fix to resolve the path error?

    create or replace package body TEST_UTL_FILE is
    -- Purpose : Sample package that uses UTL_FILE procedure(s)
    -- ===========================================================================================================
    -- Process Request
    -- ===========================================================================================================
    procedure Process_Request is
    -- Local Variable(s)
    v_file_id sys.UTL_FILE.FILE_TYPE;
    v_buffer varchar2(32767);
    begin
    v_file_id := sys.utl_file.FOPEN('D:\Oracle\XMLFiles',
    'Sample1.xml',
    'R');
    sys.utl_file.GET_LINE(v_file_id, v_buffer);
    return;
    exception
    -- Error number -29280
    WHEN UTL_FILE.INVALID_PATH THEN
    RAISE_APPLICATION_ERROR(-20001, 'invalid_path');
    -- Error number -29281
    WHEN UTL_FILE.INVALID_MODE THEN
    RAISE_APPLICATION_ERROR(-20001, 'invalid_mode');
    -- Error number -29282
    WHEN UTL_FILE.INVALID_FILEHANDLE THEN
    RAISE_APPLICATION_ERROR(-20001, 'invalid_filehandle');
    -- Error number -29283
    WHEN UTL_FILE.INVALID_OPERATION THEN
    RAISE_APPLICATION_ERROR(-20001, 'invalid_operation');
    -- Error number -29284
    WHEN UTL_FILE.READ_ERROR THEN
    RAISE_APPLICATION_ERROR(-20001, 'read_error');
    -- Error number -29285
    WHEN UTL_FILE.WRITE_ERROR THEN
    RAISE_APPLICATION_ERROR(-20001, 'write_error');
    -- Error number -29286
    WHEN UTL_FILE.INTERNAL_ERROR THEN
    RAISE_APPLICATION_ERROR(-20001, 'internal_error');
    -- Error number -29287
    WHEN UTL_FILE.invalid_maxlinesize THEN
    RAISE_APPLICATION_ERROR(-20001, 'invalid_maxlinesize');
    -- Error number -29288
    WHEN UTL_FILE.invalid_filename THEN
    RAISE_APPLICATION_ERROR(-20001, 'invalid_filename');
    -- Error number -29289
    WHEN UTL_FILE.access_denied THEN
    RAISE_APPLICATION_ERROR(-20001, 'access_denied');
    -- Error number -29290
    WHEN UTL_FILE.invalid_offset THEN
    RAISE_APPLICATION_ERROR(-20001, 'invalid_offset');
    -- Error number -29291
    WHEN UTL_FILE.delete_failed THEN
    RAISE_APPLICATION_ERROR(-20001, 'delete_failed');
    -- Error number -29292
    WHEN UTL_FILE.rename_failed THEN
    RAISE_APPLICATION_ERROR(-20001, 'rename_failed');
    -- Error number unknown
    WHEN OTHERS THEN
    RAISE_APPLICATION_ERROR(-20001, 'other_error');
    end Process_Request;
    end TEST_UTL_FILE;
    Errors:
    ORA-20001: invalid_path
    ORA-06512: at "SYS.TEST_UTL_FILE", line 21
    ORA-06512: at line 3

  • Problem with function call from sql when using distinct

    I have the following problem.
    SELECT DISTINCT colA from tabA where my_function(colB) = 'TRUE'
    This statement will return a handfull of results from a table with 70k + records. The function takes about 0.5 secs to execute.
    How do i force the optimizer to do the select distinct first then execute the function on the results rather than execute the function for every single line first?
    Thanks in advance
    Keith

    Let's compare some of those methods:
    michaels>  CREATE OR REPLACE FUNCTION my_function (tr VARCHAR2)
       RETURN VARCHAR2
    AS
    BEGIN
       DBMS_APPLICATION_INFO.set_client_info (SYS_CONTEXT ('userenv','client_info') + 1);
       IF LOWER (tr) LIKE '%name%'
       THEN
          RETURN 'TRUE';
       ELSE
          RETURN 'FALSE';
       END IF;
    END my_function;
    Function created.
    michaels>  CREATE TABLE taba AS SELECT object_id cola ,object_name colb FROM all_arguments
    Table created.
    michaels>  SELECT COUNT(*) FROM taba
      COUNT(*)
         78786
    michaels>  EXEC dbms_application_info.set_client_info(0)
    michaels>  SELECT DISTINCT colA from tabA where my_function(colB) = 'TRUE'
    167 rows selected.
    michaels>  SELECT SYS_CONTEXT ('userenv','client_info') ci FROM dual
    CI   
    78786
    michaels>  EXEC dbms_application_info.set_client_info(0)
    michaels>  SELECT DISTINCT cola FROM (SELECT ROWNUM r, t.* FROM (SELECT DISTINCT cola, colb FROM taba) t)
              WHERE my_function (colb) = 'TRUE'
    167 rows selected.
    michaels>  SELECT SYS_CONTEXT ('userenv','client_info') ci FROM dual
    CI   
    14225
    michaels>  EXEC dbms_application_info.set_client_info(0)
    michaels>  SELECT DISTINCT cola FROM taba WHERE (SELECT my_function (colb) FROM DUAL) = 'TRUE'
    167 rows selected.
    michaels>  SELECT SYS_CONTEXT ('userenv','client_info') ci FROM dual
    CI   
    14281
    michaels>  EXEC dbms_application_info.set_client_info(0)
    michaels>  SELECT DISTINCT cola FROM taba WHERE EXISTS (SELECT ROWNUM FROM dual WHERE my_function (colb) = 'TRUE')
    167 rows selected.
    michaels>  SELECT SYS_CONTEXT ('userenv','client_info') ci FROM dual
    CI   
    13913
    michaels>  EXEC dbms_application_info.set_client_info(0)
    michaels>  WITH temp AS
      (SELECT DISTINCT colA, colB FROM tabA)
    SELECT DISTINCT colA FROM temp WHERE  my_function(colB) = 'TRUE'
    167 rows selected.
    michaels>  SELECT SYS_CONTEXT ('userenv','client_info') ci FROM dual
    CI   
    78786
    michaels>  EXEC dbms_application_info.set_client_info(0)
    michaels>  WITH temp AS
      (SELECT colB, my_function(colB) func FROM (SELECT DISTINCT colB FROM   tabA))
    SELECT DISTINCT colA FROM tabA a, temp t WHERE  a.colB = t.colB AND t.func = 'TRUE'
    michaels>  SELECT SYS_CONTEXT ('userenv','client_info') ci FROM dual
    CI   
    78786 The combination with exists, rownum and dual gives the least calls to the function.

Maybe you are looking for

  • Search in training and event management

    HI TEM gurus, I having issue related to search functionlity for TEM. I have created catalog in backend but when i run in ITS ....PV7I .. system is not giving any result for search function. I am not able to find the cause.. is there any system settin

  • Deploying a Web Service w/o WAR files

    I've seen several posts on this (including a few from me about a year ago), but I haven't seen anything from Sun on how to do this. In JWSDP 1.1 xrpcc would create a *Config.properties file, and I would add the following to my web.xml file           

  • Finder won't launch at startup

    What's the best way out of a problem which stops the Finder launching at startup? I have no idea why my recently clean-installed system seems to spontaneously start corrupting in the middle of innocuous tasks but here's my own grisly log of this issu

  • Can't update itunes my old version is newer than the release today

    I have had this problem twice now. And it is really starting to get on my nerves. Every time apple puts out an update for itunes it states that the current one on my computer is newwer than the version that is was just released 2 days ago (today marc

  • Program to update BOM by CSAP_MAT_BOM_CREATE as error KEY_INCOMPLETE coming

    Hi to all, Can any one provide me sample program to update BOM via Function Module CSAP_MAT_BOM_CREATE. As i already have created the program , but run time error is coming KEY_INCOMPLETE for CSAP_MAT_BOM_CREATE. as i have already search the SDN , bu