Passing record datatype collections to a procedure
Has anyone successfully created a record collection and passed it to a procedure? I am getting any error when I try to pass my record as a parameter to a procedure.
Here is my record datatype:
TYPE testInput IS RECORD (
input_anum VARCHAR2(09),
input_lastname VARCHAR2(40),
input_firstname VARCHAR2(25),
input_middlename VARCHAR2(25),
input_dob VARCHAR2(08),
input_inmate_no VARCHAR2(15),
input_ident_code VARCHAR2(09),
input_country_cde VARCHAR2(10),
input_date_custdy VARCHAR2(08),
input_date_relsed VARCHAR2(08),
input_num VARCHAR2(10),
input_type_offense VARCHAR2(01),
input_ms_offense VARCHAR2(50),
input_cis_anum VARCHAR2(09),
input_cis_lastname VARCHAR2(40),
input_cis_firstname VARCHAR2(25),
input_cis_midlename VARCHAR2(25),
input_cis_dob VARCHAR2(08),
input_cis_entry_class VARCHAR2(03),
input_cis_date_of_entry VARCHAR2(08),
input_cis_cob VARCHAR2(05),
input_cis_nationality VARCHAR2(05),
input_cis_fco VARCHAR2(03),
input_cis_match VARCHAR2(01),
input_cis_match_flag VARCHAR2(01),
input_cis_natz_flag VARCHAR2(01),
input_cis_natz_date VARCHAR2(08),
input_cis_fbi_num VARCHAR2(10));
infile testInput;
test_scaap.writeout_rec(pInfile infile);
PROCEDURE writeout_rec(pInfile_rec IN infile) IS
This is the error that I am getting:
PLS-00103: Encountered the symbol "INFILE" when expecting one of the following:
. ( ) , * @ % & | = - + < / > at in is mod not range rem =>
.. <an exponent (**)> <> or != or ~= >= <= <> and or
Thank you.
I'm not understanding. Here is my entire code:
CREATE OR REPLACE PACKAGE BODY test_scaap AS
NAME: test_scaap
PURPOSE:
REVISIONS:
Ver Date Author Description
1.0 3/11/2004 1. Created this package body.
TYPE ScaapInput IS RECORD (
input_anum VARCHAR2(09),
input_lastname VARCHAR2(40),
input_firstname VARCHAR2(25),
input_middlename VARCHAR2(25),
input_dob VARCHAR2(08),
input_inmate_no VARCHAR2(15),
input_ident_code VARCHAR2(09),
input_country_cde VARCHAR2(10),
input_date_custdy VARCHAR2(08),
input_date_relsed VARCHAR2(08),
input_fbi_num VARCHAR2(10),
input_type_offense VARCHAR2(01),
input_ms_offense VARCHAR2(50),
input_cis_anum VARCHAR2(09),
input_cis_lastname VARCHAR2(40),
input_cis_firstname VARCHAR2(25),
input_cis_midlename VARCHAR2(25),
input_cis_dob VARCHAR2(08),
input_cis_entry_class VARCHAR2(03),
input_cis_date_of_entry VARCHAR2(08),
input_cis_cob VARCHAR2(05),
input_cis_nationality VARCHAR2(05),
input_cis_fco VARCHAR2(03),
input_cis_match VARCHAR2(01),
input_cis_match_flag VARCHAR2(01),
input_cis_natz_flag VARCHAR2(01),
input_cis_natz_date VARCHAR2(08),
input_cis_fbi_num VARCHAR2(10));
infile test_scaap.ScaapInput;
PROCEDURE UTL_READ_FILE(pStatus OUT VARCHAR2)
IS
ext_anum VARCHAR2(09);
ext_lastname VARCHAR2(40);
ext_firstname VARCHAR2(25);
ext_middlename VARCHAR2(25);
ext_dob VARCHAR2(08);
ext_inmate_no VARCHAR2(15);
ext_ident_code VARCHAR2(09);
ext_country_cde VARCHAR2(10);
ext_date_custdy VARCHAR2(08);
ext_date_relsed VARCHAR2(08);
ext_fbi_num VARCHAR2(10);
ext_type_offense VARCHAR2(01);
ext_ms_offense VARCHAR2(50);
ext_cis_anum VARCHAR2(09);
ext_cis_lastname VARCHAR2(40);
ext_cis_firstname VARCHAR2(25);
ext_cis_middlename VARCHAR2(25);
ext_cis_dob VARCHAR2(08);
ext_cis_entry_class VARCHAR2(03);
ext_cis_date_of_entry VARCHAR2(08);
ext_cis_cob VARCHAR2(05);
ext_cis_nationality VARCHAR2(05);
ext_cis_fco VARCHAR2(03);
ext_cis_match VARCHAR2(01);
ext_cis_match_flag VARCHAR2(01);
ext_cis_natz_flag VARCHAR2(01);
ext_cis_natz_date VARCHAR2(08);
ext_cis_fbi_num VARCHAR2(10);
ext_dacs_anum VARCHAR2(09);
ext_dacs_lastname VARCHAR2(40);
ext_dacs_firstname VARCHAR2(25);
ext_dacs_middlename VARCHAR2(25);
ext_dacs_dob VARCHAR2(08);
ext_dacs_entry_class VARCHAR2(03);
ext_dacs_date_of_entry VARCHAR2(08);
ext_dacs_cob VARCHAR2(05);
ext_dacs_nationality VARCHAR2(05);
ext_dacs_dco VARCHAR2(03);
ext_dacs_name_match VARCHAR2(01);
ext_dacs_match VARCHAR2(01);
ext_dacs_natz VARCHAR2(01);
ext_dacs_natz_date VARCHAR2(08);
ext_dacs_fbi_num VARCHAR2(10);
ext_dacs_osc_iss_date VARCHAR2(10);
ext_dacs_osc_servd_date VARCHAR2(10);
v_seq NUMBER(10);
v_stage VARCHAR2 (200);
v_record VARCHAR2(370);
v_output_file UTL_FILE.FILE_TYPE;
v_rep_output UTL_FILE.FILE_TYPE;
v_input_file UTL_FILE.FILE_TYPE;
v_input_rec VARCHAR2(1000);
v_util_dest_dir VARCHAR2 (100) := Erem_Constants.vc_interface_dir;
v_util_dest_file VARCHAR2(17) := Erem_Constants.vc_scaap_extract_file;
v_util_input_file VARCHAR2(23) := Erem_Constants.vc_scaap_input_file;
v_util_rpt_dest_file VARCHAR2(23) := Erem_Constants.vc_scaap_report_file;
v_num_dupin_recs_skipped NUMBER(10) := 0;
v_num_recs_total NUMBER(10) := 0;
v_num_of_recs NUMBER(10) := 0;
v_num_dob_matches NUMBER(10) := 0;
v_num_exact_name_matches NUMBER(10) := 0;
v_num_middle_name_matches NUMBER(10) := 0;
v_num_anum_matches NUMBER(10) := 0;
v_num_reverse_name_matches NUMBER(10) := 0;
v_num_bad_input_records NUMBER(10) := 0;
v_num_matches NUMBER(10) := 0;
v_num_no_matches NUMBER(10) := 0;
v_rec_not_found BOOLEAN;
v_error_text VARCHAR2(255);
v_prog_type VARCHAR2(6) := 'PL/SQL';
v_return PLS_INTEGER := 0;
v_new_line PLS_INTEGER := 0;
v_end_of_file BOOLEAN := FALSE;
BEGIN
v_stage := 'Error get seq';
v_seq := jobcntrl.job_executing ('Erem_Intf_Scaap', v_prog_type);
v_stage := 'Error open input file';
v_input_file := UTL_FILE.FOPEN (v_util_dest_dir, v_util_input_file , 'R');
v_stage := 'Error open extract file';
v_output_file := UTL_FILE.FOPEN (v_util_dest_dir, v_util_dest_file, 'W');
v_stage := 'Error open report file';
IF UTL_FILE.IS_OPEN (v_input_file) THEN
DBMS_OUTPUT.PUT_LINE('THE FILE IS OPEN');
NULL;
END IF;
Erem_Intf_Utl.get_nextline(v_input_file, v_input_rec, v_end_of_file);
DBMS_OUTPUT.PUT_LINE('GETTING THE FIRST RECORD');
WHILE NOT v_end_of_file LOOP
v_num_of_recs := v_num_of_recs + 1;
DBMS_OUTPUT.PUT_LINE('ADDING 1 TO THE RECORD COUNT ==>'|| v_num_of_recs);
/*** Move input original record to hold original record ***/
--DBMS_OUTPUT.PUT_LINE('THE ANUM IN THE RECORD DATATYPE ==> '|| infile.input_anum);
infile.input_anum := SUBSTR(v_input_rec,1,9);
infile.input_lastname := SUBSTR(v_input_rec,10,40);
infile.input_firstname := SUBSTR(v_input_rec,50,25);
infile.input_middlename := SUBSTR(v_input_rec,75,25);
infile.input_dob := SUBSTR(v_input_rec,100,8);
infile.input_inmate_no := SUBSTR(v_input_rec,108,15);
infile.input_ident_code := SUBSTR(v_input_rec,123,9);
infile.input_country_cde := SUBSTR(v_input_rec,132,10);
infile.input_date_custdy := SUBSTR(v_input_rec,142,8);
infile.input_date_relsed := SUBSTR(v_input_rec,150,8);
infile.input_fbi_num := SUBSTR(v_input_rec,158,10);
infile.input_type_offense := SUBSTR(v_input_rec,168,1);
infile.input_ms_offense := SUBSTR(v_input_rec,169,50);
infile.input_cis_anum := SUBSTR(v_input_rec,219,9);
infile.input_cis_lastname := SUBSTR(v_input_rec,228,40);
infile.input_cis_firstname := SUBSTR(v_input_rec,268,25);
infile.input_cis_midlename := SUBSTR(v_input_rec,293,25);
infile.input_cis_dob := SUBSTR(v_input_rec,318,8);
infile.input_cis_entry_class := SUBSTR(v_input_rec,326,3);
infile.input_cis_date_of_entry := SUBSTR(v_input_rec,329,8);
infile.input_cis_cob := SUBSTR(v_input_rec,337,5);
infile.input_cis_nationality := SUBSTR(v_input_rec,342,5);
infile.input_cis_fco := SUBSTR(v_input_rec,347,3);
infile.input_cis_match := SUBSTR(v_input_rec,350,1);
infile.input_cis_match_flag := SUBSTR(v_input_rec,351,1);
infile.input_cis_natz_flag := SUBSTR(v_input_rec,352,1);
infile.input_cis_natz_date := SUBSTR(v_input_rec,353,8);
infile.input_cis_fbi_num := SUBSTR(v_input_rec,361,10);
writeout_rec(infile);
DBMS_OUTPUT.PUT_LINE('GETTING NEXT RECORD');
Erem_Intf_Utl.get_nextline(v_input_file, v_input_rec, v_end_of_file);
END LOOP;
UTL_FILE.FCLOSE (v_output_file);
--UTL_FILE.FCLOSE (v_rep_output);
UTL_FILE.FCLOSE (v_input_file);
v_return := 0;
jobcntrl.job_complete (v_seq);
pStatus := '0';
EXCEPTION
WHEN NO_DATA_FOUND
THEN
UTL_FILE.FCLOSE (v_output_file);
v_error_text := 'No data found error.';
RAISE;
WHEN UTL_FILE.INTERNAL_ERROR
THEN
UTL_FILE.FCLOSE (v_output_file);
v_error_text := 'Internal Error';
RAISE;
WHEN UTL_FILE.INVALID_FILEHANDLE
THEN
UTL_FILE.FCLOSE (v_output_file);
v_error_text := 'Invalid file handle';
RAISE;
WHEN UTL_FILE.INVALID_OPERATION
THEN
UTL_FILE.FCLOSE (v_output_file);
v_error_text := 'Invalid operation';
RAISE;
WHEN UTL_FILE.INVALID_PATH
THEN
UTL_FILE.FCLOSE (v_output_file);
v_error_text := 'Invalid path';
RAISE;
WHEN UTL_FILE.READ_ERROR
THEN
UTL_FILE.FCLOSE (v_output_file);
v_error_text := 'Read error';
RAISE;
WHEN UTL_FILE.WRITE_ERROR
THEN
UTL_FILE.FCLOSE (v_output_file);
v_error_text := 'Write error';
RAISE;
WHEN VALUE_ERROR
THEN
UTL_FILE.FCLOSE (v_output_file);
v_error_text := 'Value error';
RAISE;
WHEN OTHERS
THEN
UTL_FILE.FCLOSE (v_output_file);
v_error_text := 'OTHER ERROR';
jobcntrl.job_abort (v_seq, SUBSTR (SQLERRM, 1, 100) || v_stage,SQLCODE);
pStatus := '1';
--RAISE;
END utl_read_file;
PROCEDURE writeout_rec(pInfile_rec IN infile)
IS
BEGIN
v_record := RPAD (NVL (pInfile_rec.input_anum, ' '),9,' ') ||
RPAD (NVL (pInfile_rec.input_lastname, ' '), 40, ' ') ||
RPAD (NVL (pInfile_rec.input_firstname, ' '), 25,' ') ||
RPAD (NVL (pInfile_rec.input_middlename, ' '), 25, ' ') ||
RPAD (NVL (pInfile_rec.input_dob, ' '),8,' ') ||
RPAD (NVL (pInfile_rec.input_inmate_no, ' '),15,' ') ||
RPAD (NVL (pInfile_rec.input_ident_code, ' '),9,' ') ||
RPAD (NVL (pInfile_rec.input_country_cde, ' '),10,' ') ||
RPAD (NVL (pInfile_rec.input_date_custdy, ' '),8,' ') ||
RPAD (NVL (pInfile_rec.input_date_relsed, ' '),8,' ') ||
RPAD (NVL (pInfile_rec.input_fbi_num, ' '),10,' ') ||
RPAD (NVL (pInfile_rec.input_type_offense, ' '),1,' ') ||
RPAD (NVL (pInfile_rec.input_ms_offense, ' '),50,' ') ||
RPAD (NVL (pInfile_rec.infile.input_cis_anum, ' '),9,' ') ||
RPAD (NVL (pInfile_rec.infile.input_cis_lastname, ' '),25,' ') ||
RPAD (NVL (pInfile_rec.infile.input_cis_firstname, ' '),25,' ') ||
RPAD (NVL (pInfile_rec.infile.input_cis_midlename, ' '),25,' ') ||
RPAD (NVL (pInfile_rec.infile.input_cis_dob, ' '),8,' ') ||
RPAD (NVL (pInfile_rec.infile.input_cis_entry_class, ' '),3,' ') ||
RPAD (NVL (pInfile_rec.infile.input_cis_date_of_entry, ' '),8,' ') ||
RPAD (NVL (pInfile_rec.infile.input_cis_cob, ' '),5,' ') ||
RPAD (NVL (pInfile_rec.infile.input_cis_nationality, ' '),5,' ') ||
RPAD (NVL (pInfile_rec.infile.input_cis_fco, ' '),3,' ') ||
RPAD (NVL (pInfile_rec.infile.input_cis_match, ' '),1,' ') ||
RPAD (NVL (pInfile_rec.infile.input_cis_match_flag, ' '),1,' ') ||
RPAD (NVL (pInfile_rec.infile.input_cis_natz_flag, ' '),1,' ') ||
RPAD (NVL (pInfile_rec.infile.input_cis_natz_date, ' '),8,' ') ||
RPAD (NVL (pInfile_rec.infile.input_cis_fbi_num, ' '),10,' ') ||
RPAD (NULL, 9,' ') ||
RPAD (NULL, 40,' ') ||
RPAD (NULL, 25,' ') ||
RPAD (NULL, 25,' ') ||
RPAD (NULL, 8,' ') ||
RPAD (NULL, 3,' ') ||
RPAD (NULL, 8,' ') ||
RPAD (NULL, 5,' ') ||
RPAD (NULL, 5,' ') ||
RPAD (NULL, 3,' ') ||
RPAD (NULL, 1,' ') ||
RPAD ('N', 1,' ') ||
RPAD (NULL, 1,' ') ||
RPAD (NULL, 8,' ') ||
RPAD (NULL, 10,' ') ||
RPAD (NULL, 8,' ') ||
RPAD (NULL, 8,' ');
DBMS_OUTPUT.PUT_LINE('WRITING RECORD');
DBMS_OUTPUT.PUT_LINE('THE INFILE ==> '|| v_record);
UTL_FILE.PUT_LINE (v_output_file, v_record);
END writeout_rec;
END test_scaap;
I only want to use the record type if I can.
Thank you.
Similar Messages
-
Passing CLOB datatype to a stored procedure
Hi,
How do I pass a CLOB value to a stored procedure?
I am creating a stored procedure which appends a value to a CLOB datatype. The procedure has 2 in parameter (one CLOB and one CLOB). The procedure is compiled but I'm having problem executing it. Below is a simplified version of the procedure and the error given when the procedure is executed.
SQL> CREATE OR REPLACE PROCEDURE prUpdateContent (
2 p_contentId IN NUMBER,
3 p_body IN CLOB)
4 IS
5 v_id NUMBER;
6 v_orig CLOB;
7 v_add CLOB;
8
9 BEGIN
10 v_id := p_contentId;
11 v_add := p_body;
12
13 SELECT body INTO v_orig FROM test WHERE id=v_id FOR UPDATE;
14
15 DBMS_LOB.APPEND(v_orig, v_add);
16 commit;
17 END;
18 /
Procedure created.
SQL> exec prUpdateContent (1, 'testing');
BEGIN prUpdateContent (1, 'testing'); END;
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'PRUPDATECONTENT'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Any help or hints please.
nullsorry I made a mistake with the in parameter types - it's one NUMBER and one CLOB.
-
How to pass RECORD input type to stored procedure from JDBC?
Hi,
We have stored procedure which takes RECORD as input .
We could execute the below script from oracle client tool and get the response.
declare
l_record app.batch_update.add_record;
l_id number;
begin
-- memberNumber
l_record.no := '123456700';
-- Policy Number
l_record.pno := '1234567'
-- Status. This will always be NEW.
-- Call to API to add record
app.batch_update.add_request
(p_record => l_record,
p_id => l_id,
end;
We have requirement to construct RECORD input from Java application and pass it to callable statement.
We have tried to construct it via STRUCT and pass it to callable statement but it didn't work.
We have constructed it like the following but not sure whether it is correct. It was throwing error "java.sql.SQLException: invalid name pattern: app.batch_update.add_record
StructDescriptor structdesc = StructDescriptor.createDescriptor
("app.batch_update.add_record", delConn);
Object[] p1obj = {' 12345','124050'};
STRUCT p1struct = new STRUCT(structdesc, delConn, p1obj);
Not sure whether I am doing the logic correctly.
Please point me to the correct approach.
Thanks in Advice
ThanksWrap the method using a record-type parameter in PL/SQL; a simplified example follows. Add exception handling, translation of types etc. as needed.
CREATE OR REPLACE PROCEDURE prc_wrap_prc_using_rec
pv_my_field_01 IN VARCHAR2,
pv_my_field_02 IN VARCHAR2,
pv_my_field_99 IN VARCHAR2,
pv_err_msg OUT VARCHAR2
) AS
-- Non-scalar parameter
pr_my_record user.pkg_rec_declarations.wr_a_record_decl;
BEGIN
-- Load the work record
pr_my_record.pv_field_01 := pv_my_field_1;
pr_my_record.pv_field_02 := pv_my_field_2;
pr_my_record.pv_field_99 := pv_my_field_99;
-- Call the procedure
pkg_std_routines.prc_do_sumfin(pr_my_record, pv_err_msg);
END; -
How to pass Single record set out to another Procedure in a LOOP
In my complete Order lines FOR LOOP, I want to pass one line out to call another program to perform the insert or update action. How to write
PROCEDURE order_line_process
p_username IN VARCHAR2,
p_id IN OUT NUMBER,
my_orderdtl_tbl IN OUT my_orderdtl_tbl_type
) IS
BEGIN
FOR x IN 1 .. my_orderdtl_tbl.count LOOP
IF my_orderdtl_tbl(x).update_flag = 'I' THEN
order_line_insert(p_username => p_username,
p_id => p_id,
my_orderdtl_tbl => my_orderdtl_tbl(x)); --- how do I pass only one line info here? Do I have to assign/pass all column?
END IF;
END LOOP;
END order_line_process;ThanksMy example still works:
SQL> create or replace package test2 is
2 type my_orderdtl_rec_type is record (a number,b varchar2(10),update_flag char(1));
3 type my_orderdtl_tbl_type is table of my_orderdtl_rec_type index by binary_integer;
4 end;
5 /
Package created.
SQL> create or replace procedure order_line_insert(p_user varchar2, p_id number, my_orderdtl_tbl test2.my_orderdtl_rec_type) is
2 begin
3 null;
4 end;
5 /
Procedure created.
SQL> create or replace PROCEDURE order_line_process
2 (
3 p_username IN VARCHAR2,
4 p_id IN OUT NUMBER,
5 my_orderdtl_tbl IN OUT test2.my_orderdtl_tbl_type
6 ) IS
7 BEGIN
8
9 FOR x IN 1 .. my_orderdtl_tbl.count LOOP
10 IF my_orderdtl_tbl(x).update_flag = 'I' THEN
11 order_line_insert(p_username,
12 p_id,
13 my_orderdtl_tbl(x));
14 END IF;
15
16 END LOOP;
17
18 END order_line_process;
19 /
Procedure created.But if you're using the following syntax to pass parameters:
SQL> create or replace PROCEDURE order_line_process
2 (
3 p_username IN VARCHAR2,
4 p_id IN OUT NUMBER,
5 my_orderdtl_tbl IN OUT test2.my_orderdtl_tbl_type
6 ) IS
7 BEGIN
8
9 FOR x IN 1 .. my_orderdtl_tbl.count LOOP
10 IF my_orderdtl_tbl(x).update_flag = 'I' THEN
11 order_line_insert(p_username => p_username,
12 p_id,
13 my_orderdtl_tbl(x));
14 END IF;
15
16 END LOOP;
17
18 END order_line_process;
19 /
Warning: Procedure created with compilation errors.
SQL> sho err
Errors for PROCEDURE ORDER_LINE_PROCESS:
LINE/COL ERROR
11/7 PL/SQL: Statement ignored
11/7 PLS-00306: wrong number or types of arguments in call to
'ORDER_LINE_INSERT'Dublecheck the parameters name in the order_line_insert procedure
SQL> create or replace PROCEDURE order_line_process
2 (
3 p_username IN VARCHAR2,
4 p_id IN OUT NUMBER,
5 my_orderdtl_tbl IN OUT test2.my_orderdtl_tbl_type
6 ) IS
7 BEGIN
8
9 FOR x IN 1 .. my_orderdtl_tbl.count LOOP
10 IF my_orderdtl_tbl(x).update_flag = 'I' THEN
11 order_line_insert(p_user => p_username, -- THE ERROR WAS HERE!!! CORRECT PARAMETER NAME IS P_USER
12 p_id => p_id,
13 my_orderdtl_tbl => my_orderdtl_tbl(x));
14 END IF;
15
16 END LOOP;
17
18 END order_line_process;
19 /
Procedure created.Max
http://oracleitalia.wordpress.com -
PL/SQL Passing record type between two procedures
I have a package and package body as following
My problem is I forgot the syntax to pass the record type between the two procedure.?????
CREATE OR REPLACE PACKAGE Standby_Schedules_Disp
AS
PROCEDURE Get_schedule (test1 OUT VARCHAR2);
PROCEDURE get_test (my_test REF my_sched); DOESN'T WORK?????
END Standby_Schedules_Disp;
CREATE OR REPLACE PACKAGE BODY Standby_Schedules_Disp
AS
PROCEDURE Get_schedule (test1 OUT VARCHAR2)
AS
temp NUMBER;
TYPE my_sched IS RECORD ( my_name VARCHAR2(30) := NULL,
my_age NUMBER := 0);
who_I_am my_sched;
Get_test(my_sched);
BEGIN
test1 := 'aaaaa';
who_i_am.my_name := 'Matthew';
END get_schedule;
PROCEDURE get_test (my_test REF my_sched) DOESN'T WORK?????
AS
BEGIN
END;
END Standby_Schedules_Disp;
/Youv'e declared the my_sched type within the scope of the Get_schedule procedure - it's not visible to the get_test procedure. You have declare the type in the package body if it's only used internally within the package or in the package spec if it can be referenced outside the package:
CREATE OR REPLACE PACKAGE [BODY] Standby_Schedules_Disp
AS
TYPE my_sched IS RECORD (
my_name VARCHAR2(30) := NULL,
my_age NUMBER := 0);I don't understand what you are trying to do with the REF keyword in this context. Having declared the type, you can use it as normal in a parameter spec:
PROCEDURE get_test (my_test IN [OUT] my_sched);You're also trying to call get_test within the declaration section of a program, which you can't do, and get_test also contains no executable code, which is not allowed in PL/SQL. -
Passing record type into function [error: identifier must be declared]
Hi,
I have a record type defined in my procedure
type chk_tab is record(
effect date,
count number(9)
type chk_typ is table of chk_tab index by binary integer;
chk_typ_rec chk_typ;
I have to pass the effect and count into another function, i tried doin as below:
function name: func_chk_typ
func_chk_typ(effect, count);
this returns an saying "identifier effect needs to be declared"
I am required to pass these values from the record type into the function, How can i over come this??
Any help is very much appreciated.Hi Hemz,
Find below code.
Function Code:
CREATE OR REPLACE FUNCTION fetch_band(eff in date,ineff in date)
return number
is
lu_cb_sysid NUMBER;
BEGIN
select fk_cb_sysid
into lu_cb_sysid
from ia_for_icon
where cr_ans_date >= eff
and cr_ans_date < ineff;
RETURN lu_cb_sysid;
END fetch_band;Procedure code. Here I have embedded the function.
CREATE OR REPLACE procedure abc(a varchar, b number) is
type cns_tab_record is record(
eff date,
ineff date);
type cns_tab_typ is table of cns_tab_record index by binary_integer;
cns_tab cns_tab_typ;
v_lu_cb_sysid NUMBER;
BEGIN
-- Here you have to assign the values to your table type record.
-- For example I am passing two values SYSDATE and SYSDATE - 10
cns_tab(1).eff := SYSDATE;
cns_tab(1).ineff := SYSDATE - 10;
v_lu_cb_sysid:= fetch_band(cns_tab(1).eff, cns_tab(1).ineff);
END abc;But I am just wondering why you are using table type datatype here.
Hope above code will help you.
Thanks,
Suri -
Using UDT's for passing rows to a PL/SQL procedure
I'm trying to get a list of rows into a procedure...
With ODP 11 - I thought that I would simply need to create a UDT of an object (i.e. user_id, first_name, last_name) and - then type which is a collection of that object.
Then - using that object type collection as a parameter in my procedure - pass the numerous rows from .NET in.
I've found a examples with varray's, nested varrays etc... but - nothing straight forward with passing a collection of rows.
Does anyone know of any online examples that illustrate this?
Thanks for your help!Hi,
A BLOB variable is just a pointer to binary data and you are passing a text string to your procedure which is why you have the error. So to write a blob into a table in a procedure you need something like this:
CREATE OR REPLACE PROCEDURE testone(
V_TEXT IN VARCHAR2
AS
V_SIGIMG BLOB;
BEGIN
insert into sin_image values(empty_blob())
returning blobcol into V_SIGIMG;
-- then copy the text as binary data, this does not convert the text to binary data
DBMS_LOB.WRITE(V_SIGIMG,1,LENGTH(V_TEXT),v_TEXT);
commit;
END;
/However, if you want to upload images into the table it is easier to use the Apex functionality to upload the image into the APEX_APPLICATION_FILES table then move the blob into your table using an INSERT or UPDATE.
Rod West -
Passing table data to pl sql procedure oaf
Hi All,
I have a requirement where i have to pass table data to plsql procedure.
In the first page i select the REQUISITION and click on RETURN button and it will take me to the next page.
and in the Next page i will click on APPLY button.
When i click on APPLY, it will call the procedure and will give input to the procedure whatever has been selected when i have selected requisition.
Please help. Please tell me the approach how to get this task done. A sample code will work.
Hope the requirement is clear.
Thanks in Advance.Hi Chinmay,
Refer below code for Your Requirement.
//Code For Quering Data
import java.sql.PreparedStatement;
import java.sql.ResultSet;
Connection conn = pageContext.getApplicationModule(webBean).getOADBTransaction().getJdbcConnection();
String Query = "SELECT organization_id FROM hr_operating_units WHERE organization_id = fnd_global.org_id";
PreparedStatement stmt = conn.prepareStatement(Query);
resultset=stmt.executeQuery();
while (resultset.next())
orgId = (String)resultset.getString("ORGANIZATION_ID").toString();
conn.commit();
catch(Exception e)
e.printStackTrace();
//Code for Pass Resulted column to Procedure Input for delete Particular Record
Execute parameterized PL SQL procedure from OAF page
Let us try to call PL/SQL package from OAF page. We will try to remove selected line from Database.
Package Spec
CREATE OR REPLACE PACKAGE APPS.genpack_pkg
AS
PROCEDURE roll_delete_proc (orgId IN VARCHAR2);
END genpack_pkg;
Package Body
CREATE OR REPLACE PACKAGE BODY APPS.genpack_pkg
AS
PROCEDURE roll_delete_proc (orgId IN VARCHAR2)
AS
BEGIN
DELETE FROM pklist_roll_details_temp
WHERE roll_line_id = orgId;
COMMIT;
END roll_delete_proc;
END genpack_pkg;
//in Controller PFR
import java.sql.CallableStatement;
if (pageContext.getParameter("ActionsButton") != null)
String val = pageContext.getParameter("ActionsChoice");
if ("DELLN".equals(val))
CallableStatement cstmt = null;
for (OAViewRowImpl row = (OAViewRowImpl)tempvo.first(); row != null; row = (OAViewRowImpl)tempvo.next()) {
if ((row.getAttribute("Selectflag") == null) ||
(!row.getAttribute("Selectflag").toString().equals("Y"))) continue;
try {
int rollid = Integer.parseInt((String)row.getAttribute("orgId"));
Connection conn = am.getOADBTransaction().getJdbcConnection();
if (rollid == 1)
temphm.put(row.getAttribute("orgId").toString(), row.getAttribute("PoNumber").orgId());
tempvo.removeCurrentRow();
else
try
StringBuilder sb = new StringBuilder();
sb.append(rollid);
String strI = sb.toString();
System.out.println("Inside else in delete");
cstmt = conn.prepareCall("{call GENPACK_PKG.tpc_roll_delete_proc(?)}");
cstmt.setString(1, strI);
System.out.println("Oracle Callable Statment Execution Init for Delete");
cstmt.execute();
catch (SQLException e) {
throw new OAException(e.toString(), (byte)0);
}tempvo.removeCurrentRow();
catch (OAException e) {
throw new OAException("No row selected", (byte)3);
Thanks,
Dilip -
URGENT: I want to pass a variable to a stored procedure at run time
Post Author: aruplabs
CA Forum: Data Connectivity and SQL
I work for a health care provider and I have reports that pull PHI (Protected Health Information) about patients that needs to be logged according to federal HIPAA regulations. One of the pieces of information that needs to be logged is the username of the person who ran the report. Since these reports will be run from our Crystal Enterprise server I can get this from the CurrentCEUserName variable but I am looking for a way to pass this value to a stored procedure that will not only return the records for the report, but also log the disclosure in our PHI disclosure tracking table. I know you can pass a parameter to a stored procedure but I dont know how, or if it is even possible, to pass a run time variable. This is an urgent problem that I need to find a solution for. Any help would be appreciated.
Thank you.Here it is. Right now, when i press te "Go" it runs for the specific time i've set and when its done the variable "Run" is set true. When i call this VI from another VI it waits for the loop to be finished before it will read the variable.
Regards
Viktor
Attachments:
Untitled 2.vi 26 KB -
How to pass value in array to another procedure?
Hello.
I have created application by Developer form9i.
And I have some problem about passing value in array to another procedure.
My code is :
PROCEDURE p_add_array (col_no in number,
col_val in varchar2) IS
type xrecord is record(col number,vcol varchar2(1000));
xrec xrecord;
type varraytype is varying array(42) of xrecord;
xvartab varraytype := varraytype();
alert number;
BEGIN
set_application_property(cursor_style,'busy');
xrec.col := col_no;
xrec.vcol := col_val;
xvartab.extend(1);
xvartab(col) := xrec;
EXCEPTION
when others then
set_application_property(cursor_style,'default');
alert := f_show_alert('!Error ORA-'||
to_char(DBMS_ERROR_CODE)||' '||
substr(DBMS_ERROR_TEXT,1,240),
'al_stop');
END;
And I want to have
PROCEDURE p_print_arrey is
BEGIN
END;
So how to bring value of xvartab( ) in p_add_array to use in p_print_array?
Anybody please help me solve this ploblem.Hi,
Instead of declaring the array locally within the procedure (i.e. p_add_array), define it in the package specification (i.e. Under Program Units).
-- Shailender Mehta -- -
How to Pass multiple parameter into single store procedure
How to Pass multiple parameter into single store procedure
like a one to many relationship.
it is possible then reply me immediatlyyou mean like this .....
CREATE OR REPLACE procedure display_me(in_param in varchar2,in_default in varchar2 := 'Default') is
BEGIN
DBMS_OUTPUT.put_line ('Values is .....'||in_param || '....'||in_default);
END display_me;
CREATE OR REPLACE procedure display_me_2 as
cnt integer :=0;
BEGIN
For c1_rec In (SELECT empno,deptno FROM test_emp) Loop
display_me(in_param => c1_rec.empno);
cnt := cnt+1;
end loop;
DBMS_OUTPUT.put_line('Total record count is ....'||cnt);
END display_me_2;
SQL > exec display_me_2
Values is .....9999....Default
Values is .....4567....Default
Values is .....2345....Default
Values is .....7369....Default
Values is .....7499....Default
Values is .....7521....Default
Values is .....7566....Default
Values is .....7654....Default
Values is .....7698....Default
Values is .....7782....Default
Values is .....7788....Default
Values is .....7839....Default
Values is .....7844....Default
Values is .....7876....Default
Values is .....7900....Default
Values is .....7902....Default
Values is .....7934....Default
Values is .....1234....Default
Total record count is ....18 -
Standard datatype in dbms_aq.enqueue procedure
Payload argument is defined as standard datatype in dbms_aq.enqueue procedure definition. Any object type can then be passed to the enqueue procedure. Can we define an argument's type as STANDARD in a user defined PL/SQL procedure ?
What is standard datatype ? I haven't seen documentation for it.
PROCEDURE ENQUEUE
Argument Name Type
QUEUE_NAME VARCHAR2 IN
PAYLOAD STANDARD IN
other arguments..The payload has to be a user created object type. In Oracle9i you can use SYS.Anydata or SYS.XMLType.
-
Fetching records using a cursor in to the record datatype
Hii,
I am trying to declare a cursor and load the fetched rows in to record datatype. but i am getting error about the arguments that have to passed in to output command. plz help
1 DECLARE
2 cursor emp_cursor IS
3 select ename, empno from emp
4 where deptno =30;
5 emp_rec1 emp_cursor%rowtype;
6 BEGIN
7 open emp_cursor;
8 loop
9 fetch emp_cursor into emp_rec1;
10 exit when emp_cursor %notfound;
11 dbms_output.put_line(emp_rec1);
12 end loop;
13* end;
SQL> /
dbms_output.put_line(emp_rec1);
ERROR at line 11:
ORA-06550: line 11, column 1:
PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'
ORA-06550: line 11, column 1:
PL/SQL: Statement ignored
thanks
sharaththanks guys.the issue is resolved.
1 DECLARE
2 cursor emp_cursor IS
3 select ename, empno from emp
4 where deptno =30;
5 emp_rec1 emp_cursor%rowtype;
6 BEGIN
7 open emp_cursor;
8 loop
9 fetch emp_cursor into emp_rec1;
10 exit when emp_cursor %notfound;
11 dbms_output.put_line(emp_rec1.ename);
12 dbms_output.put_line(emp_rec1.empno);
13 end loop;
14* end;
SQL> /
ALLEN
7499
WARD
7521
MARTIN
7654
BLAKE
7698
TURNER
7844
JAMES
7900 -
Passing Record type parameter from one session to other session
Hi,
I have a package.procedure, in that I am calling custom workflow, inside this workflow again I am calling
same package.procedure (Its an recursive call)
I need to pass record type parameter in this package.procedure.
I tried with global variables but Workflow starts its new session so it losses all variables.
Now I am going with creation of Custom table.
Please advice, is there any way other than creation of Custom table.
I mean can we pass Record type parameter from one session to other session without creating table.
Regards
RohitAl-Salamu Alikum We Rahmatu Allah We Barakatu...
want this place from to be passed as a parameter to the shipping bill form..... using web.show_documentwhy don't u think of just passing data parameter or global parameters from one form to another
Pass global variable between two forms.
Hope this helps...
Regards,
Abdetu... -
Passing a html array to a procedure then to another procedure
Hi Sir,
Passing an array from html to procedure can be done by having html form elements with same name and a IN parameter in procedure that uses OWA_UTIL.IDENT_ARR as the datatype.
What if from the receiving procedure A, I want to pass the array further to another procedure B:
1)How should I write the statement to pass?
2)How should I declare the parameter in procedure B?
Please advise.
Thanks.Hi Sir,
Passing an array from html to procedure can be done by having html form elements with same name and a IN parameter in procedure that uses OWA_UTIL.IDENT_ARR as the datatype.
What if from the receiving procedure A, I want to pass the array further to another procedure B:
1)How should I write the statement to pass?
2)How should I declare the parameter in procedure B?
Please advise.
Thanks.
Maybe you are looking for
-
Why won't my drop down list populate from the array?
I am using the following array. var actDesc = new Array(" ", "Desc1 ", "Desc2 ", "Desc3 "); // Array of HUD Activity Numbers. var actNum = new Array(null, "1 ", "2 ", "3 "); // This populates the Description Drop-down List and works just fine. funct
-
Network card doesn't start automatic on virtualbox
Hi, I came back at Arch after a long time! I try to install on virtualbox with 2 network: first NAT (eth0) and second host-only (eth1) but at each reboot my eth0 not start. My rc.conf # Network # interface=eth0 # address=10.0.2.15 # netmask=255.255.
-
Have windows xp and windows 7 down loaded itunes 10.4 and all computers. When you open itunes store it opens as a blank page.
-
I want to send my ical to my cell phone. Ive searched these forums and ical help and cant get anything. I have a samsung a900. It says "this devices is not supported by isync". I also tried to export my calendar to my phone and it said the file wasnt
-
Deleting emails with in a specific date range
Is there a way to delete a specific date range of email using 10.9.3 or Gmail. Thanks