DML in stored procedure

Greetings:
If I simply want run a DML statement containing a variable, do I need to use the DBMS_SQL package or is there an easier way. For example:
PROCEDURE test_procedure IS
data_table_name VARCHAR2(20) := 'Table1';
BEGIN
DELETE FROM data_table_name;
COMMIT;
END;
When I do this, Oracle says I must define date_table_name. How do I get it to extract the value of the variable to use as the table name?
Thanks,
Chris

You definitely have to use dbms_sql when you wish to have the table you work on defined at runtime.
One more piece of advice: instead of using deleate from tablename (with no where clause), you may use truncate tablename, which should be executed faster.
Regards,
BD

Similar Messages

  • Best approach for performing DMLs using stored procedures

    Hi,
    I have a really general question and would like to hear your say about this.
    I want my application to manipulate or read data using stored procedures (or packages in that manner) and not directly using queries against the DB.
    Let's say I have a table with many columns:
    create table test (pkid number(10),col1 varchar2(30), col2 number(10), col3 date,...);For such a DML procedure, is it best to do something like
    procedure do_update(i_pkid IN number,i_col1 IN varchar2, i_col2 IN number, i_col3 IN date,...) as
    begin
       update test
       set col1=i_col1,
            col2=i_col2,
            col3=i_col3...
       where pkid=i_pkid;
       commit;
    end;Or do a selective update, meaning update only a certain column every time, given only 1 column actually changes? (and how to do that - separate procedures for each column? [columns can be nulls])
    Also, is it better to work with test.col1%type instead of specifying the data type in the procedure?
    And one last question - If I have a table with 100 columns and I don't want to create a procedure with 100 parameters - the best approach would be to use a record?
    I just need to be set on the way I start implementing things in order to do it well from the start.
    Many thanks.
    Edited by: Pyrocks on Nov 17, 2010 1:58 PM

    Pyrocks wrote:
    One last clarification (although it may be more related to c/c++ developers - maybe one of you will know):
    We are working with C++ and VB against a SQLServer and my part is to translate all the existing procedures to Oracle in order to migrate the application to work with Oracle DB.
    The existing procedures use an IN parameter for each column in the table and I would really like to use rowtype like you mentioned.
    Since I'm not a c/c++/vb developer - is there an easy way of working with such types, or even User-Defined Types, from c/c++/vb (as in passing a rowtype record from c++ to a SP ?)
    I'm not looking for the actual way - just want to know how hard it would be and how much code needs to be changed in order to be able to convince the developers that this is the RIGHT way to work.
    PS. none of our developers have experience with ORACLE so they wouldn't know the answer...Not actually an Oracle server-side (SQL language or PL/SQL language) question - but a client one. And it has been a long time since I wrote a fat client using C/C++ or Delphi.
    The OCI (<i>Oracle Call Interface</i>) supports advance (user defined) SQL data types. Has since Oracle 8i. So in that respect, yes the client can support custom SQL data types.
    How well it does depends entirely on that client language's features wrt OCI integration. For example, Delphi 4 was release around Oracle 8i and supported custom SQL types. I would expect that most languages today (like Java and C#) will provide support for it.
    As for usiong +%ROWTYPE+ - this is a PL/SQL clause as far as I know. Unsure whether it is supported by the OCI. What could support it is a pre-compiler like Pro*C. These enable you to mix pseudo SQL source code with client language source code. The pre-compilation step then replaces the pseudo SQL code with native client language calls to the OCI. The code is then compiled by that client language's compiler. Pre-compilers can pull all kinds of interesting "tricks" with their pseudo SQL code support.
    The best would be to consult the applicable client language's manuals that describe the interface it supports (via OCI) to Oracle.

  • How to simulate a dml error in order to test try-catch code block inside a stored procedure

    Hi,
    What would be the easiest way to simulate a dml error in order to test a try catch block.
    I would like to do it with a simple command from outside the stored procedure if possible.
    I tried dropping the table that was updated but it hangs
    Thanks,
    Dani

    Dropping the table that is the target of the procedure will give you an unpleasant surprise: the CATCH block will not fire. To wit, errors like missing tables can only be caught in outer scopes, but not in the procedure where the error occurs.
    But you would add a fake constraint to a table which causes the update to fail. You need to do this in advance, not while running the procedure.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • DML visibility in stored procedures called via JDBC

    Hello,
    I have two stored procedures, A and B. Proc A inserts Q into table X. Proc B selects Q from table X to insert it into table Y. Neither procedure does a COMMIT.
    My Java class executes Proc A and then Proc B within a transaction (autocommit is false). But Proc B fails to select Q from table X with the No Data Found error, apparently unable to see the recently inserted Q.
    If these two procedures are called from a SQL*Plus block, everything succeeds.
    Does anyone have a clue about what I am missing? All my DML should be visible to my session.
    Thank you in advance for any suggestions.
    - CJ

    Thank you, Joe, for your reply!
    To the best of my knowledge, all of my stored procedure calls are being made from the same connection so I can rollback everything if necessary. I have not explicitly closed the connection between calls. The debugger indicates my connection session id never changes across calls.
    Do you know of any JDBC trace tools that might help me verify my connections? I've enabled logging with oracle.jdbc.driver.OracleLog.setTrace(true) but it doesn't really give me specific connection information - at least not that I can tell. :)
    Thanks!
    Cori

  • Java Stored Procedure functions in SQL DML - multiple invocations

    When running a java stored procedure as part of a DML statement the procedure is invoked 10-15 times for each row that is updated.
    For example:
    Update mytable set mycolumn = myjsp(somecolumn);
    I undertand that this was a known bug with the JDBC driver. Has it been fixed? Is there a workaround?
    We are using 8.1.6 on NT 4
    Thanks
    Julian

    Hello ,
    I tried here, and it seems to call the function once for each row
    eg :
    package package90;
    public class Class1 extends Object {
    public int get_data(int i)
    return i+10;
    Published the get_data function as
    myproject67.get_data
    SQL> connect scott/tiger@orcl8i
    Connected.
    SQL> set serveroutput on
    SQL> exec dbms_java.set_output(5000);
    PL/SQL procedure successfully completed.
    SQL> select * from test_java;
    NO1
    10
    10
    SQL> insert into test_java values (20);
    1 row created.
    SQL> select * from test_java;
    NO1
    10
    10
    20
    SQL> update test_java set no1=myproject67.get_data(no1);
    Called
    Called
    Called
    3 rows updated.
    SQL> select * from test_java;
    NO1
    20
    20
    30
    SQL>

  • Invoking stored procedures containing DML statements

    Hi, I'm invoking a stored procedure that inserts the form record into the base tables, however I do not want to insert duplicates and if I try to do a count on that record from forms I get 0 records until the session is commited. I assume the insert was done in another session? is there a way around this? Thanks.

    thanks, I found that the reason I was getting 0 records is because I'm calling a db package to insert the record using the on-insert trigger.. forms is only populating the table once I try to commit all the records bypassing my when-validate-record trigger.. so I now call my check_unique procedure from the insert procedure and raise an application exception from the db procedure...seems to work.

  • Can not delete data from table which is queried in my stored procedure

    Hi,
    Anyone knows how to fix it:
    I have a table. In a stored procedure, I have a simple query running on this table.
    When I want to delete one record from that table, I got error message:
    ORA-04091: table *** is mutating, trigger/function may not see it.
    Thanks first.

    Rick, the only time you should get a mutating table error is when a trigger is involved. FK problems have separate error codes (and would be a different problem than the one that started this thread). Using a DBA id check all the tables subject to DML by your function and by whatever calls your function for triggers. Only the owner or a DBA can see the existence of triggers on a non-owned table. This has caused some of the developers I work with to think tables that had triggers do not have them since they do not work under the owning or a DBA ID.
    By your description of what you are trying to do in the function we do that all the time without problem.
    How large is the function? How/When is it called?
    Mark D Powell

  • Unable to use the values returned by a PL/SQL stored procedure in a XSQL page

    Hi,
    I've been messing around with XML and XSQL in particular. I was trying to write a xsql page to display a report with account totals...I have the following .xsql which calls a PL/SQL stored procedure :
    <?xml version="1.0"?>
    <xsql:query connection="pfcdm" xmlns:xsql="urn:oracle-xsql">
    <xsql:set-session-param name="zasset_total" value="100">
    <xsql:dml connection="pfcdm">
    rraman.sp_vw_id(zasset_total,zinvm_total,zmkt_val);
    </xsql:dml>
    </xsql:set-session-param>
    select 'Asset total is {@zasset_total}' as "ASSET_TOTAL" from dual
    </xsql:query>
    My procedure sp_vw_id returns the values that it should. But, I am not sure how to declare variables within a page, and to output the return values. There is very scanty documentation on the usage of <xsql:dml> or <xsql:ref-cursor-function>.
    Any response would be greatly appreciated.
    Thanks,
    Raja

    Here is the example from the Oracle9i (complete rewrite) of the XSQL Chapter in our Oracle documentation.
    Question
    I using <xsql:dml> to call a stored procedure which has one OUT parameter, but I was not able to see any results. The executed code results in the following statement:
    <xsql-status action="xsql:dml" rows="0"/>
    Answer
    You cannot set parameter values by binding them in the position of OUT variables in this release using <xsql:dml>. Only IN parameters are supported for binding. You can create a wrapper procedure that constructs XML elements using the HTP package and then your XSQL page can invoke the wrapper procedure using <xsql:include-owa> instead.
    For an example, suppose you had the following procedure:
    CREATE OR REPLACE PROCEDURE addmult(arg1 NUMBER,
    arg2 NUMBER,
    sumval OUT NUMBER,
    prodval OUT NUMBER) IS
    BEGIN
    sumval := arg1 + arg2;
    prodval := arg1 * arg2;
    END;You could write the following procedure to "wrap" it, taking all of the IN arguments that the procedure above expects, and then "encoding" the OUT values as a little XML datagram that you print to the OWA page buffer:
    CREATE OR REPLACE PROCEDURE addmultwrapper(arg1 NUMBER, arg2 NUMBER) IS
    sumval NUMBER;
    prodval NUMBER;
    xml VARCHAR2(2000);
    BEGIN
    -- Call the procedure with OUT values
    addmult(arg1,arg2,sumval,prodval);
    -- Then produce XML that encodes the OUT values
    xml := '<addmult>'&#0124; &#0124;
    '<sum>'&#0124; &#0124;sumval&#0124; &#0124;'</sum>'&#0124; &#0124;
    '<product>'&#0124; &#0124;prodval&#0124; &#0124;'</product>'&#0124; &#0124;
    '</addmult>';
    -- Print the XML result to the OWA page buffer for return
    HTP.P(xml);
    END;This way, you can build an XSQL page like this that calls the wrapper procedure:
    <page connection="demo" xmlns:xsql="urn:oracle-xsql">
    <xsql:include-owa bind-params="arg1 arg2">
    BEGIN addmultwrapper(?,?); END;
    </xsql:include-owa>
    </page>This allows a request like:
    http://yourserver.com/addmult.xsql?arg1=30&arg2=45
    to return an XML datagram that reflects the OUT values like this:
    <page> <addmult><sum>75</sum><product>1350</product></addmult>
    </page>

  • Need Help With a Stored Procedure

    Help With a Stored Procedure
    Hi everyone.
    I am quite new relative to creating stored procedures, so I anticipate that whatever help I could get here would be very much helpful.
    Anyway, here is my case:
    I have a table where I need to update some fields with values coming from other tables. The other tables, let us just name as tblRef1, tblRef2 and tblRef3. For clarity, let us name tblToUpdate as my table to update. tblToUpdate has the following fields.
    PlanID
    EmployeeIndicator
    UpdatedBy
    CreatedBy
    tblRef1, tblRef2 and tblRef3 has the following fields:
    UserName
    EmpIndicator
    UserID
    In my stored procedure, I need to perform the following:
    1. Check each row in the tblToUpdate table. Get the CreatedBy value and compare the same to the UserName and UserID field of tblRef1. If no value exists in tblRef1, I then proceed to check if the value exists in the same fields in tblRef2 and tblRef3.
    2. If the value is found, then I would update the EmployeeIndicator field in tblToUpdate with the value found on either tblRef1, tblRef2 or tblRef3.
    I am having some trouble writing the stored procedure to accomplish this. So far, I have written is the following:
    CREATE OR REPLACE PROCEDURE Proc_Upd IS v_rec NUMBER;
    v_plan_no tblToUpdate.PLANID%TYPE;
    v_ref_ind tblToUpdate.EMPLOYEEINDICATOR%TYPE;
    v_update_user tblToUpdate.UPDATEDBY%TYPE;
    v_created_by tblToUpdate.CREATEDBY%TYPE;
    v_correct_ref_ind tblToUpdate.EMPLOYEEIDICATOR%TYPE;
    CURSOR cur_plan IS SELECT PlanID, EmployeeIndicator, UPPER(UpdatedBy), UPPER(CreatedBy) FROM tblToUpdate;
    BEGIN
    Open cur_plan;
         LOOP
         FETCH cur_plan INTO v_plan_no, v_ref_ind, v_update_user, v_created_by;
              EXIT WHEN cur_plan%NOTFOUND;
              BEGIN
              -- Check if v_created_by has value.
                   IF v_created_by IS NOT NULL THEN
                   -- Get the EmpIndicator from the tblRef1, tblRef2 or tblRef3 based on CreatedBy
                   SELECT UPPER(EmpIndicator)
                        INTO v_correct_ref_ind
                        FROM tblRef1
                        WHERE UPPER(USERNAME) = v_created_by
                        OR UPPER(USERID) = v_created_by;
                        IF v_correct_ref_ind IS NOT NULL THEN
                        -- Update the Reference Indicator Field in the table TRP_BUSPLAN_HDR_T.
                             UPDATE TRP_BUSPLAN_HDR_T SET ref_ind = v_correct_ref_ind WHERE plan_no = v_plan_no;
                        ELSIF
                        -- Check the Other tables here????
                        END IF;
                   ELSIF v_created_by IS NULL THEN
                   -- Get the EmpIndicator based on the UpdatedBy
                        SELECT UPPER(EmpIndicator)
                        INTO v_correct_ref_ind
                        FROM tblRef1
                        WHERE UPPER(USERNAME) = v_update_user
                        OR UPPER(USERID) = v_created_by;
                        IF v_correct_ref_ind IS NOT NULL THEN
                        -- Update the Reference Indicator Field in the table TRP_BUSPLAN_HDR_T.
                             UPDATE TRP_BUSPLAN_HDR_T SET ref_ind = v_correct_ref_ind WHERE plan_no = v_plan_no;
                        ELSIF
                        -- Check the Other tables here????
                        END IF;
                   END IF;
              END;
         END LOOP;
         CLOSE cur_plan;
         COMMIT;
    END
    Please take note that the values in the column tblToUpdate.UpdatedBy or tblToUpdate.CreatedBy could match either the UserName or the UserID of the table tblRef1, tblRef2, or tblRef3.
    Kindly provide more insight. When I try to execute the procedure above, I get a DATA NOT FOUND ERROR.
    Thanks.

    Ah, ok; I got the updates the wrong way round then.
    BluShadow's single update sounds like what you need then.
    I also suggest you read this AskTom link to help you see why you should choose to write DML statements before choosing to write cursor + loops.
    In general, when you're being asked to update / insert / delete rows into a table or several tables, your first reaction should be: "Can I do this in SQL?" If you can, then putting it into a stored procedure is usually just a case of putting the sql statement inside the procedure header/footers - can't really get much more simple than that! *{;-)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • EJB 3.0 Persistence API and Stored Procedures

    Does the EJB 3.0 Persistence API in any way prescribe or facilitate the use of Stored Procedure calls? Given the recent popularity of using (database) server APIs consisting of Stored Procedures that are addressed by ORM frameworks for performing the DML operations and of course the general usefulness of stored procedures for specific data related operations, there definitely is a need for clarity on using the straightforward Persistence operations in combination with calls to Stored Procedures. Can we use the Native Query for executing CallableStatements? Can we get to a Connection instance from the EntityManager? Can we easily use the results from a Stored Procedure invocation to refresh our Domain Objects - or is that all application logic in which the EntityManager cannot help us?
    If the spec does not help us at this point, do you know how TopLink will deal with this topic?
    Thanks for any help you can give me!
    Best regards,
    Lucas Jellema

    I'm am also interested in a response to this post. I've just upgraded to JDeveloper 10.1.3.1 and am interested in making calls to stored procedures.
    I've found examples of just creating my own session beans but it seems I would have to hard code the datasource name. Does anyone know if I can get around this using the entity manager supplied by the tool?
    thanks,
    Dan

  • Receive java.lang.NullPointerException (JCA-12563) on SCA with Stored Procedure dbAdapter (SOA Suite 12.1.3)

    Hi,
    I'm new to the Oracle SOA Suite and have been creating very simple SCA WebServices (async and sync) prototypes to INSERT, UPDATE and Poll Oracle 9i and 11g databases. So far, everything works and passes the tests from EM.
    I cannot get the Stored Procedure WebService to test successfully as I receive the error message below regardless of JNDI configuration for XA, non-XA, Last Logging Resource, Support Global Transactions,PlatformClassName, etc...  The Outbound Connection Pool is setup correctly as the other DML tests have worked fine.
    BINDING.JCA-12563
    Exception occurred when binding was invoked.
    Exception occurred during invocation of JCA binding: "JCA Binding execute of Reference operation 'dbReference' failed due to: Interaction processing error.
    Error while processing the execution of the IFSAPP.TEST_SOA_API API interaction.
    An error occurred while processing the interaction for invoking the IFSAPP.TEST_SOA_API API. Cause: java.lang.NullPointerException
    Check to ensure that the XML containing parameter data matches the parameter definitions in the XSD.  This exception is considered not retriable, likely due to a modelling mistake.
    The invoked JCA adapter raised a resource exception.
    Please examine the above error message carefully to determine a resolution.
    Caused by: BINDING.JCA-12563
    Exception occurred when binding was invoked.
    Exception occurred during invocation of JCA binding: "JCA Binding execute of Reference operation 'callAPI' failed due to: Interaction processing error.
    Error while processing the execution of the IFSAPP.TEST_SOA_API API interaction.
    An error occurred while processing the interaction for invoking the IFSAPP.TEST_SOA_API API. Cause: java.lang.NullPointerException
    Check to ensure that the XML containing parameter data matches the parameter definitions in the XSD.  This exception is considered not retriable, likely due to a modelling mistake.
    The invoked JCA adapter raised a resource exception.
    Please examine the above error message carefully to determine a resolution.
       at oracle.integration.platform.blocks.adapter.fw.jca.cci.JCAInteractionInvoker.executeJcaInteraction(JCAInteractionInvoker.java:569)
        at oracle.integration.platform.blocks.adapter.fw.jca.cci.JCAInteractionInvoker.invokeJcaReference(JCAInteractionInvoker.java:724)
        at oracle.integration.platform.blocks.adapter.fw.jca.cci.JCAInteractionInvoker.invokeAsyncJcaReference(JCAInteractionInvoker.java:689)
        at oracle.integration.platform.blocks.adapter.fw.jca.cci.JCAEndpointInteraction.performAsynchronousInteraction(JCAEndpointInteraction.java:628)
        at oracle.integration.platform.blocks.adapter.AdapterReference.post(AdapterReference.java:325)
        ... 84 more
    Caused by: BINDING.JCA-11812
    Interaction processing error.
    Error while processing the execution of the IFSAPP.TEST_SOA_API API interaction.
    An error occurred while processing the interaction for invoking the IFSAPP.TEST_SOA_API API. Cause: java.lang.NullPointerException
    Check to ensure that the XML containing parameter data matches the parameter definitions in the XSD.  This exception is considered not retriable, likely due to a modelling mistake.
        at oracle.tip.adapter.db.exceptions.DBResourceException.createNonRetriableException(DBResourceException.java:690)
        at oracle.tip.adapter.db.exceptions.DBResourceException.createEISException(DBResourceException.java:656)
        at oracle.tip.adapter.db.sp.SPUtil.createResourceException(SPUtil.java:180)
        at oracle.tip.adapter.db.sp.SPInteraction.executeStoredProcedure(SPInteraction.java:183)
        at oracle.tip.adapter.db.DBInteraction.executeStoredProcedure(DBInteraction.java:1302)
        at oracle.tip.adapter.db.DBInteraction.execute(DBInteraction.java:307)
        at oracle.integration.platform.blocks.adapter.fw.jca.cci.JCAInteractionInvoker.executeJcaInteraction(JCAInteractionInvoker.java:415)
    Caused by: java.lang.NullPointerException
        at oracle.tip.adapter.db.sp.SPInteraction.executeStoredProcedure(SPInteraction.java:162)
        ... 91 more
    The SP SCA is the simplest possible application I can think of...  The WebService accepts a single INT, calls BPEL>Receive>Assign>Invoke>dbAdapter(Stored Procedure) that accepts a single IN INTEGER parameter in an Oracle 11g database.
    Steps I've used to create the SP SCA. (Create Empty SOA Application)
    1.) Create Database Adapter in External References swim lane.
    2.) Set JNDI and Connection.
    3.) Browse to Oracle Procedure...click through Wizard and accept all defaults.
       CREATE OR REPLACE PROCEDURE TEST_SOA_API (
         wo_order_no_ IN INTEGER)
       IS
       BEGIN
         INSERT INTO TEST_TMP VALUES (wo_order_no_);
       END;
    4.) WSDL, XSD, JCA are automatically generated. 
    5.) Create BPEL Process Component and select Template "Base on a WSDL".  I choose the WSDL created from the Database Adapter wizard.
    6.) The "Exposed Service" is automatically created and everything is wired.
    7.) I deploy to my CompactDomain (running on a local Oracle12 db).  No errors.
    8.) I login to EM and Test the WebService..and ALWAYS receive the error message above.
    I've tried BPEL Process and Mediator as components to simply pass the single incoming INT parameter to the SP DbAdapter and tried every combination I can think of with DataSource/DbAdapter Deployment through the Admin console.  I used the same exact steps above for INSERT, UPDATE, Polling and have had no issues so I cannot figure out why I'm not receiving java.NullPointer exception or why I'm receiving the XML/XSD malformation error.
    Stuck now...anyone have an idea what I'm doing wrong or simply tell me I'm an idiot and shouldn't do SP's this way?
    FYI.  I've turned on logging for the oracle.soa.adapter.db class to TRACE: 32(FINEST).  Not much help to me
    [2015-04-02T09:03:55.706-05:00] [AdminServer] [WARNING] [ADF_FACES-00007] [oracle.adf.view.rich.render.RichRenderer] [tid: 118] [userId: weblogic] [ecid: 852497f1-b648-4cac-9cee-05e7972ce68e-00000788,0] [APP: em] [DSID: 0000KluHqzk0NuGayxyWMG1L7K52000003] Attempt to synchronized unknown key: viewportSize.
    [2015-04-02T09:05:23.971-05:00] [AdminServer] [TRACE] [] [oracle.soa.adapter.db.outbound] [tid: 115] [userId: <anonymous>] [ecid: 852497f1-b648-4cac-9cee-05e7972ce68e-000007db,1:17474] [APP: soa-infra] [oracle.soa.tracking.FlowId: 250004] [oracle.soa.tracking.InstanceId: 1270014] [oracle.soa.tracking.SCAEntityId: 90004] [composite_name: OraclePLSQL2!1.0] [FlowId: 0000KluSpyP0NuGayxyWMG1L7K52000007] [SRC_CLASS: oracle.tip.adapter.db.sp.AbstractStoredProcedure] [SRC_METHOD: execute]  [composite_version: 1.0] [reference_name: dbReference] BEGIN IFSAPP.TEST_SOA_API(WO_ORDER_NO_=>?); END;
    [2015-04-02T09:05:23.972-05:00] [AdminServer] [TRACE] [] [oracle.soa.adapter.db.outbound] [tid: 115] [userId: <anonymous>] [ecid: 852497f1-b648-4cac-9cee-05e7972ce68e-000007db,1:17474] [APP: soa-infra] [oracle.soa.tracking.FlowId: 250004] [oracle.soa.tracking.InstanceId: 1270014] [oracle.soa.tracking.SCAEntityId: 90004] [composite_name: OraclePLSQL2!1.0] [FlowId: 0000KluSpyP0NuGayxyWMG1L7K52000007] [SRC_CLASS: oracle.tip.adapter.db.sp.AbstractStoredProcedure] [SRC_METHOD: execute]  [composite_version: 1.0] [reference_name: dbReference] Bindings [WO_ORDER_NO_=>INTEGER(2343)]
    WSDL
    <wsdl:definitions
         name="dbReference"
         targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/db/OraclePLSQL2/OraclePLSQL2/dbReference"
         xmlns:tns="http://xmlns.oracle.com/pcbpel/adapter/db/OraclePLSQL2/OraclePLSQL2/dbReference"
         xmlns:jca="http://xmlns.oracle.com/pcbpel/wsdl/jca/"
         xmlns:plt="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
         xmlns:db="http://xmlns.oracle.com/pcbpel/adapter/db/sp/dbReference"
         xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
        >
      <plt:partnerLinkType name="dbReference_plt" >
        <plt:role name="dbReference_role" >
          <plt:portType name="tns:dbReference_ptt" />
        </plt:role>
      </plt:partnerLinkType>
        <wsdl:types>
         <schema xmlns="http://www.w3.org/2001/XMLSchema">
           <import namespace="http://xmlns.oracle.com/pcbpel/adapter/db/sp/dbReference"
                   schemaLocation="../Schemas/dbReference_sp.xsd" />
         </schema>
        </wsdl:types>
        <wsdl:message name="args_in_msg">
            <wsdl:part name="InputParameters" element="db:InputParameters"/>
        </wsdl:message>
        <wsdl:portType name="dbReference_ptt">
            <wsdl:operation name="dbReference">
                <wsdl:input message="tns:args_in_msg"/>
            </wsdl:operation>
        </wsdl:portType>
    </wsdl:definitions>
    XSD
    <schema targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/db/sp/dbReference" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:db="http://xmlns.oracle.com/pcbpel/adapter/db/sp/dbReference" elementFormDefault="qualified">
       <element name="InputParameters">
          <complexType>
             <sequence>
                <element name="WO_ORDER_NO_" type="int" db:index="1" db:type="INTEGER" minOccurs="0" nillable="true"/>
             </sequence>
          </complexType>
       </element>
    </schema>
    Payload XML
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
            <soap:Body>
                    <ns1:InputParameters xmlns:ns1="http://xmlns.oracle.com/pcbpel/adapter/db/sp/dbReference">
                            <ns1:WO_ORDER_NO_>667</ns1:WO_ORDER_NO_>
            </ns1:InputParameters>
        </soap:Body>
    </soap:Envelope>

    An even simpler request:
    Can someone create an SCA that simply accepts a single INT parameter and calls a Stored Procedure (Oracle) that inserts this INT into a table?  Maybe upload the project folder structure in a zip? 
    Seems someone with experience on this platform could execute this task in 10-15 minutes.
    CREATE TABLE TEST_TMP (WO_ORDER_NO INT);
       CREATE OR REPLACE PROCEDURE TEST_SOA_API (
         wo_order_no_ IN INTEGER)
       IS
       BEGIN
         INSERT INTO TEST_TMP VALUES (wo_order_no_);
       END;

  • Calling Stored Procedure in SDK Code

    Hello Experts,
    Iam facing a problem in Sdk Code...How do i Excute the stored procedure in sdkcode.I have  aStored Procedure ,In My Stored Procedures (My Operation Is DML operation Insert),Inserting UDO (Document Data) To the Normal Table.
      I am Having Data in Matrix and when Add the Document I am  calling the Procedure.How Do establish Connection and How do i Use the Commands to excute the Procedure and Save to the Normal Table..
    Dim sqlconn As New SqlConnection("Data Source=" & SBO_Company.Server & ";Database=" & SBO_Company.CompanyDB & "; User ID=" & SBO_Company.DbUserName & ";Password=sap;")
            Dim sqldaa As New SqlDataAdapter
            Dim dss As New DataSet
            If sqlconn.State = ConnectionState.Closed Then
                sqlconn.Open()
            End If
            Dim sqlcmdd As New SqlCommand("PRODSALETOALL", sqlconn)
            sqlcmdd.CommandType = CommandType.StoredProcedure
            'sqlcmd.CommandText = "PRODSALE"
            sqlcmdd.Parameters.Add("@fy", "bb")
            sqlcmdd.Parameters.Add("@doctype", "aa")
            'sqldaa.SelectCommand = sqlcmdd
            'sqldaa.Fill(dss)
            'sqldaa.Dispose()
            sqlcmdd.ExecuteNonQuery()
            sqlcmdd.Dispose()
    Help would be Appreciated..
    Regards,
    Kumar

    Haroon,
    SAP does not allow Stored Procedures to be used as part of the SAP Business Db or to be used to access SAP Business One tables directly for Insert, Update or Delete.  Any interaction with the SAP Business One Db is required to go through the SAP Business One API's, namely the DI and UI API's.
    Eddy

  • Big overhead calling stored procedure vs query in oci program

    My previous question hasn;t got a reply. I guess I did not state it well so I rephrased it a little and repost here. Hopefully somebody can help me with this problem.
    I'm a newbie on OCI. I hope to use OCI for array DML to improve performance. It takes only 1 seconds to insert 20,000 records using the simple insert query, which is almost a miracle to me.
    Then I tested using a stored procedure. This SP does exactly the same thing as the query: Inserting into the table with the 10 parameter provided.
    However, it takes 23 seconds for 20,000 records.
    Is calling a stored procedure fundamentally slower than a query in Oci, or I just did it wrong?
    Following is the codes:
    sword Tform_1::update_all_rows(OCIEnv envhp, OCISvcCtx svchp, OCIError errhp, OCIStmt update_p, OCIStmt *select_p)
    int *intArry = new int[20000];
    for (int i = 0; i < 20000; i++)
    intArry = 50000 + i;
    // text mySql = (text ) "Insert into testPro (a, b, c, d, e, f, g, h, i, j) VALUES (:a, :b, :c, :d, :e, :f, :g, :h, :i, :j)";
    text mySql = (text ) "BEGIN\
    CDSDEVELOPER_UTILPKG.INSERTTESTPRO(:a, :b, :c, :d, :e, :f, :g, :h, :i, :j);\END;";
    ub4 prefetch = 10;
    sword errr;
    ub4 c1;
    text c2[30];
    OCIBind *bndhp;
    OCIDefine *defnp1,
    *defnp2;
    for (int i = 0; i < MAXROWS; i++)
    if (OCIDescriptorAlloc((dvoid *) envhp, (dvoid **) &(intArry),
    (ub4) OCI_DTYPE_ROWID, (size_t) 0, (dvoid **) 0))
    ShowMessage("FAILED: OCIDescriptorAlloc()\n");
    return (OCI_ERROR);
    if (OCIStmtPrepare (update_p, errhp,
    mySql, strlen(mySql), OCI_NTV_SYNTAX, OCI_DEFAULT))
    ShowMessage ("Prepare failed \n");
    return (OCI_ERROR);
    for (int k = 1; k <= 10; k++)
    if (OCIBindByPos ( update_p,
    &bndhp,
    errhp,
    k,
    intArry,
    sizeof(int),
    SQLT_INT,
    (ub2 *) 0,
    (ub2 *) 0,
    (ub4) 0,
    (ub4) 0,
    (ub4 *) 0,
    (ub4) OCI_DEFAULT))
    ShowMessage ("Bind failed \n");
    return (OCI_ERROR);
    if (errr = OCIStmtExecute(svchp,
    update_p,
    errhp,
    (ub4) MAXROWS,
    (ub4) 0,
    (OCISnapshot *) NULL,
    (OCISnapshot *) NULL,
    (ub4) OCI_DEFAULT))
    report_error(errhp);
    ShowMessage ("Update failed \n");
    return (OCI_ERROR);
    delete[] intArry;
    Can anybody tell me what is wrong? Thanks very much.
    Changsong

    Karl: Thanks a lot for your reply. I think you are right about context switch when calling a stored procedure.
    I found even wrapping a 'begin' and 'end' around the query text in the call slows down a great deal (from 1 second to 5 seconds for 20000 inserts).
    so a lot of the array binding benefits come from bulk-insert feature in oci, which is not allowed when calling a stored procedure. I've compared the performace using oci array binding to call a sp vs. traditional borland C++ builder BDE stored procedure component, and it is 23seconds vs 45 seconds. Still a lot of gain here, but compared with the bulk insert feature, I'm quite disappointed. My problem is most of the database transaction is done within some stored procedures and thus cann't take much advantage of bulk insert.
    Changsong

  • Oracle Instant Client and OUT Parameter of custom type in Stored Procedures

    Hi @ all!
    I try to set up a simple client application, that calls a stored procedure via Instant Client from C#.
    The stored procedure and assiciated types looks like this:
    TYPE MYVALUE AS OBJECT
          Id      INTEGER,
          value     FLOAT
    TYPE MYVALUELIST AS TABLE OF MYVALUE;
    PROCEDURE ReadValues( ID IN INTEGER,
                                        RESULTSET OUT MYVALUELIST)
                                           IS
    ...I created an Oracle Command executing this SP and added OracleParameters for ID and (where I got stuck) the RESULTSET.
    Is it possible to pass a parameter with a custom type from C# in some way?
    I already tried it as a function with SELECT * FROM TABLE(ReadValues(1));
    With my parameter RESULTSET as the RETURN type. But since I use DML within the procedure, this does not work inside of a query...
    Any suggestions?
    Thanks in advance!

    Hi Greg!
    Sorry, I misunderstood the forum topic then. =(
    Anyway, in the example you provided in the link, this is nearly exactly my situation. But there the Oracle.DataAccess.Client is used, where the OracleDBType can be called to initialize an object of type person. I use the instant client libraries called by using System.Data.OracleClient. There is only the OracleType enum, that does not contain an object or something similar.
    So I do it right now after trying a bit with a ref cursor parameter and an OracleDataAdapter - the ref cursor is passed back from Oracle as a DataReader, so die DataAdapter is able to use it for a .Fill():
    OracleCommand cmd = new OracleCommand();
    cmd.Parameters.Add("RESULTSET", OracleType.Cursor).Direction = ParameterDirection.Output;
    OracleDataAdapter odr = new OracleDataAdapter(cmd);
    DataTable result = new DataTable();
    odr.Fill(result);Within my stored procedure I just added the following OUT parameter:
    PROCEDURE ReadValues( ID IN INTEGER,
                                        RESULTSET OUT sys_refcursor)
                                           IS
    currentlist MYVALUELIST;
    ... [Adding elements to that list] ...
    OPEN resultset for select * from TABLE(currentlist);It works now, but I don't like that solution that much since I'm always afraid that there are lots of opened cursors idyling around. Do I have to close this one explicitly after filling my table by the DataAdapter?
    Regards

  • Error when executing DBMS_ERRLOG through Stored Procedures...

    Hi,
    We have TWO schemas like IDWH_ODS and IDWH_ERR running on Oracle 10g Rel.2.
    The schema IDWH_ERR has direct SELECT privilege on all the base tables in IDWH_ODS schema. (As Pl/sql doesn't support ROLE, we have granted direct SELECT on each of the tables)
    IDWH_ODS schema has tables like ACCOUNT & CUSTOMER, for which I need to create DML Error logging tables in IDWH_ERR schema.
    I have one procedure 'Cr_Errlog_Tabs' in IDWH_ERR schema which gets all tables in IDWH_ODS and creates Error logging table in IDWH_ERR schema using DBMS_ERRLOG package. My problem starts here,
    When I execute the DBMS_ERRLOG package in IDWH_ERR through SQL*Plus LIKE,
    > exec DBMS_ERRLOG.CREATE_ERROR_LOG('idwh_ods.ACCOUNT','ERR$_ACCOUNT','idwh_err');
    it's creating the error log table 'ERR$_ACCOUNT' in IDWH_ERR schema.
    (...the same will be working when execute through Anonymous plsql block)
    BUT, when i execute the DBMS_ERRLOG package with same parameters through the stored Procedure 'Cr_Errlog_Tabs', it throws the following error...
    ORA-01031: insufficient privileges
    Please let me know how the solution at the earliest.

    WHY DO YOU FEEL YOU HAVE TO START A NEW THREAD FOR YOUR PROBLEM!?
    Insufficient priv error when executing DBMS_ERRLOG through PLSQL

Maybe you are looking for

  • Firefox 4 locks up a lot when I visit Amazon. I can't use it and when I try to close it, it crashes.

    A lot of the times when I visit Amazon FF 4 locks up on me to the point that I can't use it. The only option to get out of it being locked up is to right click, then select "close" at which point a dialogue pops up saying that the program has stopped

  • Can't get cell borders to work

    I'm new Mac user...and I'm having a terrible time working with some spreadsheets that I created in Excel and saved as .numbers docs. My current problem is: I can't get cell borders to work. I had an existing Excel spreadsheet and when I saved it as a

  • How to create contact group in nokia n900

    Hi,        Kindly help me to create group in nokia n900. Group options i can;t understand how i will create groups.

  • How could I investigate SQL statement from standard audit record ?

    We use Oracle 11gR2. We use standard audit , audit_trail=DB. We found suspicious audit record but that  SQL_BIND,SQL_TEXT colums were NULL. How could I investigate that SQL statement from standard audit record ?

  • Update 14.2.1 fails

    I recently purchased a Creative Cloud subscription and was happily using Photoshop until yesterday when my PC completely crashed and I needed to reinstall absolutely everything. I have now got all my programs back to normal except for Photoshop. It w