How to test a procedure that takes a PARAMETER array?

Oracle 9i

I created a procedure that takes an ARRAY PARAMETER (essentially a list of the IDS of employees and this procedure is called from the Java side), and the procedure is to remove the employees based on employee ID list.

I stated that the type employee_id_array is TABLE of NUMBER.

I want to test this procedure in sqlplus, but how to move this list of 'id table used' to this procedure, so I know it works?

Thank you.

Sure.

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:00.01
satyaki>
satyaki>
satyaki>create or replace type number_array as table of number;
  2  /

Type created.

Elapsed: 00:00:00.02
satyaki>
satyaki>
satyaki>CREATE OR REPLACE procedure delete_employee(
  2                                               p_employee_id_array in number_array
  3                                             )
  4  as
  5  begin
  6   for i in 1 .. p_employee_id_array.count
  7   loop
  8     --dbms_output.put_line ('this employee idis is: ' || p_query_id_array(i));
  9     delete from emp
 10     where empno in (to_number(p_employee_id_array(i)));
 11   end loop;
 12  end delete_employee;
 13  /

Procedure created.

Elapsed: 00:00:00.13
satyaki>
satyaki>
satyaki>select * from emp;

     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
      7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
      7903                                                 1000                    10
      7499 Travor     SALESMAN        7698 20-FEB-81       1600        300         30
      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

     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
      7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
      7900 JAMES      CLERK           7698 03-DEC-81        950                    30
      7902 FORD       ANALYST         7566 03-DEC-81       3000                    20

14 rows selected.

Elapsed: 00:00:00.16
satyaki>
satyaki>
satyaki>
satyaki>
satyaki>declare
  2     vv number_array := number_array(7903,7499);
  3  begin
  4    delete_employee(vv);
  5  end;
  6  /

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.15
satyaki>
satyaki>select * from emp;

     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
      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
      7900 JAMES      CLERK           7698 03-DEC-81        950                    30

     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
      7902 FORD       ANALYST         7566 03-DEC-81       3000                    20

12 rows selected.

Elapsed: 00:00:00.16
satyaki>

Kind regards.

LOULOU.

Tags: Database

Similar Questions

  • Try to run a procedure that takes as parameter VARRAY

    Hi gurus,
    I am trying to run a procedure having a table entry.
    However, I get an error during execution.
    Can you please help me on how to run a procedure having a table input?


    create or replace type type_a in the table to the number (10,0);

    Script:

    declare
    txn_id type_a
    Start
    txn_id type_a()
    txn_id (1): = 516963065;
    procedure_1 (emp_id = > 1001, txn_id)
    end;

    Besides above solutions, you must confirm that all variables have a corresponding input parameter, including the case even in the name of the variable, if your Oracle database is case-sensitive.

    Can you check and let us know your findings?

    Kind regards
    Ashutosh

  • How to provide a botton that takes a quick measure of the Isc and VOC?

    Right now I have a program that allows to measure Voc, Isc and the efficiency of the solar cell. How to provide a botton that takes a quick measure of the Isc and VOC and displays the result next the botton? I want to do this because I want to know VOCS and SAIS before hand, so that I can set the amplitude of scanning. In addition, I also want to set the initial time in seconds. At present, the time is 3 seconds, I can't find where to put them, is 3 seconds by default.

    Button not botton.

    It will be similar to what you have already in your another thread.

    Did you take the tutorials since then?  I highly recommend you do.

    LabVIEW Introduction course - 3 hours
    LabVIEW Introduction course - 6 hours

  • Need to query to find stored procedures that takes great execution time

    Hi all

    I use the oracle version below:

    Oracle Database 11 g Release 11.2.0.3.0 - 64 bit Production

    PL/SQL Release 11.2.0.3.0 - Production

    CORE Production 11.2.0.3.0

    AMT for Linux: Version 11.2.0.3.0 - Production

    NLSRTL Version 11.2.0.3.0 - Production

    is it possible to find the name of stored procedure that take too long to run, I need those optimized all SPs.

    Is there a query as top queries that are used to find queries albums that have great time for execution...

    or y at - it another way to find the names of MS. I try with AWR report but showing only used the names of MS.

    Thank you

    No, it not there no such request as far as I know.

    or y at - it another way to find the names of MS.

    Just listen to complaints from the user...

  • Cannot configure DBAdapter to call the procedure that takes no parameters

    Hello

    I created a test as a package below:

    create or replace package Tester
    as
    Main1 procedure;
    procedure (x VARCHAR2) Main2;

    end;

    create or replace package body Tester
    as

    procedure Main1
    is
    Start
    insert into ziptest values (' Main', sysdate);
    commit;
    end;

    procedure (x VARCHAR2) Main2
    is
    Start
    insert into ziptest values (' in Main2 :'|| x, sysdate);
    commit;
    end;

    end;
    ----------------------------------------
    When I try to configure a DB adapter to call the Main1 procedure, that I'll meet with the following error:
    An error occurred while getting stored procedures. Verify that the database connection is valid.

    If I try to configure the DB adapter to call Main2, it works without problem.
    In addition, this occurs only when the procedure is in a package. If the procedure is independent, no error is delivered.

    Is this a known bug or am I missing something. I use Jdev 10.1.3.4 and SOA Suite 10.1.3.4.

    Kind regards

    Amit

    Hi Amit,

    This is a bug in the wizard of DBAdapter. Try to update BPEL for the latest available patch, and if this does not work here workaround has been tested to work on 10.1.3.1 too!

    1. modify "Main1' to"Main1 (dummy IN VARCHAR2)"in your package.
    2. use the wizard of DBAdapter as ususal to create a partner link that hits this procedure has changed.
    3. change your procedure "Main1" back to the way it was IE without any parameters.
    4. in your BPEL process file, find the file .xsd to Main1 generated by the wizard in step 2. Replace ... inside the for the "InputParameters" element with an emty tag.

    Now, go ahead and invoke this link partner as usual. It would work! ;)

    Kind regards
    Ravi

  • How to test a procedure returns the result set

    Hello

    I have a following code:

    {color: #0000ff} create or replace the TYPES of PACKAGING
    AS
    type cursorType is ref cursor;
    end;

    create or replace PROCEDURE GetAllCategories (p_cursor in the Types.cursorType)
    AS
    Start
    Open p_cursor for SELECT * CATEGORY;
    end; {color}

    I would like to test the procedure of * {color: #000000} visualization output resultset {color} *. How can I do with SQL Developer?
    In fact, when select RUN in SQL Developer, I got the following code:

    DECLARE
    P_CURSOR types.cursorType;
    BEGIN

    GetAllCategories (P_CURSOR = & gt; P_CURSOR);
    END;

    When I run it, it is successful but there is no result set displayed. However if I execute SELECT * FROM category only in the SQL Editor, I see the result set in the grid. Then where the result set did when he went through the procedure?

    Thanks in advance for any help.

    Published by: CarbonFiber Sep 22, 2008 20:52

    Is a simple way with sqlplus

    SQL> create or replace package types
      2  as
      3     type cursortype is ref cursor;
      4  end;
      5  /
    
    Package created.
    
    SQL> create or replace procedure getallemp(p_cursor in out types.cursortype )
      2  as
      3  begin
      4     open p_cursor for select * from emp;
      5  end;
      6  /
    
    Procedure created.
    
    SQL> var lcursor refcursor
    SQL>
    SQL> exec getallemp(:lcursor)
    
    PL/SQL procedure successfully completed.
    
    SQL> print lcursor
    
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO        DIV
    ---------- ---------- --------- ---------- --------- ---------- ---------- ---------- ----------
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20         10
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30         10
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30         10
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20         10
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30         10
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30         10
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10         10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20         10
          7839 KING       PRESIDENT            17-NOV-81       5000                    10         10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30         10
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20         10
    
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO        DIV
    ---------- ---------- --------- ---------- --------- ---------- ---------- ---------- ----------
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30         10
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20         10
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    10         10
    
    14 rows selected.
    

    Thank you
    Knani.

  • Hi friends I want to know how to call a procedure that has values arrary as parameter?

    I have a procedure as shown below, and I am using oracle 11g.

    create or replace procedure procedureName (v_hospital_id in NUMBER,

    v_process_id VARR_VARRY,

    v_cnt OUT NUMBER);

    Now, how to call this procedure from PLSQL. If v_process_id values ('abc123', 'xyz234', 'sfs234')

    Please present the definition of VARR_VARRY

    If it's a simple table of varchar2.

    declare

    v_cnt NUMBER;

    Start

    procedureName (1, VARR_VARRY('abc123','xyz234','sfs234'), v_cnt);

    end;

  • How to test this package that has defined the user as input types

    Hello
    I have this part of my package where I try to put insert/update / delete based on the value of the attribute "action":

    I need to test this package of sql * more command line, could someone help me write a command run to test this package.



    CREATE or REPLACE PACKAGE pkg_test_process BODY
    AS

    PROCEDURE iud_issue_col
    (pv_issue_version IN issue_version_t
    )
    AS

    BEGIN

    DECLARE
    lv_im issue_version_t;


    BEGIN
    lv_im: = pv_issue_version;
    lv_level: = 'ISSUE_VERSION ';

    DECLARE
    lv_imv issue_maint_t;

    BEGIN
    lv_imv: = lv_im.issue_maint;
    lv_level: = 'ISSUE_MAINT ';
    Dbms_output.put_line ('for the many round table')

    IF lv_imv.action = 'I '.
    THEN
    INSERT
    IN
    test_process
    (im_key_id
    sec_cusip
    issr_key_id
    issuer_id_nm
    im_orig_usr_id
    im_orig_cre_tmstp
    org_ref_id
    delete_ind
    add_usr_id
    add_tmstmp
    lock_level_num
    )
    VALUES
    (lv_imv.im_key_id
    lv_imv.sec_cusip
    lv_issr_key_id
    lv_issuer_id_nm
    LC_USR_ID
    LC_TMSTMP
    ' 111 '
    "N" - deletion indicator
    LC_USR_ID
    LC_TMSTMP
    lv_imv.lock_level_num
    ) ;

    END;
    END;
    COMMIT WORK;
    RETURN;
    EXCEPTION
    WHILE OTHERS THEN
    ROLLBACK WORK;
    RAISE_APPLICATION_ERROR (-20000, impossible to insert in ' | lv_level, TRUE);
    END iud_issue_col;


    While the type 'issue_version_t' is:

    CREATE OR REPLACE TYPE ISSUE_MAINT_T
    AS AN OBJECT
    (
    Number IM_KEY_ID
    , SEC_CUSIP varchar2 (12)
    , DELETE_IND varchar2 (1)
    , ADD_USR_ID varchar2 (20)
    ADD_TMSTMP timestamp
    , UPD_USR_ID varchar2 (20)
    UPD_TMSTMP timestamp
    Number LOCK_LEVEL_NUM
    , ACTION VARCHAR2 (1)
    ISSUE_MAINT_VERSION ISSUE_MAINT_VERSION_T
    ISSUE_MAINT_COMMENT_COL ISSUE_MAINT_COMMENT_COL_T
    );


    Any help would be greatly appreciated.

    Hi Solsam,

    something like that,

    Declare
       pv_issue_version issue_version_t := issue_version_t(ISSUE_MAINT_T( 'value' --IM_KEY_ID
                                                                        , 'value' --SEC_CUSIP
                                                                        , 'value' --DELETE_IND
                                                                        , 'value' --ADD_USR_ID
                                                                        , 'value' --ADD_TMSTMP
                                                                        , 'value' --UPD_USR_ID
                                                                        , 'value' --UPD_TMSTMP
                                                                        , 'value' --LOCK_LEVEL_NUM
                                                                        , 'value' --ACTION
                                                                        , ISSUE_MAINT_VERSION_T( 'value'
                                                                                               , 'value'
                                                                                               , ...
                                                                                               )
                                                                        , ISSUE_MAINT_COMMENT_COL_T( 'value'
                                                                                                   , 'value'
                                                                                                   , ...
                                                                                                   )
                                                                        );
    Begin
       pkg_test_process.iud_issue_col( pv_issue_version );
    End;
    /
    

    Kind regards
    Christian Balz

  • How to run a report that takes too long

    Hi all

    I can't run a report (report version is 9i) that crashes, cause it takes too much time.

    I think I need to run in batch mode, do I try to use the following syntax:

    rwun < oracle_home > < report name > < report parameter > on the server application, but nothing happens... no error not any warnings messages, I configure anything?

    Thanks in advance for your support
    Antonio

    Hello

    When you use rwrun, errors are saved to a file reports.log

    This file will be generated in the directory 'active '.

    This means that the directory that you were when you called rwrun

    Concerning

  • How to delete a photo that takes up the entire screen

    When I'm not on the internet, a picture of my picture library appears on the screen as more wrinkles my desktop icons. How can I remove the image

    See http://windows.microsoft.com/en-US/windows7/change-your-desktop-background-wallpaper

  • How to reverse the direction that takes the type on a path?

    I need to change the orientation of the text on a path. Basically it is written the phrase back now. I need to type from right to left instead of left to right, so the first word of the sentence will be completely left instead of all the way to the right.

    Thank you

    skeeterz,

    When you select the Type of path with the normal (black) selection tool, you should see the i-beam type begins. If you ClickDrag on the path, the type must return on the other side and read the other way. You can pay by the vertical offset of the character Panel to do things.

  • I am back! test a procedure through PL/SQL block

    Hi all!

    Do you know how to test a procedure? Please check mine, its gave me an error of what follows:-see the bottom of my test pls/sql code:
    ORA-06550: line 4, column 1:
    PLS-00306: wrong number or types of arguments in the call to 'MEMBER_CK_SP '.
    ORA-06550: line 4, column 1:
    PL/SQL: Statement ignored
    2 lv_name varchar2 (20);
    3. start to
    4 member_ck_sp('rat55','kile',lv_name);
    5 end;
    6. /

    CREATE OR REPLACE PROCEDURE member_ck_sp
    (p_id IN VARCHAR2,
    p_pw IN OUT VARCHAR2,
    p_cook ON the NUMBER,
    p_check OUT VARCHAR2)
    IS
    BEGIN
    SELECT firstname. » '|| LastName, cookie
    IN p_pw, p_cook
    OF bb_shopper
    WHERE username = p_id
    AND password = p_pw;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    p_check: = 'INVALID ';
    END;
    /
    -This is the test of the procedure-
    declare
    lv_name varchar2 (20);
    Start
    member_ck_sp ('rat55', 'kile', lv_name);
    end;
    /

    For not being "Captain obvious" but your procedure takes 4 parameters, and you go to 3... so the wrong number of arguments error...

  • How to run a procedure with the object as OUTPUT parameter

    Hello

    I have a procedure and it composed of 2 parameters, there is an input parameter and it's some ID (NUMBER datatype) and 2nd parameter is an output parameter and it an object type. I want to run this procedure, but not able to do the same thing. Can someone please suggest me how to run a procedure that got the object as output parameter.

    Thank you very much in advance for your support.

    Example:

    SQL> create or replace type t_obj as object (ename varchar2(10), deptno number);
      2  /
    
    Type created.
    
    SQL> ed
    Wrote file afiedt.buf
    
      1  create or replace procedure myproc (p_empno in number, obj out t_obj) is
      2  begin
      3    select t_obj(ename, deptno)
      4    into obj
      5    from emp
      6    where empno = p_empno;
      7* end;
    SQL> /
    
    Procedure created.
    
    SQL> set serverout on
    SQL> declare
      2    v_obj t_obj;
      3  begin
      4    myproc(7788, v_obj);
      5    dbms_output.put_line(v_obj.ename||','||v_obj.deptno);
      6  end;
      7  /
    SCOTT,20
    
    PL/SQL procedure successfully completed.
    
  • How to test the stored procedure in SQL Developer or SQL Plus

    Hello

    It's small, but I am confused. Can someone give me the EXACT command to run to test my stored procedure described below. Please don't refer me to the documentation or offer some sort of pseudocode. I've been through the documentation - and through it again - and I just don't get it. I know that the procedure works in general because I'm calling ColdFusion, but I want to test developer SQL or SQL more before I call my ColdFusion page - it only makes sense. I'm probably not initialize variables right or something - not sure.

    You will see that it is a line right insert in the firstname and lastname data base and there are 2 IN OUT values as well. Please use a fake name for the firstname and lastname values to demonstrate. I appreciate it!

    create or replace
    procedure sp_insertDirector_A)
    vFirstname IN Directors.Firstname%TYPE,
    vLastname IN Directors.Lastname%TYPE,
    vInsertStatus in on NUMBER,
    vNewDirectorID IN OUT NUMBER
    )
    IS
    row_count NUMBER;
    BEGIN
    SELECT Count (*) FROM directors WHERE Lastname vLastname = row_count;
    IF row_count > 0 THEN
    vInsertStatus: = - 1;
    RETURN;
    END IF;

    INSERT INTO administration)
    FirstName, Lastname)
    VALUES)
    vFirstname, vLastname
    );

    SELECT Directors_Seq.CURRVAL INTO vNewDirectorID FROM DUAL;
    vInsertStatus: = 1;
    END;

    If someone can tell me exactly how to test, I'd appreciate it. I asked on another site and got many responses that I tried and did not work due to various errors. Once I get a working example, I'm sure I can get the idea and continue on. I mainly use the SQL Developer.

    Thank you, mallethead

    p.s. I think that my if - THEN followed by the instruction INSERT is fixed - it is woring. Seems a little odd to me however.
    declare
       l_instatus  number;
       l_newdirid  number;
    begin
       sp_insertDirector_A('bob','smith',l_instatus,l_newdirid);
       dbms_output.put_line(l_instatus);
       dbms_output.put_line(l_newdirid);
    end;
    /
    
  • is it possible to tell me how I can make program in labview that take black and with image pixels and give the coordinates of black or white pixels again to me.

    Hello everyone

    is it possible to tell me how I can make program in labview that take black and with image pixels and give the coordinates of black or white pixels again to me.

    It depends on the image and the module LabVIEW available to you. LabVIEW can open bitmap and png files and convert them into tables: if it's really a monochromatic (depth of 1 bit) you get a table 2D boolean, T for white, F for black. Just look at the index of the item to its details (don't forget that LabVIEW does not use the order of rows and columns, so you must transpose and reflect the table). If you have a 24 bit bitmap, the table will contain the color in hexadecimal synthesis (000000 for black, FFFFFF is white and so on); Yet once, you simply check if the element of the array correspond to your requirements and get its index.

    With the vision that you module con open other pictures and perform advanced on them without convert them into tables. Anyway, you can just type the extension of your image using LabVIEW and see what you get.

    Here is a code snippet to open a monochromatic image

Maybe you are looking for