Procedure with in procedure

Hi,
i need to call a procedure with in another procedure and pass the main procedure values. when i am doing like this i am getting the error.
Can any one tell me where the error is:
the main procedure is xxxx( P_PHONE IN VARCHAR2,
P_CLIENT IN VARCHAR2,
P_MANAGER IN VARCHAR2,
P_ACCOUNTANT IN VARCHAR2
as
x:=P_PHONE;
y:= P_CLIENT;
z:= P_MANAGER;
n:= P_ACCOUNTANT;
exec tlm_ar_string_to_table(x,y,z,n);
end;
my inner procedure is
create or replace procedure tlm_ar_string_to_table(
P_PHONE IN VARCHAR2,
P_CLIENT IN VARCHAR2,
P_MANAGER IN VARCHAR2,
P_ACCOUNTANT IN VARCHAR2
as
p_string_c varchar2(500);
P_PROCESSING_GROUP_C varchar2(10);
P_client_C varchar2(10);
P_manager_C varchar2(10);
P_accountant_C varchar2(10);
p_search_result_c varchar2(10);
CURSOR psg_CURSOR IS
SELECT distinct phone FROM SSRFUND.bank where phone>' ' ;
cursor string_ex_cur is
select substr( p_string_c
, decode( level, 1, 1, instr(p_string_c,',',1,level-1)+1)
, decode( instr(p_string_c,',',1,level), 0, length(p_string_c),
instr(p_string_c,',',1,level) - decode( level, 1, 0, instr(p_string_c,',',1,level-1))-1)
) the_value
from ( select p_string_c
from dual)
connect by level <= length(p_string_c)-length(replace(p_string_c,','))+1;
cursor mgr_cursor is
select distinct fax from ssrfund.bank;
cursor client_cursor is
select distinct swift_address from ssrfund.bank;
cursor accountant_cursor is
select distinct telex from ssrfund.bank;
begin
execute immediate 'Truncate table temp_processing_group';
execute immediate 'Truncate table temp_accountant';
execute immediate 'Truncate table temp_client';
execute immediate 'Truncate table temp_manager';
if (P_PHONE is null) then
open psg_cursor;
loop
FETCH psg_cursor INTO P_PROCESSING_GROUP_C;
EXIT WHEN (psg_cursor%NOTFOUND);
insert into temp_PROCESSING_GROUP values(P_PROCESSING_GROUP_C);
commit;
end loop;
close psg_cursor;
else
p_search_result_c:=instr(p_phone,',');
if (p_search_result_c='TRUE') then
p_string_c:=p_phone;
open string_ex_cur;
loop
fetch string_ex_cur into P_PROCESSING_GROUP_C;
insert into temp_PROCESSING_GROUP values(P_PROCESSING_GROUP_C);
commit;
end loop;
close string_ex_cur;
else
insert into temp_PROCESSING_GROUP values(P_PROCESSING_GROUP_C);
commit;
end if;
end if;
if (P_client is null) then
open client_cursor;
loop
FETCH client_CURSOR INTO P_client_C;
EXIT WHEN (client_CURSOR%NOTFOUND);
insert into temp_client values(P_client_C);
commit;
end loop;
close client_cursor;
else
p_search_result_c:=instr(p_client,',');
if (p_search_result_c='TRUE') then
p_string_c:=p_client;
open string_ex_cur;
loop
fetch string_ex_cur into P_client_C;
insert into temp_client values(P_client_C);
commit;
end loop;
close string_ex_cur;
else
insert into temp_client values(P_client_C);
commit;
end if;
end if;
if (P_manager is null) then
open mgr_cursor;
loop
FETCH mgr_CURSOR INTO P_manager_C;
EXIT WHEN (mgr_CURSOR%NOTFOUND);
insert into temp_manager values(P_manger_C);
commit;
end loop;
close mgr_cursor;
else
p_search_result_c:=instr(P_manager,',');
if (p_search_result_c='TRUE') then
p_string_c:=p_manager;
open string_ex_cur;
loop
fetch string_ex_cur into P_manager_C;
insert into temp_manager values(P_manager_C);
commit;
end loop;
close string_ex_cur;
else
insert into temp_manager values(P_manager_C);
commit;
end if;
end if;
if (P_accountant is null) then
open accountant_cursor;
loop
FETCH accountant_cursor INTO P_accountant_C;
EXIT WHEN (accountant_cursor%NOTFOUND);
insert into temp_accountant values(P_accountant_C);
commit;
end loop;
close accountant_cursor;
else
p_search_result_c:=instr(P_accountant,',');
if (p_search_result_c='TRUE') then
p_string_c:=p_accountant;
open string_ex_cur;
loop
fetch string_ex_cur into P_accountant_C;
insert into temp_accountant values(P_accountant_C);
commit;
end loop;
close string_ex_cur;
else
insert into temp_accountant values(P_accountant_C);
commit;
end if;
end if;
EXCEPTION
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR (-20001, SQLERRM);
end;
/

user12852882 wrote:
i need to call a procedure with in another procedure and pass the main procedure values. when i am doing like this i am getting the error.Ugly code. There's seldom the need to use PL logic when the source and destination data both resides in Oracle tables. SQL should be used.
Also, why the the "+temp+" tables? I/O is single most expensive thing you can on a database platform. Why would one then want to create more I/O by creating temp tables? This approach may be needed in SQL-Server for example, but in Oracle it is usually just plain and horribly wrong.
I suggest that you scrap this code, forget about coding procedures-in-procedures (use packages instead), forget about trying to process row-by-row in a slow-by-slow fashion in the PL language.
SQL is not a mere I/O language to be used for reading and writing data (for PL code to process the row). SQL is a data processing language. Extremely capable. Extremely powerful. And can process Oracle data faster than any other language, including using the PL language component in the server.
The basic rule for effective and scalable Oracle code is Maximize SQL. Minimize PL/Java/etc.
Use the SQL language for its intended purpose and do not process rows needlessly in another language layer.

Similar Messages

  • Calculate the total value of payments with the procedures and triggers?

    Hello!
    I work for a college project and I have a big problem because professor requires to do it by the examples he gives during the lecture. Here's an example that should be applied to its base, so please help!
    I have three table with that should work:
    Invoice (#number_of_invoices, date, comm, total_payment, number_of_customer, number_of_dispatch)
    where:
    number_of_invoices primary key (number),
    date (date),
    comm (var2),
    total_payment is UDT (din - currency in my country) - in this field should be entered value is calculated
    number_of_customer and number_of_dispatch (number) are foreign keys and they are not relevant for this example
    Invoice_items (#serial_number, #number_of_invoices, quantity, pin)
    serial_number primary key (number),
    number_of_invoices primary key (number),
    quantity (number),
    pin foreign keys (number)
    Item (#pin, name, price, tax, price_plus_tax)
    pin primary key (number),
    name (var2),
    price, tax, UDT (din) not relevant for this example
    price_plus_tax UDT (din)
    These are the triggers and procedures with my calculation should be done:
    trigger1:
    CREATE OR REPLACE TRIGGER  "trg1"
    BEFORE INSERT OR UPDATE OR DELETE ON Invoice_items
    FOR EACH ROW
    BEGIN  
         IF (INSERTING OR UPDATING)
         THEN     
              BEGIN Invoice_items.number_of_invoices := :NEW.number_of_invoices; END;
         ELSE
              BEGIN Invoice_items.number_of_invoices :=: OLD.number_of_invoices; END;  
         END IF;
    END;trigger2:
    CREATE OR REPLACE TRIGGER  "trg2"
    AFTER INSERT OR UPDATE OR DELETE ON Invoice_items
    DECLARE
    doc NUMBER := Invoice_items.number_of_invoices;
    BEGIN  
         entire_payment (doc);
    END;procedure
    CREATE OR REPLACE PROCEDURE  "entire_payment" (code_of_doc IN NUMBER) AS 
    entire NUMBER := 0;
    BEGIN 
         SELECT SUM (a.price_plus_tax * i.quantity) INTO entire
         FROM Item a join Invoice_items i on (a.pin = i.pin) 
         WHERE number_of_invoices = code_of_doc;
         UPDATE Invoice
         SET total_payment = entire
         WHERE number_of_invoices = code_of_doc;
    END;As you can see the procedure is called from the triggers, I have a problem at the first trigger, and I think it will be even higher in procedure because UDT, field "total_payment".

    I was not here a few days because I was trying to get additional information related to this problem. Professor gave me the information that I need to introduce a package and variable to get this thing work. But including that I still have problem. I hope that this time is less of a problem and that someone will be able to help me.
    I also noticed that it was not a smart idea to try to translate the names of tables and attributes. That make trouble for me, especially you who are trying to understand and to help me, and absolutely nothing that will change the attribute and the table name will be. So this time I will set out the problem with the original name again to avoid confusion.
    So, I try to base Implement optimization technique called: Repeating Single Detail with Master (so writes the slides that I received from professor, I hope that will mean something to you)
    These are the lines of code that we get on the slides and should implement in the base, again I remind you that at this time in its original form, without translation.
    - First create the package variable:
    create or replace
    package paket
    AS
    sifra number(10):=0;
    end;This part is ok and it works.
    - Secondly, it is necessary to create the first trigger:
    create or replace
    TRIGGER aktuelna_cena1
    BEFORE INSERT OR UPDATE OR DELETE ON cena_artikla
    FOR EACH ROW
    BEGIN
         IF (INSERTING OR UPDATING)
         THEN      
              BEGIN paket.sifra := :NEW.sifra_artikla; END;
         ELSE
              BEGIN paket.sifra := :OLD.sifra_artikla; END;
        END IF;
    END;This part is ok and working.
    Now the problems begin.
    - It is necessary to create another trigger that will call the procedure:
    create or replace
    TRIGGER aktuelna_cena2
    AFTER INSERT OR UPDATE OR DELETE ON cena_artikla
    DECLARE  
         s NUMBER := paket.sifra;
    BEGIN  
         aktuelnacena (s);
    END;I suppose the trigger have problem because procedure is not ok.
    I will copy error that I get from the compiler:
    Error(7,2): PL/SQL: Statement ignored
    Error(7,2): PLS-00905: object NUMBER6.AKTUELNACENA is invalid
    And finally, it is necessary to create the procedure:
    create or replace
    PROCEDURE  aktuelnacena (SifraPro IN NUMBER) AS 
    aktCena artikal.aktuelna_cena%type;
    BEGIN aktCena:=0;
                    SELECT cena INTO aktCena
                    FROM cena_artikla 
                    WHERE sifra_artikla=SifraPro and datum_od=
                                    (select max(datum_od)
                                    from cena_artikla
                                    where sifra_artikla = SifraPro and datum_od<=sysdate); 
                    UPDATE artikal
                    SET aktuelna_cena = aktCena
                    WHERE sifra_artikla = SifraPro;
    END;I will copy error that I get from the compiler:
    Error(10,57): PLS-00103: Encountered the symbol " " when expecting one of the following: ( begin case declare end exception exit for goto if loop mod null pragma raise return select update while with << continue close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe purge The symbol " " was ignored.
    Tables I work with are:
    Artikal (sifra_artikla, naziv, aktuelna_cena),
    Cena_artikla (sifra_artikla, datum_od, cena)
    You will notice that this differs from the first problem, but my task is to implement the two optimization techniques and my base. Both techniques are quite similar and I hope that I now have enough information to help me. I suppose that when this problem is solved the othet one will too!
    Thank in advance!

  • Calling stored procedures with parameters with the Database Connectivi​ty Toolkit

    Hi all,
    I am new to the forum and am having difficulty finding a solution to a particular problem I am having regarding using the LabVIEW Database Connectivity Toolkit on a project I am currently working on at my job.  I have a database in which I have tables and stored procedures with parameters.  Some of these stored procedures have input, output, and return parameters.
    I have been trying to follow this example but to no avail:  http://digital.ni.com/public.nsf/allkb/07FD1307460​83E0686257300006326C4?OpenDocument
    One such stored procedure I am working on implementing is named "dbo.getAllowablePNs", which executes "SELECT * from DeviceType" (DeviceType is the table).  In this case, it does not require an input parameter, it has an output parameter that generates the table [cluster], and has a return parameter which returns an integer value (execution status code) to show if an error occurred.  The DeviceType table has 3 columns; ID (PK, int, not null), PN (nvarchar(15), null), and NumMACAddresses (int, null).  I have gone over many examples and have talking to NI support to try to implement this and similar stored procedures in LabVIEW but have not been successful.  I am able to connect to the database with the Open Connection VI without error, but am running into some confusion following this step.  I am then trying to use the Create Parameterized Query VI to call the stored procedure and set the parameters.  I assume I would then use the Set Parameter Value VI for each parameter that is wired into the parameters input on the previous Parameterized Query VI?  I am also having some confusion during and following these steps as well.  I would greatly appreciate any advice or suggestions anyone might have in regards to this situation as I am not a SQL expert.  Also, I would be happy to provide any more information that would be helpful.
    Regards,
    Jon
    Solved!
    Go to Solution.

    Also, I don't know if this would be helpful but here is the actual stored procedure in SQL:
    CREATEPROCEDURE [dbo].[getLastSequenceNumber]
    @p1 nvarchar(10)='WO-00000'
    AS
    BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SETNOCOUNTON;
    -- Insert statements for procedure here
    selectmax(SequenceNumber)from Devices where WorkOrderNumber= @p1
    END
    GO

  • Procedure with OUT Parameters - Creating A Report

    I have the following procedure that is used in our internal (non-APEX) apps:
    PROCEDURE SelIssueActivityPublic (
                                                p_results           OUT     SYS_REFCURSOR,
                                                p_IssueID                    IN     ems.issue.issue_id%TYPE,
                                                p_TransactionID         OUT VARCHAR2
                 ) The body of the procedure does a bunch of processing, and inserts data into a staging table. The cursor OUT parameter then returns a SELECT statement from the staging table. Since it's possible for this procedure to be hit multiple times (multiple users), the transaction ID is used to match the data in the staging table to the correct request. The procedure then deletes the data from the staging table. (I'll post it if necessary, but it's quite long, and since it's used in other applications successfully, I don't believe it's relevant to my issue.)
    I have been asked to create an APEX report of the data generated by the procedure. I've never used a procedure with an OUT parameter to set up a report. I was hoping to assign the transaction ID to a hidden variable on page load, and then using it to poplulate the report. I'm not interested in the cursor OUT parameter, I've written my own SELECT statement to grab data from the staging table.
    I tried to create a page computation that did this - item :H_P19_TRANSID, Before Header, computation = EMS.EMS_READER.SelIssueActivityPublic(:H_P19_CURSOR, 454551, :H_P19_TRANSID) [454551 is a test issue id], but I get the following error: ORA-06550: line 1, column 43: PLS-00222: no function with name 'SELISSUEACTIVITYPUBLIC' exists in this scope ORA-06550: line 1, column 7: PL/SQL: Statement ignored flowComp=H_P19_TRANSID
    Error ERR-1030 Error executing computation expression. It seems to be thinking that SelIssueActivityPublic is a function, and I'm not sure why.
    Basically I need to know how to use this existing procedure to set up my report. Once I can get the transaction ID into a page item, I'll be set.

    I never got a chance to finish this report, as I was shuffled to something else with a higher priority. Now that I'm coming back to it, I still have a few issues.
    I created a new function that does all the processing (inserting into the staging table etc.), and returns the transaction id. I then tried to set up a page computation on a hidden item to run this function and store the transaction id.
    In the computation, if I put
    reader.SelIssueActivityPubnocursor(:H_P19_ISSUEID); as the computation, I get ORA-06503: PL/SQL: Function returned without value flowComp=H_P19_TRANSACTIONID as an error. If I put return return reader.SelIssueActivityPubnocursor(:H_P19_ISSUEID); as the computation, I get ORA-06550: line 1, column 50: PLS-00103: Encountered the symbol "EMS" when expecting one of the following: . ( * @ % & = - + ; < / > at in is mod remainder not rem <> or != or ~= >= <= <> and or like like2 like4 likec between || multiset member submultiset The symbol "." was substituted for "EMS" to continue. flowComp=H_P19_TRANSACTIONID as the error. Can someone tell me what's going wrong?

  • Passing parameters from vb form to a crystal report with stored procedure

    Can someone give me an idea how to use data inputted on vb form to be use as basis of crystal report generation which loads data from a stored procedure. Stored procedure has parameters that was also set in the crystal report. viewing on crystal report is ok but i am having difficulty running the report from vb.

    Hi John,
                  If Not CRRpt.ParameterFields("AgeType") Is Nothing Then
                        CRRpt.ParameterFields("AgeType").CurrentValues.Clear()
                        Dim ParamValue As new CrystalDecisions.Shared.ParameterDiscreteValue
                        ParamValue.Value = AgeType.ToString 
                        CRRpt.ParameterFields("AgeType").CurrentValues.Add(ParamValue)
                    End If
    Note that the ParamValue.Value should be assigned with exact same data type as you declared it in CR.
    If it is string, Convert your Variable to string first.
    If it is date, make sure you are passing a date variable.
    and so on...
    Regards
    Edy

  • Using stored procedures with a timestamp parameter with Delphi  and ADO

    Dear Oracle experts,
    I have a problem concerning using a stored procedure with Delphi.
    I try to use a stored procedure which hast two input parameters ( a integer and a timestamp).
    The timestamp parameter is my problem since I would like to use the "to_timestamp"
    Oracle-function to create the timestamp parameter to be inserted into my procedure.
    If I insert the to_timestamp statement as a adodatetime I have to perform the conversion to the oracle timestamp in my application.
    If I want to use the to_timestamp statement I have to use the ftstring datatype but in that case I get an error because I use a string as input for my procedure were it awaits a timestamp.
    So the problem seems to be that the function call "to_timestamp" is not interpreted if it is transferred through my ADO component.
    Do you know how to use a procedure with Delphi (ADO) with a function as input parameter ?
    Best regards,
    Daniel Wetzler
    P.S. :
    This is the Delphi code to use my Procedure.
    FactsTempDS:=TADODataset.Create(nil);
    Sproc1 := TAdoStoredProc.Create(nil);
    Sproc1.Connection := TDBConnection(strlistConnectionstrings.objects[iConnectionIndex]).Connection;
    Sproc1.ProcedureName := 'ECSPACKAGE.PROCFINDINITIALSWITCHSTATE';
    Sproc1.Parameters.CreateParameter ('SwitchID',ftInteger,pdinput,0,0);
    //Sproc1.Parameters.CreateParameter ('StartTime',ftdatetime,pdinput,50,0);
    Sproc1.Parameters.CreateParameter ('StartTime',ftString,pdinput,50,0);
    Sproc1.Parameters.Findparam('SwitchID').value:=SwitchID;
    Sproc1.Parameters.FindParam('StartTime').Value:= 'to_timestamp(''2005/12/30 19:36:21'', ''YYYY/MM/DD HH:MI:SS'')';
    Sproc1.CursorType := ctKeyset;
    Sproc1.ExecuteOptions:=[];
    Sproc1.Open;
    Sproc1.Connection := nil;
    FactsTempDS.Recordset:= sproc1.Recordset;
    if FactsTempDS.RecordCount=0
    then raise Exception.Create('No line switch variable found for switch '+IntToStr(SwitchID)+' before starttime. Check BDE dump filter.')

    I have my entity manager setup in a singleton.
    I'm finding it's costly to generate the emf, but if I don't close the em (enitity manager) and emf (entity manager factory) my open cursor count climbs until I exceed the max number of open cursors on the database (11g RAC)
    I'm committing the connection, and uow, and closing the em at the end of each call.
    But until I close the emf, the open cursors aren't released.
    TransactionhistoryPkg tranPkg = new TransactionhistoryPkg(conn); //Class created over database package via JPublisher
    tranPkg.transactionhistoryInsSp(insertTrans.getCardId()); // executes db package
    tranPkg.closeConnection();
    conn.commit();
    uow.commit();
    uow.getAccessor().decrementCallCount();
    em.close();
    Am I missing something really obvious here??
    btw - I found this link helpful in troubleshooting the max cursors issue: https://support.bea.com/application_content/product_portlets/support_patterns/wls/InvestigatingORA-1000MaximumOpenCursorsExceededPattern.html

  • How can I execute a Procedure with OUT variable is %ROWTYPE on SQL Prompt

    Hi,
    I have a procedure with OUT variable is %ROWTYPE
    How can I execute the following procedure on SQL prompt.
    (without creating anonymous block)
    CREATE OR REPLACE PROCEDURE zz_sp_EMP(VEMPNO IN EMP.EMPNO%TYPE,
    V_REC IN OUT EMP%ROWTYPE)
    AS
    BEGIN
    SELECT * INTO V_REC FROM EMP WHERE EMPNO = VEMPNO;
    END;
    Thanks & Regards,
    Naresh

    as previous posters said: it's not possible to do this without declaring a variable in the anonymous block.
    With anonymous block it would look like this (had to change it a bit, since i'm using hr-schema on oracle XE):
    declare
    l_rec EMPLOYEES%ROWTYPE;
    begin
    zz_sp_EMP(VEMPNO => 100, V_REC => l_rec);
    DBMS_OUTPUT.PUT_LINE ( 'first_name = ' || l_rec.first_name );
    DBMS_OUTPUT.PUT_LINE ( 'last_name = ' || l_rec.last_name );
    end;
    first_name = Steven
    last_name = King

  • Calling a stored procedure with a CLOB as input parameter

    Hello,
    I was unsuccessfully trying to call a stored procedure with a clob as input parameter from my C++ application using occi.
    Anyone got a working example to look at?
    I already checked the thread Invalid OCI handle when creating a Blob which didn't help.
    The problem seems to be that I don't have a lob locator to write my data (xml file) to. I tried creating a temporary clob using the sys.dbms_lob package which only resulted in a major headache on my part...
    I would appreciate any help.
    Kind regards
    Horst
    my environment:
    Visual Studio 2008, C++ application
    Oracle 11g

    To start using a blob you have to insert it into the database and then get it back. Sounds weird but that is how it is. Here is a very simple program to do this:
    #include<occi.h>
    #include <iostream>
    using namespace oracle::occi;
    using namespace std;
    int main()
      try
        Environment *env = Environment::createEnvironment(Environment::OBJECT);
        Connection *conn = env->createConnection("hr","hr","");
        string stmt1 = "insert into blob_tab values (:1) ";
        string stmt2 = "select col1 from blob_tab";
        Blob blob(conn);
        blob.setEmpty(conn);
        Statement *stmtObj = conn->createStatement(stmt1);
        stmtObj->setBlob(1,blob);
        stmtObj->executeUpdate();
        conn->commit();
        Blob blob1(conn);
        Statement *stmtObj2 = conn->createStatement(stmt2);
        ResultSet *rs = stmtObj2->executeQuery();
        while(rs->next())
         blob1 = rs->getBlob(1);
        string stmt3 = "begin my_proc(:1) ;end;";
        Statement *stmtObj3 =  conn->createStatement(stmt3);
        stmtObj3->setBlob(1,blob1);
        stmtObj3->executeUpdate();
      catch (SQLException e)
        cout << e.getMessage();
      /* The tables and procedure are primitive but ok for demo
        create table blob_tab(col1 blob);
        create or replace procedure my_proc(arg in blob)
        as
        begin
         -- just a putline here. you can do other more meaningful operations with the blob here
          dbms_output.put_line('hello');
       end;
    }Hope this helps.
    Thanks,
    Sumit

  • Calling a Stored Procedure with output parameters from Query Templates

    This is same problem which Shalaka Khandekar logged earlier. This new thread gives the complete description about our problem. Please go through this problem and suggest us a feasible solution.
    We encountered a problem while calling a stored procedure from MII Query Template as follows-
    1. Stored Procedure is defined in a package. Procedure takes the below inputs and outputs.
    a) Input1 - CLOB
    b) Input2 - CLOB
    c) Input3 - CLOB
    d) Output1 - CLOB
    e) Output2 - CLOB
    f) Output3 - Varchar2
    2. There are two ways to get the output back.
    a) Using a Stored Procedure by declaring necessary OUT parameters.
    b) Using a Function which returns a single value.
    3. Consider we are using method 2-a. To call a Stored Procedure with OUT parameters from the Query Template we need to declare variables of
    corresponding types and pass them to the Stored Procedure along with the necessary input parameters.
    4. This method is not a solution to get output because we cannot declare variables of some type(CLOB, Varchar2) in Query Template.
    5. Even though we are successful (step 4) in declaring the OUT variables in Query Template and passed it successfully to the procedure, but our procedure contains outputs which are of type CLOB. It means we are going to get data which is more than VARCHAR2 length which query template cannot return(Limit is 32767
    characters)
    6. So the method 2-a is ruled out.
    7. Now consider method 2-b. Function returns only one value, but we have 3 different OUT values. Assume that we have appended them using a separator. This value is going to be more than 32767 characters which is again a problem with the query template(refer to point 5). So option 2-b is also ruled out.
    Apart from above mentioned methods there is a work around. It is to create a temporary table in the database with above 3 OUT parameters along with a session specific column. We insert the output which we got from the procedure to the temporary table and use it further. As soon the usage of the data is completed we delete the current session specific data. So indirectly we call the table as a Session Table. This solution increases unnecessary load on the database.
    Thanks in Advance.
    Rajesh

    Rajesh,
    please check if this following proposal could serve you.
    Define the Query with mode FixedQueryWithOutput. In the package define a ref cursor as IN OUT parameter. To get your 3 values back, open the cursor in your procedure like "Select val1, val2, val3 from dual". Then the values should get into your query.
    Here is an example how this could be defined.
    Package:
    type return_cur IS ref CURSOR;
    Procedure:
    PROCEDURE myProc(myReturnCur IN OUT return_cur) ...
    OPEN myReturnCur FOR SELECT val1, val2, val3  FROM dual;
    Query:
    DECLARE
      MYRETURNCUR myPackage.return_cur;
    BEGIN
      myPackage.myProc(
        MYRETURNCUR => ?
    END;
    Good luck.
    Michael

  • Getting error while Calling Oracle Stored Procedure with output Parameter

    HI All,
    From long days i am working on this but i unable to solve it.
    Even i have studied so many forums in SAP but i didn't find the solution.
    I am calling Oracle Store procedure with 3 inputs and 1 output without cursor.
    Store Procedure:-
    CREATE OR REPLACE PROCEDURE PDS.send_rm
    IS
    proc_name           VARCHAR2(64) := 'send_rm';
    destination_system  VARCHAR2(32) := 'RAWMAT';
    xml_message         VARCHAR2(4000);
    status_code         INTEGER;
    status_message      VARCHAR2(128);
    debug_message       VARCHAR2(128);
    p_ret               INTEGER;
    BEGIN
      DBMS_OUTPUT.PUT_LINE( proc_name || ' started' );
      xml_message := '<RAW_MATERIAL>'||
                     '<BAR_CODE>10000764601</BAR_CODE>'||
                     '<MATERIAL>1101448</MATERIAL>'||
                     '<VENDOR_CODE/>'||
                     '<PRODUCTION_DATE>0000-00-00</PRODUCTION_DATE>'||
                     '<EXPIRE_DATE>0000-00-00</EXPIRE_DATE>'||
                     '<BATCH/>'||
                     '<PO_NUM/>'||
                     '<MATERIAL_DESCRIPTION>POWER SUPPLY</MATERIAL_DESCRIPTION>'||
                     '<SPEC_NAME/>'||
                     '<STOCK_CODE>BSW-JH</STOCK_CODE>'||
                     '<INSPECTION_LOT>00</INSPECTION_LOT>'||
                     '<USAGE_DECISION_CODE/>'||
                     '<MATERIAL_GROUP>031</MATERIAL_GROUP>'||
                     '</RAW_MATERIAL>';
          dbms_output.put_line('XML '||xml_message);
    --      vp_interface.load_rawmat@cnprpt1_pds(SYSDATE, destination_system,
    --                   xml_message, p_ret);
          vp_interface.load_rawmat(SYSDATE, destination_system,
                       xml_message, p_ret);
          dbms_output.put_line('Return Code '||p_ret);
          COMMIT;
    EXCEPTION
      WHEN OTHERS THEN
        status_code := SQLCODE;
        status_message := SUBSTR(SQLERRM, 1, 64);
    --    Extract_Error_Logger(proc_name, 'LOCAL', SYSDATE, -999,
    --                         status_message, 0, debug_message);
        ROLLBACK;
    END send_rm;
    And while i am calling this Store procedure in MII, I am facing error.
    I have tried different ways but didnt solved
    In SQL Query, i kept mode as: FixedQueryOutput
    Can anyone tell me or send code for calling above store procedure
    And onemore thing, While creating store procedure in Oracle for MII. Do we need to Create output parameter as cursor or normal.  
    Thanks,
    Kind Regards,
    Praveen Reddy M

    Hi Praveen
    Our wrapper was created because we could not modify the procedure we call (it was not returning a cursor).
    CREATE OR REPLACE PROCEDURE CHECK_PUT_IN_USE
    (STRCMPNAME in varchar2,
    STRSCANLABEL in varchar2,
    RCT1 out SYS_REFCURSOR
    AS
      charDispo          Char(1);
      charStatus          Char(1);
      intCatNo          Integer;
      charCatDispo     Char(1);
      strCatQual          VarChar2(2);
      strCatDesc          VarChar2(30);
      strMsg          VarChar2(128);
    BEGIN
    qa.check_put_in_use@AR(STRCMPNAME,
                                              STRSCANLABEL,
                                              charDispo,
                                              charStatus,
                                              intCatNo,
                                              charCatDispo,
                                              strCatQual,
                                              strCatDesc,
                                              strMsg);
    OPEN RCT1
    FOR Select charDispo,charStatus,charDispo,charStatus,intCatNo,charCatDispo,strCatQual,strCatDesc,strMsg from Dual;
    END;
    Hope this helps
    Regards
    Amrik
    then with a FixedQueryWithOutput
    call mixar.qasap.wrapper_update_put_in_use('[Param.1]','[Param.2]',[Param.3],?)
    Hope this helps.

  • How to run procedure(with paramater other than errbuff and retcode) through

    Hi everybody,
    This is Ram. I'm comfortable while running a procedure through concurrent program. but getting error when trying to run a procedure with parameter. Plz let me know the process (if possible example) of running a pl/sql procedure(with parameter) through concurrent programs..
    Regards,
    Ram.

    Hi
    It's difficult to know exactly what to modify to have no errors as those are not specified. However, the rule of thumb is for a procedure to be used as a concurrent program:
    procedure conc_prog(
    errbuf out varchar2
    , retcode out varchar2
    , param1 in varchar2 -- all additional parameters must by of IN type
    , paramn in varhcar2 ) ;
    On the concurrent program definition form, add the parameters from the third one, errbuf and retcode don't neet to be defined. Be careful on datatypes as date an numbers may have format mask problems when passed to your procedure and more possibility for this to happen is more than one language is installed. A safe way to pass those values would be to define parameters as varhchar2 and in your code, define a variable of the right type to use and assign the received value with the format mask defined for the value set associated to the parameter.

  • T-sql 2008 r2 place results from calling a stored procedure with parameters into a temp table

    I would like to know if the following sql can be used to obtain specific columns from calling a stored procedure with parameters:
    /* Create TempTable */
    CREATE TABLE #tempTable
    (MyDate SMALLDATETIME,
    IntValue INT)
    GO
    /* Run SP and Insert Value in TempTable */
    INSERT INTO #tempTable
    (MyDate,
    IntValue)
    EXEC TestSP @parm1, @parm2
    If the above does not work or there is a better way to accomplish this goal, please let me know how to change the sql?

    declare @result varchar(100), @dSQL nvarchar(MAX)
    set @dSQL = 'exec @res = TestSP '''+@parm1+''','' '''+@parm2+' '' '
    print @dSQL
      EXECUTE sp_executesql @dSQL, N'@res varchar(100) OUTPUT', @res = @result OUTPUT
    select @result
    A complicated way of saying
    EXEC @ret = TestSP @parm1, @parm2
    SELECT @ret
    And not only compliacated, it introduces a window for SQL injection.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Execute immediate for stored procedure with out parameter

    Hi,
    I have problem with dynamically executing the statement hope anyone can help me.
    I have a table which stores the procedure names. and procedure parameter values are stored on another column with parameter values coming from java side.
    I have to create a procedure that dynamically executes the procedure on table1 with the values from table 2.
    Now I'm getting real trouble to execute immediate this proc with parameters. I tried the DBMS_SQL package as well.
    Problem is you need to mention the OUT mode specifically for the out parameter. Can anybody plz help me with this issue??
    TABLE1_
    PROCESS_ID     PROC_NAME
    1      proc1(p1 IN number, p2 IN varchar2, p3 OUT varchar2)
    2     proc2(p1 IN number, p2 out varchar2, p3 OUT varchar2)
    TABLE2_
    PROCESS_ID     PROC_PARMS
    1     100, 'test', :return
    2     200, :return1, :return2
    Thank You

    826957 wrote:
    Hi,
    I have problem with dynamically executing the statement hope anyone can help me.
    I have a table which stores the procedure names. and procedure parameter values are stored on another column with parameter values coming from java side.
    I have to create a procedure that dynamically executes the procedure on table1 with the values from table 2.
    Now I'm getting real trouble to execute immediate this proc with parameters. I tried the DBMS_SQL package as well.
    Problem is you need to mention the OUT mode specifically for the out parameter. Can anybody plz help me with this issue??
    TABLE1_
    PROCESS_ID     PROC_NAME
    1      proc1(p1 IN number, p2 IN varchar2, p3 OUT varchar2)
    2     proc2(p1 IN number, p2 out varchar2, p3 OUT varchar2)
    TABLE2_
    PROCESS_ID     PROC_PARMS
    1     100, 'test', :return
    2     200, :return1, :return2
    Thank YouSounds like an appalling design and a nightmare waiting to happen.
    Why not have your Java just call the correct procedures directly?
    Such design smells badly of an entity attribute value modelling style of coding. Notoriously slow, notoriously buggy, notoriously hard to maintain, notoriously hard to read. It really shouldn't be done like that.

  • 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

  • Call stored procedure with OUT parameter

    Hello,
    I have created a short-lived process. Within this process I am using the "FOUNDATION > JDBC > Call Stored Procedure" operation to call an Oracle procedure. This procedure has 3 parameters, 2 IN and 1 OUT parameter.
    The procedure is being executed correctly. Both IN parameters receive the correct values but I am unable to get the OUT parameter's value in my process.
    Rewriting the procedure as a function gives me an ORA-01460 since one of the parameters contains XML (>32K) so this is not option...
    Has someone been able to call a stored procedure with an OUT parameter?
    Regards,
    Nico

    Object is Foundation, Execute Script
    This is for a query, you can change to a stored procedure call. Pull the value back in the Java code then put into the process variable.
    import javax.naming.InitialContext;
    import javax.sql.DataSource;
    import java.sql.*;
    PreparedStatement stmt = null;
    Connection conn = null;
    ResultSet rs = null;
    try {
    InitialContext ctx = new InitialContext();
    DataSource ds = (DataSource) ctx.lookup("java:IDP_DS");
    conn = ds.getConnection();
    stmt = conn.prepareStatement("select FUBAR from TB_PT_FUBAR where PROCESS_INSTANCE_ID=?");
    stmt.setLong(1, patExecContext.getProcessDataLongValue("/process_data/@inputID"));
    rs = stmt.executeQuery();
    rs.next();
    patExecContext.setProcessDataStringValue("/process_data/outData", rs.getString(1));
    } finally {
    try {
    rs.close();
    } catch (Exception rse) {}
    try {
    stmt.close();
    } catch (Exception sse) {}
    try {
    conn.close();
    } catch (Exception cse) {}

Maybe you are looking for

  • Getting error message only on certain pages

    I am testing Crystal Reports 10 on a windows 2008 platform and getting the following error only on some pages. Usually on first page of a report but sometimes on a later page. When it happens on the first page, the next pages work fine if I scroll th

  • Acquire RCA video using USB adapter and LabView

    Hi, I would like to know if it is possible to acquire RCA video using LabVIEW. I plan to use a RCA to USB adapter in order to connect the RCA device to my computer. What would I need to capture video using IMAQ USB driver? Thanks in advance for the h

  • Itunes playing videos

    I bought a new video at itunes, and it has no sound. You can see the video when you play it but there is absolutely no sound to it. Please tell me what is going on.

  • New implementation of toString() in Object.

    I think that it would be nice if the toString method in Object class also returns the data in the object. In the same way as org.apache.commons.lang.builder.ToStringBuilder does.

  • [Solved] Preview RAW files on Nautilus

    How do I set nautilus to as a preview RAW files? I have since I show the previews, but I not display them. Earlier in Debian and LMDE I can display them Greetings Rafa P.D.: I hope understand this. My english is not very good Last edited by Warper4 (