Note that there are some explanatory texts on larger screens.

plurals
  1. POpass pl/sql record as arguement to procedure
    primarykey
    data
    text
    <p>How to pass pl/sql record type to a procedure :</p> <pre><code>CREATE OR REPLACE PACKAGE BODY PKGDeleteNumber AS PROCEDURE deleteNumber ( list_of_numbers IN List_Numbers ) IS i_write VARCHAR2(5); BEGIN --do something END deleteNumber; END PKGDeleteNumber; / </code></pre> <p>In this procedure <code>deleteNumber</code> I have used <code>List_Numbers</code>, which is a record type. The package declaration for the same is :</p> <pre><code>CREATE OR REPLACE PACKAGE PKGDeleteNumber AS TYPE List_Numbers IS RECORD ( IID NUMBER ); TYPE list_of_numbers IS TABLE OF List_Numbers; PROCEDURE deleteNumber ( list_of_numbers IN List_Numbers ); END PKGDeleteNumber; </code></pre> <p>I have to execute the procedure <code>deleteNumber</code> passing a list of values. I inserted numbers in <code>temp_test</code> table, then using a cursor U fetched the data from it :</p> <pre><code> SELECT * BULK COLLECT INTO test1 FROM temp_test; </code></pre> <p>Now, to call the procedure I am using</p> <pre><code>execute immediate 'begin PKGDELETENUMBER.DELETENUMBER(:1); end;' using test1; </code></pre> <p>I have tried many other things as well(<code>for loop</code>, <code>dbms_binding</code>, etc). How do I pass a pl/sql record type as argument to the procedure?</p> <p>EDIT:</p> <p>Basically, I want to pass a list of numbers, using native dynamic sql only...</p> <p>adding the table temp_test defn (no index or constraint):</p> <pre><code>create table test_temp ( IID number ); </code></pre> <p>and then inserted 1,2,3,4,5 using normal <code>insert</code> statements.</p> <p>For this solution,</p> <pre><code>In a package testproc CREATE TYPE num_tab_t IS TABLE OF NUMBER; CREATE OR REPLACE PROCEDURE my_dyn_proc_test (p_num_array IN num_tab_t) AS BEGIN dbms_output.put_line(p_num_array.COUNT); END; / </code></pre> <p>this is called from sql prompt/toad DECLARE v_tab testproc.num_tab_t := testproc.num_tab_t(1, 10); BEGIN EXECUTE IMMEDIATE 'BEGIN testproc.my_dyn_proc_test(:1); END;' USING v_tab; END;</p> <p>this will not work.This shows error.I am not at my workstation so am not able to reproduce the issue now.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload