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

Similar Messages

  • Calling stored procedure with output parameters in a different schema

    I have a simple stored procedure with two parameters:
    PROCEDURE Test1(
    pOutRecords OUT tCursorRef,
    pIdNumber IN NUMBER);
    where tCursorRef is REF CURSOR.
    (This procedure is part of a package with REF CURSOR declared in there)
    And I have two database schemas: AppOwner and AppUser.
    The above stored procedure is owned by AppOwner, but I have to execute this stored procedure from AppUser schema. I have created a private synonym and granted the neccessary privileges for AppUser schema to execute the package in the AppUser schema.
    When I ran the above procedure from VB using ADO and OraOLEDB.Oracle.1 driver, I got the following error when connecting to the AppUser schema:
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'TEST1'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    but when I was connecting to the AppOwner schema, everything is running correctly without errors.
    Also, when I switch to the microsoft MSDAORA.1 driver, I can execute the above procedure without any problems even when connecting to the AppUser schema.
    I got this error only when I am trying to execute a stored procedure with an output parameter. All other procedures with only input parameters have no problems at all.
    Do you know the reason for that? Thanks!

    If anyone has figured this one out let me know. I'm getting the same problem. Only in my case I've tried both the "OraOLEDB.Oracle" provider and the "MSDAORA" provider and I get an error either way. Also my procedure has 2 in parameters and 1 out parameter. At least now I know I'm not the only one with this issue. :)
    '*** the Oracle procedure ***
    Create sp_getconfiguration(mygroup in varchar2, myparameter in varchar2, myvalue out varchar2)
    AS
    rec_config tblconfiguration.configvalue%type;
    cursor cur_config is select configvalue from tblconfiguration where configgroup = mygroup and configparameter = myparameter;
    begin
    open cur_config;
    fetch cur_config into rec_config;
    close cur_config;
    myvalue := rec_config;
    end;
    '** the ado code ****
    dim dbconn as new adodb.connection
    dim oCmd as new adodb.connection
    dim ors as new adodb.recordset
    dbconn.provider = "MSDAORA" 'or dbconn.provider = "OraOLEDB.Oracle"
    dbconn.open "Data Source=dahdah;User ID=didi;Password=humdy;PLSQLRSet=1;"
    set ocmd.activeconnection = dbconn
    cmd.commandtext = "{call fogle.sp_getconfiguration(?,?)}"
    'i've also tried creating a public synonym called getconfiguration and just refering to procedure by that.
    ' "{call getconfiguration(?, ?)}"
    ' "{call getconfiguration(?,?, {resultset 1, myvalue})}"
    'and numerous numerous other combinations
    set oPrm = cmd.createparameter("MYGROUP", advarchar, adparaminput, 50, strGrouptoPassIn$)
    cmd.parameters.append oPrm
    set oPrm = cmd.createParameter("MYPARAMETER", advarchar, adParamInput, 50, strParameterToPassIn$)
    cmdParameters.append oPrm
    set rs = cmd.execute

  • Problem Calling MaxDB stored procedure with output from MII Query template

    Hi,
    I am using Max DB Database studio to write stored procedure, I am calling stored procedure from MII Query using CALL statement.
    Can anyone guide me how to pass output values of stored procedure.
    Examlpe::
    call ProcName('[Param.1]','[Param.2]','[Param.3]','[Param.4]','[Param.5]', :isSuccess, :Trace)
    In the above line of code I am not able to get the output values of stored procedure that is isSuccess and Trace values in Query template when executed. But same thing I get when executed in Database studio.
    How do I call with outputs for any stored procedure in MII.
    Any help would be appriciated.
    Thanks,
    Padma

    My call statement is like this
    call RESULTDATA_INSERT('[Param.1]','[Param.2]','[Param.3]', :isSuccess, :Trace)
    I am able to insert record in DB, But I am not getting output values in Query template.I have done this in Fixed Query, when I execute it throws me "Fatal error as Loaded content empty".
    I tried giving select below call but it dont work.
    Regards,
    Rao

  • 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.

  • Calling a stored procedure with default parameters

    Dear all,
    I am trying to call a stored procedure that has not all the parameters compulsory, and indeed, there are some I am not interested in. Therefore, I would like to call the stored procedure initializing only some of the parameters but if I miss some of them, I have an SQLException thrown. Is there any way to do that?
    Thanks
    Marie

    Hi
    One way to do it is ---
    By using Default Parameters you can miss few parameters while calling a procedure.
    =================================================================
    As the example below shows, you can initialize IN parameters to default values. That way, you can pass different numbers of actual parameters to a subprogram, accepting or overriding the default values as you please.
    Moreover, you can add new formal parameters without having to change every call to the subprogram.
    PROCEDURE create_dept (
    new_dname VARCHAR2 DEFAULT 'TEMP',
    new_loc VARCHAR2 DEFAULT 'TEMP') IS
    BEGIN
    INSERT INTO dept
    VALUES (deptno_seq.NEXTVAL, new_dname, new_loc);
    END;
    If an actual parameter is not passed, the default value of its corresponding formal parameter is used.
    Consider the following calls to create_dept:
    create_dept;
    create_dept('MARKETING');
    create_dept('MARKETING', 'NEW YORK');
    The first call passes no actual parameters, so both default values are used.
    The second call passes one actual parameter, so the default value for new_loc is used.
    The third call passes two actual parameters, so neither default value is used.
    Usually, you can use positional notation to override the default values of formal parameters.
    However, you cannot skip a formal parameter by leaving out its actual parameter.
    For example, the following call incorrectly associates the actual parameter 'NEW YORK' with the formal parameter new_dname:
    create_dept('NEW YORK'); -- incorrect
    You cannot solve the problem by leaving a placeholder for the actual parameter.
    For example, the following call is illegal:
    create_dept(, 'NEW YORK'); -- illegal
    In such cases, you must use named notation, as follows:
    create_dept(new_loc => 'NEW YORK');
    ===============================================================
    For more details refer URL http://technet.oracle.com/doc/server.804/a58236/07_subs.htm#3651
    Hope this helps
    Regards
    Ashwini

  • Calling Oracle Stored procedure with OUT parameter from ODI

    Hi,
    I called an oracle stored procedure with following anonymous block in the ODI procedure.
    Declare
    Status varchar2(10);
    Begin
    OTM.DeleteTarget('E_KPI_TARGET_VALUE', Status);
    End;
    I want to capture the OUT parameter STATUS value in a project level variable.
    And based on its va;lue I would like to choose between 2 interfaces in my package.
    Please help me in doing this.

    Hi,
    For that kind of situation I commoly use:
    1) one step with:
    create or replace package <%=odiRef.getSchemaName("W")%>.pck_var
    Status varchar2(10);
    end;
    * transaction 9, for instance
    2) step
    Begin
    OTM.DeleteTarget('E_KPI_TARGET_VALUE', <%=odiRef.getSchemaName("W")%>.pck_var.Status);
    End;
    * transaction 9
    3) then, at an ODI variable, use a refresh like:
    select <%=odiRef.getSchemaName("W")%>.pck_var.Status from dual
    at same logical shema where the package was created.
    Does it make sense to you?

  • Problem in calling of stored procedure with variable parameters

    Hello!
    When we try to call our stored procudure with variable parameter (year and month) we receive various errors.
    Here's the dynamic package script code:
    DEBUG(ON)
    PROMPT(SELECTINPUT,,,"Please select time for restatement",%TIME_DIM%)
    TASK(Execute formulas,USER,%USER%)
    TASK(Execute formulas,APPSET,%APPSET%)
    TASK(Execute formulas,APP,%APP%)
    TASK(Execute formulas,SELECTION,%SELECTIONFILE%)
    TASK(Execute formulas,LOGICFILE,%APPPATH%\..\AdminApp\%APP%\zbpc_to_fm.lgx)
    TASK(Execute formulas,RUNMODE,1)
    TASK(Execute formulas,LOGICMODE,1)
    TASK(Execute formulas,SIMULATION,1)
    TASK(Execute formulas,CHECKLCK,0)
    Our logic script file (zbpc_to_fm.lgx) code is:
    *RUN_STORED_PROCEDURE=ztest('%TIME_SET%')
    *commit
    The problem occures while transferring the variable parameter %TIME_SET% value.
    How can we correctly transfer the selected value of TIME_SET into the procedure?

    Everything in the debug log looks correct -- the most important lines are the ones indicating the values passed from the user's response to the PROMPT(SELECTINPUT...)
    INFO(%CATEGORY_SET%, BUDGET)
    INFO(%ENTITY_SET%, 1733)
    INFO(%FUND_SET%, )
    INFO(%PROJECT_SET%, )
    INFO(%TIME_SET%, 2008.NOV)
    Are you certain that the stored proc is processing the input parameter for time correctly, when you run it directly in MS Mgmt Studio?
    What error messages do you see running it from BPC?
    By "customized user authorities" do you mean that the time dimension is secured, and this user has access only to 2008.total and its descendants? If that's the case, the user should be able to see only those members in the action pane / current view, but the SELECTINPUT prompt should only show the base members (and not the year total and quarters). I'm still confused as to why all 12 + 4 + 1 members are passed through to the stored proc.

  • Calling stored procedures with output parameters using RDO and VB

    I have a simple test procedure defined as follows:
    CREATE OR REPLACE PROCEDURE test_sp (inval1 IN VARCHAR2,
    inval2 IN NUMBER, inval3 OUT VARCHAR2, inval4 OUT NUMBER) IS
    BEGIN
    inval3 := 'RETURN TEST';
    inval4 := 10;
    END;
    I am attempting to call this procedure from VB 5.0 using RDO and the Oracle ODBC Driver 8.01.06:
    dim rdoQd as rdoQuery
    dim grdoCn as rdoConnection
    strSQL = "{ call test_sp('SOMETHING',?,?,?) }"
    Set rdoQd = grdoCn.CreateQuery("", strSQL)
    rdoQd(0).Direction = rdParamInput
    ' get error# 40041 at above line
    ' "Object Collection: Couldn't ' find item indicated by text."
    rdoQd(0).Type = rdTypeINTEGER
    rdoQd(0).Value = 5
    rdoQd(1).Direction = rdParamOutput
    rdoQd(1).Type = rdTypeVARCHAR
    rdoQd(2).Direction = rdParamOutput
    rdoQd(2).Type = rdTypeINTEGER
    Set rdoApp = rdoQd.OpenResultset()
    MsgBox (CStr(rdoQd(1)))
    MsgBox (CStr(rdoQd(2)))
    When I run this VB code, I get the above mentioned error. If I use placeholders for all parameters (like "{ call test_sp (?,?,?,?) }" ), no error occurs.
    I really need to use the first type of syntax from above and not have to use placeholders for all parameters. Is there a way to accomplish this?
    TIA,
    Esther

    Are you getting any warning while importing the stored procedure?
    Please check the below datatypes:
    While creating the stored procedure, if you have used varchar(MAX), please ALTER it to varchar(255) and reimport to DS.
    Also, the datatype of $message (global variable or local variable) used inside DS should also be varchar(255)
    Try a print statement in between.
    ADMIN.DBO.SPJOBSUMMARY(69,$message,$rtCode,$rtVal);
    print('Message is '||$message);
    smtp_to('leighattest.com.au', 'Results of ' || job_name(), $rtCode || '//' || $rtVal || '~~' || $message || '//', 0,0);
    and see in the job log if DS is able to retrieve the output from DB.
    Regards,
    Suneer

  • Trouble with calling a stored procedure with VARCHAR parameter from trigger

    Hi everybody,
    today I ran across a problem with stored procedures and triggers that try to call them. Background info: I want to log changes in certain tables to another table in a trigger, so I can replicate the changes to another (non-Oracle) database in an asynchronous way. As an example I have the first data table "bak_s3_berufliste" and the table to store the changes in is "bak_s3_change_request".
    DROP TABLE BAK_S3_BERUFLISTE;
    CREATE TABLE bak_s3_berufliste (
    id_bl NUMBER(27,0) NOT NULL,
    berufsbez VARCHAR2(255),
    CONSTRAINT PK_BAK_S3_BERUFLISTE PRIMARY KEY (id_bl) ENABLE);
    DROP TABLE bak_s3_change_request;
    CREATE TABLE bak_s3_change_request (
    ID_CR NUMBER(27,0) NOT NULL,
    TABELLE_NAME VARCHAR2(50) NOT NULL,
    TABELLE_ID_ALT NUMBER(27,0),
    TABELLE_ID_NEU NUMBER(27,0),
    CONSTRAINT PK_BAK_S3_CHANGE_REQUEST PRIMARY KEY (ID_CR) ENABLE);
    DROP SEQUENCE seq_bak_s3_change_request;
    CREATE SEQUENCE seq_bak_s3_change_request;
    For testing purposes I created the following stored procedure and trigger:
    CREATE OR REPLACE PROCEDURE schreibe_cr (t_id_alt IN NUMBER, t_id_neu IN NUMBER) IS
    BEGIN
    INSERT INTO bak_s3_change_request(ID_CR, TABELLE_NAME, TABELLE_ID_ALT, TABELLE_ID_NEU)
    VALUES (seq_bak_s3_change_request.NEXTVAL, t_name, t_id_alt, t_id_neu);
    END;
    CREATE OR REPLACE TRIGGER trg_bak_s3_berufliste
    BEFORE INSERT OR UPDATE OR DELETE ON bak_s3_berufliste
    FOR EACH ROW
    call schreibe_cr(:old.id_bl,:new.id_bl)
    *... and everything worked perfectly - except from the fact that I need to know which table had changed of course. So I added another parameter to the stored procedure:*
    CREATE OR REPLACE PROCEDURE schreibe_cr (t_name IN VARCHAR2, t_id_alt IN NUMBER, t_id_neu IN NUMBER) IS
    BEGIN
    INSERT INTO bak_s3_change_request(ID_CR, TABELLE_NAME, TABELLE_ID_ALT, TABELLE_ID_NEU)
    VALUES (seq_bak_s3_change_request.NEXTVAL, t_name, t_id_alt, t_id_neu);
    END;
    and tested it:
    CALL schreibe_cr('Test',1,2);
    *... successfully. So I also added the parameter to the trigger:*
    CREATE OR REPLACE TRIGGER trg_bak_s3_berufliste
    BEFORE INSERT OR UPDATE OR DELETE ON bak_s3_berufliste
    FOR EACH ROW
    call schreibe_cr('Tabellenname',1,2)
    and what i get is:
    Error starting at line 31 in command:
    CREATE OR REPLACE TRIGGER trg_bak_s3_berufliste
    BEFORE INSERT OR UPDATE OR DELETE ON bak_s3_berufliste
    FOR EACH ROW
    call schreibe_cr('Tabellenname',1,2)
    When I try to insert something into that table I get the following error:
    insert into bak_s3_berufliste (id_bl, berufsbez) values (seq_bak_s3_change_request.NEXTVAL, 'tueduelue');
    Error report:
    ORA-00911: Ungültiges Zeichen
    00911. 00000 - "invalid character"
    Cause: identifiers may not start with any ASCII character other than
    letters and numbers. $#_ are also allowed after the first
    character. Identifiers enclosed by doublequotes may contain
    any character other than a doublequote. Alternative quotes
    (q'#...#') cannot use spaces, tabs, or carriage returns as
    delimiters. For all other contexts, consult the SQL Language
    Reference Manual.
    Action:
    I tried everything that came to my mind, like using double-quotes (") instead of quotes (') in the trigger code or escaping the quotes (\'), but nothing worked. Can anybody help my and tell me what's wrong? After googling for hours I'm outta ideas :-(
    Any ideas appreciated!
    Thanks in advance,
    Jens

    Why?
    Are you looking for this?
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    Elapsed: 00:00:01.61
    satyaki>
    satyaki>
    satyaki>create table aud_dup_emp
      2     as
      3       select empno, ename
      4       from dup_emp
      5       where 1=2;
    Table created.
    Elapsed: 00:00:01.86
    satyaki>
    satyaki>select * from dup_emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       4450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       7000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
    18 rows selected.
    Elapsed: 00:00:00.10
    satyaki>
    satyaki>
    satyaki>create or replace procedure ins_aud_dup(eno in number, enm in varchar2)
      2     is
      3     begin
      4       insert into aud_dup_emp(empno,ename) values(eno,enm);
      5     end;
      6  /
    Procedure created.
    Elapsed: 00:00:03.36
    satyaki>
    satyaki>
    satyaki>
    satyaki>ed
    Wrote file afiedt.buf
      1  create or replace trigger trg_aud_dup
      2  before insert on dup_emp
      3     for each row
      4     begin
      5       ins_aud_dup(:old.empno,:new.ename);
      6*    end;
    satyaki>/
    Trigger created.
    Elapsed: 00:00:01.47
    satyaki>
    satyaki>
    satyaki>select * from aud_dup_emp;
    no rows selected
    Elapsed: 00:00:00.10
    satyaki>
    satyaki>
    satyaki>insert into dup_emp(empno,ename,deptno) values(8855,'BILLY',40);
    1 row created.
    Elapsed: 00:00:00.19
    satyaki>
    satyaki>commit;
    Commit complete.
    Elapsed: 00:00:00.03
    satyaki>
    satyaki>
    satyaki>select * from dup_emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       4450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       7000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          8855 BILLY                                                                   40
    19 rows selected.
    Elapsed: 00:00:00.20
    satyaki>
    satyaki>select * from aud_dup_emp;
         EMPNO ENAME
               BILLY
    Elapsed: 00:00:00.09
    satyaki>Regards.
    Satyaki De.

  • Can you get values back from a stored procedure via OUTPUT parameters?

    Can you get values back from calling a stored procedure via OUTPUT parameters/variables? I call the SP via a SQL statement from a script either in a WF or DF.
    I thought I read some reference that DI could not get the values from OUTPUT parameters but I could not find it again (don't know if it is in any of the documentation or referred to in a forum.
    I did try a couple of tests but it did not reutrn any values via OUTPUT. But before I give up I thought I'd see if you could and maybe I needed to change something.

    This isn't exactly an answer to your question, but I'll point out that, given that you're resorting to a SQL script in the first place, there's no reason you can't also turn the output parameters into a regular result or record set. (The following uses T-SQL, although I think it's pretty generic.)
    declare @param1 int, param2 varchar(100), @return int;
    exec @return = proc @param1 = @param1 output, @param2 = @param2 output;
    select @param1 as param1, @param2 as param2;
    That is, to get from output parameters to a "regular" output from the SQL script isn't much of a leap...
    Jeff Prenevost
    BI Consultant
    Ann Arbor, MI

  • 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]

  • Calling DB2 Stored procedure(with parameters) from powershell

    Hi 
    I am trying to call a DB2 stored procedure that has parameters from Powershell scrip and I am not able to can some one help me here?
    $ServerName = 'XXXX'
    $dbalias='XXXXX'
     $conn_string = "Provider=IBMDADB2;DBALIAS=$dbalias;Uid=;Pwd=;"
     $conn = new-Object system.data.Oledb.OleDbconnection
     $conn.ConnectionString = $conn_string
     $conn.open()
     $query="CALL DBID_CONTROL.GET_TABLE_MAINT_CTL(?,?,?,'MSAS','DATABASE_CONNECTIONS_CUBE','CUBE_PARTITION');"
     $cmd = new-Object system.data.Oledb.OleDbcommand($query,$conn)
      $ds=New-Object system.Data.DataSet
     $da=New-Object System.Data.OleDb.OleDbDataAdapter($cmd)
      $da.Fill($ds) [int]$cur_utc_date_key = $ds.Tables[0].Rows[0][0]
     $cur_utc_date          = $ds.Tables[0].Rows[0][1]
     ###list current date key & current date values
     write-output "current date key value is $cur_utc_date_key"
     write-output "current date value is $cur_utc_date"
     write-output " "
    Thanks

    Hi 
    This is the error message i get when i run the script
    Exception calling "Fill" with "1" argument(s): " CLI0100E  Wrong number of parameters. SQLSTATE=07001"
    At line:45 char:10
    +  $da.Fill <<<< ($ds)
        + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
        + FullyQualifiedErrorId : DotNetMethodException

  • How to call stored procedure with multiple parameters in an HTML expression

    Hi, Guys:
    Can you show me an example to call stored procedure with multiple parameters in an HTML expression? I need to rewrite a procedure to display multiple pictures of one person stored in database by clicking button.
    The orginal HTML expression is :
    <img src="#OWNER#.dl_sor_image?p_offender_id=#OFFENDER_ID#" width="75" height="75">which calls a procedure as:
    procedure dl_sor_image (p_offender_id IN NUMBER)now I rewrite it as:
    PROCEDURE Sor_Display_Current_Image(p_n_Offender_id IN NUMBER, p_n_image_Count in number)could anyone tell me the format for the html expression to pass multiple parameters?
    Thanks a lot.
    Sam

    Hi:
    Thanks for your help! Your question is what I am trying hard now. Current procedure can only display one picture per person, however, I am supposed to write a new procedure which displays multiple pictures for one person. When user click a button on report, APEX should call this procedure and returns next picture of the same person. The table is SOR_image. However, I rewrite the HTML expression as follows to test to display the second image.
    <img src="#OWNER#.Sor_Display_Current_Image?p_n_Offender_id=#OFFENDER_ID#&p_n_image_Count=2" width="75" height="75"> The procedure code is complied OK as follows:
    create or replace
    PROCEDURE Sor_Display_Current_Image(p_n_Offender_id IN NUMBER, p_n_image_Count in number) AS
        v_mime_type VARCHAR2(48);
        v_length NUMBER;
        v_name VARCHAR2(2000);
        v_image BLOB;
        v_counter number:=0;
        cursor cur_All_Images_of_Offender is
          SELECT 'IMAGE/JPEG' mime_type, dbms_lob.getlength(image) as image_length, image
          FROM sor_image
          WHERE offender_id = p_n_Offender_id;
        rec_Image_of_Offender cur_All_Images_of_Offender%ROWTYPE;
    BEGIN
        open cur_All_Images_of_Offender;
        loop
          fetch cur_All_Images_of_Offender into rec_Image_of_Offender;
          v_counter:=v_counter+1;
          if (v_counter=p_n_image_Count) then
            owa_util.mime_header(nvl(rec_Image_of_Offender.mime_type, 'application/octet'), FALSE);
            htp.p('Content-length: '||rec_Image_of_Offender.image_length);
            owa_util.http_header_close;
            wpg_docload.download_file (rec_Image_of_Offender.image);
          end if;
          exit when ((cur_All_Images_of_Offender%NOTFOUND) or (v_counter>=p_n_image_Count));
        end loop;
        close cur_All_Images_of_Offender;
    END Sor_Display_Current_Image; The procedure just open a cursor to fetch the images belong to the same person, and use wpg_docload.download_file function to display the image specified. But it never works. It is strange because even I use exactly same code as before but change procedure name, Oracle APEX cannot display an image. Is this due to anything such as make file configuration in APEX?
    Thanks
    Sam

  • Calling a stored procedure with RAW and SYS_REFCURSOR

    How do you call a stored procedure with the following input and output parameters?
    create or replace PROCEDURE test
    v_col1 IN NUMBER DEFAULT NULL ,
    v_col2 IN VARCHAR2 DEFAULT NULL ,
    v_col3 IN RAW DEFAULT NULL ,
    v_vol4 IN DATE DEFAULT NULL,
    cv_1 IN OUT SYS_REFCURSOR
    OPEN cv_1 FOR
    SELECT
    lv_tmp1 aaaa ,
    lv_tmp2 bbbb,
    lv_tmp3 cccc
    FROM DUAL ;
    END;
    Edited by: 925963 on Apr 6, 2012 10:50 AM

    Did you try just declaring the vars?
    untested
    declare
      myCur SYS_REFCURSOR;
      myRaw RAW(4);
      BEGIN
        test (0, 0, myRaw, sysdate, myCur);
      END;

  • 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

Maybe you are looking for

  • G6-2102 ev card reader?

    Greetings. The laptop G6-2102 EV has a "Multi-format digital media card reader". What do I need to get/buy to read a micro sd for exaple? Some sort of adapter accessory? This question was solved. View Solution.

  • Tecra A3 106 Noise on Audio Output while Charging

    Hello all, My Tecra A3 generates an annoying noise on line out/headphone output while charging the battery. when it's unplugged, the noise goes off. Is that normal? Thanks in advance. Onur.

  • Multi message to Proxy ABAP without BPM possible?

    Hi Experts, I am designing a scenario where my source is a flat file and the target SAP. According to the content of the file, we would like to group the data per company and then send the grouped data. The question is, is it possible to send data in

  • Presets are missing since upgrading to Lightroom 5

    Since upgrading to Lightroom 5 a number of Adobe Presets I purchased are no longer available.  All of my HDR, Tilt Shift, Dragon as well as other presets are not available within the appliction even though they are still in the Preset folder. How do

  • Media Encoder - very bad resizing quality

    The problem is when i want to resize HD video from it's original size 1440x1080 50i (16x9) to DV PAL 720x576 (4x3) 50i to the full frame size (without black borders) using crop - the video quality even in preview looks really bad. The whole image get