SQL SELECT statement as a parameter in the procedure of string
Hi allI'm new to PL/SQL and I must get a procedure as parameter select SQL select statement as a VARCHAR and the production output the result of the statement with a few changes. Can someone help me solve this problem?
A possibility I thought at was to use a REF CURSOR. The following example works but binds me to a specific table (in the example of the "customers" table). However, I need the ability to specify arbitrary tables in the select statement parameter.
SET SERVEROUTPUT ON
DECLARE
TYPE my_cur IS REF CURSOR;
query_cursor my_cur;
BEGIN
OPEN query_cursor FOR 'SELECT * FROM customers';
DECLARE
record_type customers%ROWTYPE;
BEGIN
LOOP
FETCH query_cursor INTO record_type;
EXIT WHEN query_cursor%NOTFOUND;
DBMS_OUTPUT.PUT_LINE('some output ... ');
END LOOP;
END;
CLOSE query_cursor;
END;
/
My idea was to modify this example to work in the following code, but it does not work (I get a compile error):SET SERVEROUTPUT ON
DECLARE
TYPE my_cur IS REF CURSOR;
query_cursor my_cur;
BEGIN
OPEN query_cursor FOR 'SELECT * FROM customers';
DECLARE
record_type query_cursor%ROWTYPE;
BEGIN
LOOP
FETCH query_cursor INTO record_type;
EXIT WHEN query_cursor%NOTFOUND;
DBMS_OUTPUT.PUT_LINE('some output ... ');
END LOOP;
END;
CLOSE query_cursor;
END;
/
Does anyone has an idea how can I solve my problem?Thank you very much!
(I'm using Oracle 11 g)
This can help.
Re: Dynamic Extraction on dynamic Sql
Tags: Database
Similar Questions
-
What is the sql SELECT statement to list all service names in the database?
What is the sql SELECT statement to list all service names in the database?
I tried
SELECT name FROM dba_services
But a long with valid service, he list also some other documents that are not the names of services.Hello
You can try this query:
select name, value from v$parameter where name = 'service_names';
Hope this helps.
Best regards
Jean Valentine -
NULL in PL/SQL SELECT statement..
Hi all
I need to use as a result of a SELECT statement in my function to get PCODE from the table. Cur_rec here. CODE comes from cursor that runs before the declaration.
SELECT PCODE in v_pcode TABLE_XYZ where CODE = cur_rec. CODE and PCODE = 'VIEW '.
Now the problem is the part of the CODE has all the information in the table TABLE_XYZ. In this case, it triggers an error NO_DATA_FOUND. To solve it, I can put a part of the EXCEPTION and handle it. But I think in another way...
If there is no data for a CODE, the default value of v_pcode would be 'No Code'. I tried to use the NVL function, but it does not work here as a SQL SELECT statement.
Can someone give an idea how to achieve this?Hello
declare ... v_cnt number; begin SELECT count(*) into v_cnt from TABLE_XYZ where CODE = cur_rec.CODE and PCODE='SEE'; if v_cnt=0 then v_pcode = 'No code'; else v_pcode = 'SEE'; end if; end;
Bartek
-
How to block a select statement for a table of the specified until validation line
Hello
How to block a SELECT statement for a specified row in a table until willingness to engage occure?
My procedure is part of a Stock request and if a user (X) get stock 1 piece, another user must wait for the user (Y) complete his reportoire.
So, let say my stock have 10 pencils.
When the X user starts the Stock_PLS procedure, in table Stock, line (e.g. R1) that user X should work with it, must be lock up to what the commit / rollback will appear.
procedure Stock_PLS...
Start
..
pencils: pencils-1 =;
..
End
Observation-> pencils: = 9;
This means that is a user there, run SELECT * stock of the table where rows_id = R1, SELECTION should wait the Stock_PLS started by user X will be completed (with commit or rollback) and his SELECT should return the value 9.
What I need, is that Oracle has something like LINE EXCLUSIVE TABLE LOCK, but in my situation the SELECT statement should be denied on the specified lines, until the end of the procedure.
Kind regards
MichaelHello
You can achieve this using the update with the Select clause.
You can write your select statement like this
SELECT * from stock of the table where rows_id = R1 for update; -
How to assign values to the nested table and passes as a parameter for the procedure?
How to assign values to the nested table and passes as a parameter for the procedure?
Here are the object and its type
create or replace type test_object1 as an object
(
val1 varchar2 (50).
val2 varchar2 (50).
VARCHAR2 (50) val3
);
create or replace type test_type1 is table of the test_object1;
create or replace type test_object2 as an object
(
val1 varchar2 (50).
val2 varchar2 (50).
VARCHAR2 (50) val3
);
create or replace type test_type2 is table of the test_object2;
GRANT ALL ON test_object1 to PUBLIC;
GRANT ALL ON test_type1 to PUBLIC;
GRANT ALL ON test_object2 to PUBLIC;
GRANT ALL ON test_type2 to PUBLIC;
Here is the table object type:
create the table test_object_tpe
(
sl_num NUMBER,
Description VARCHAR2 (100),
main_val1 test_type1,
main_val2 test_type2
)
NESTED TABLE main_val1 STORE AS tot1
NESTED TABLE main_val2 STORE AS earlier2;
-----------------------------------------------------------------------------------------------------------
Here is the procedure that inserts values into the nested table:
PROCEDURE INSERT_TEST_DATA (sl_num in NUMBER,
Description in VARCHAR2,
p_main_val1 IN test_type1,
p_main_val2 IN test_type2
)
IS
BEGIN
FOR rec in p_main_val1.first... p_main_val1. Last
LOOP
INSERT INTO xxdl.test_object_tpe
(
sl_num,
Description,
main_val1,
main_val2
)
VALUES
(
sl_num
description
test_type1 (test_object1)
p_main_val1 .val1 (CRE),
p_main_val1 .val2 (CRE),
p_main_val1 .val3 (rec)
)
)
test_type2 (test_object2 (p_main_val2 .val1 (CRE),
p_main_val2 .val2 (CRE),
p_main_val2 .val3 (rec)
)
)
);
END LOOP;
commit;
END INSERT_TEST_DATA;
-------------------------------------------------------------------------------------------
Here are the block anonymoys what values attributed to the object type and pass values in the procedure:
Set serveroutput on;
declare
p_sl_num NUMBER: = 1001;
p_description VARCHAR2 (50): = 'Test Val1;
inval1 test_type1: = test_type1();
inval2 test_type2: = test_type2();
Start
inval1 (1) .val1: = "testx1";
inval1 (1) .val2: = "testx2";
inval1 (1) .val3: = "testx3";
inval2 (1) .val1: = "testy1";
inval2 (1) .val2: = "testy2";
inval2 (1) .val3: = "testy3";
CSI_PKG. INSERT_TEST_DATA (sl_num = > p_sl_num,)
Description = > p_description,
p_main_val1 = > inval1,
p_main_val2 = > inval2
);
end;
/
Someone can correct me.
Thank you
LavanThanks for posting the DOF and the sample code but whenever you post provide your Oracle version 4-digit (result of SELECT * FROM V$ VERSION).
>
How to assign values to the nested table and passes as a parameter for the procedure?
>
Well you do almost everything bad that could be hurt.Here is the code that works to insert data into your table (the procedure is not even necessary).
declare p_sl_num NUMBER := 1001; p_description VARCHAR2(50) := 'Testing Val1'; inval1 test_type1 := test_type1(); inval2 test_type2 := test_type2(); begin inval1.extend(); inval1(1) := test_object1('testx1', 'testx2', 'testx3'); inval2.extend(); inval2(1) := test_object2('testy1', 'testy2', 'testy3'); INSERT INTO test_object_tpe ( sl_num, description, main_val1, main_val2 ) VALUES (p_sl_num, p_description, inval1, inval2); commit; end; /
See example 5-15 making reference to an element of nested Table Chapter 5 using PL/SQL collections and records in the PL/SQL doc
http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28370/Collections.htm#CJABEBEA1. you don't even have the procedure because it is a simple INSERTION in the table you can do directly (see my above code)
inval1(1).val1 := 'testx1';
Since you have not yet created all the elements, there is no element 1 "inval1". You need EXTEND the collection to add an element
inval1.extend();
And then, there is an empty element, but "inval1" is a container for objects of type 'test_object1' not for scalars as "val1", "val2", and "val3".
If you can not doinval1(1).val1 := 'testx1';
You must create an instance of 'test_object1 '.
inval1(1) := test_object1('testx1', 'testx2', 'testx3');
And so on for the other collection
You don't need the procedure (as my code example shows), but once you fill in the variables correctly it will work.
-
the size of the out parameter in the procedure
Hi all:
I have a procedure in a pl/sql package like this:
create or replace procedure MyProc (PRM_STR in VHARCHAR2, PRM_OUTSTR OUT VARCHAR2) is
V_TEST VARCHAR2 (100)
Start
+...+
V_STR: = SUBSTR (PRM_STR, 22, 31);
V_TEST: = TRIM (V_STR);
PRM_OUTSTR: = V_TEST;
EXCEPTION
WHILE OTHERS THEN
+....+
myproc end;
When I run it, it always gives me an exception: ORA-06502: PL/SQL: digital or value error: character string buffer too small.
Then I debug him:
V_TEST: = TRIM (V_STR)
is OK.
While PRM_OUTSTR: = V_TEST, it throws this exception.
I was confused, the out parameter in the procedure has a size? How can I set it?
Please help me!
Thank you very much!You must declare the size of the variable you use in the call to the procedure to be big enough.
The output parameter itself may not be declared with a size:
for example
Your appeal should be something like the following:
declare v_prmstr varchar2(4000) := 'Your input value'; v_prmoutstr varchar2(4000); begin myproc(v_prmstr,v_prmoutstr) ; end;
v_prmoutstr must be reported to be large enough to contain the value returned by the parameter
PRM_OUTSTRadded example variable
Published by: Keith Jamieson on August 11, 2011 13:32 -
How the parameter of the procedure with the default table type?
Hello!
How the parameter of the procedure with the default table type?
For example:type varchar2lType is table of varchar2(50) index by binary_integer;
Published by: bullbil on 16.01.2012 06:35create or replace procedure test1 ( s1 varchar2(50) sa2 Varchar2Type ) as begin dbms_output.put_line('yyxxyyy!'); end; /
If he should really be an associative array for some reason any (can't think why, but just for fun...) you could declare a dummy array in the packet header and specify as the default:
create or replace package wr_test as type varchar2ltype is table of varchar2(50) index by pls_integer; g_dflt_varchar2l_tab varchar2ltype; procedure testit ( p_testarray varchar2ltype default g_dflt_varchar2l_tab ); end wr_test; create or replace package body wr_test as procedure testit ( p_testarray varchar2ltype default g_dflt_varchar2l_tab ) is begin dbms_output.put_line('p_testarray contains ' || p_testarray.count || ' elements'); end testit; end wr_test;
It is a bit of a hack, because it relies on a global variable that is exposed. A more orderly approach would overload the procedure so that a version does not have the table and another argument:
create or replace package wr_test as type varchar2ltype is table of varchar2(50) index by pls_integer; procedure testit; procedure testit ( p_testarray varchar2ltype ); end wr_test; create or replace package body wr_test as procedure testit is v_default_array varchar2ltype; begin testit(v_default_array); end testit; procedure testit ( p_testarray varchar2ltype ) is begin dbms_output.put_line('p_testarray contains ' || p_testarray.count || ' elements'); end testit; end wr_test;
-
What is INSIDE and OUTSIDE in parameter of the procedure?
Hello
often IN, OUT and IN OUT are used with the parameter in the procedures and functions.
This means pass by value, by reference, we did in programming c / c++?When you create a procedure or function, you can set parameters. There are three types of parameters that may be declared:
1. - the parameter can be referenced by the procedure or function. The value of the parameter can not be overwritten by the procedure or function.
2 - the parameter may not be referenced by the procedure or function, but the value of the parameter can be replaced by the procedure or function.
3 AL '-the parameter can be referenced by the procedure or function and the value of the parameter can be replaced by the procedure or function. -
Hey everybody,
First of all, Yes, I searched through the 8.5 database schema guide. As I went through the scheme, I've developed some ideas on how to collect the data you want. However, if someone has already developed or found the SQL statements (which I'm sure that someone already has) it would help by reducing to the minimum of the buggs in my data collection program.
All these statistics must be grouped by CSQ and selected for a certain time interval (
and ). That is, levels of 1 hour. I have no problem to get a list of results and then perform v.f. to achieve the desired final result. Also, if I need to run several select statements for tables of essentially two join, please include two statements. Finally, I saw the RtCSQsSummary table, but I need to collect data for the past, not at this time. 1 total calls presented by the CSQ
2. total number of calls answered by the CSQ
3 total number of calls abandoned by the CSQ
4. percentage of calls abandoned by CSQ (if it is not stored in the database, I think:
/ ) 5. average abandon time in seconds (if it is not stored in the DB, I think: sum (
) / ) 6. service level - % calls answered in 90 seonds by a set of skills (I have seen metServiceLevel in the ContactQueueDetail table; however, I need to find how to configure this threshold for application)
7. average speed of response by CSQ
8 average conversation by CSQ calls
9. the aggregates connected full-time resources or agents CSQ
10. resources/agents of CSQ ready time
I realize that some of them should be easy to find (as I always am search in the guide of db schema), but I was reading how a new record is created for each step of the call so I could easily see how I could get inaccurate information without properly developed select statements.
Any help will be greatly appreciated.
Brendan
Brendan,
I read your message very well.
You have the schema of database with tables and description. each table has its associated tables (connected with primary and foreign keys). I think you should start the tables to determine what you need.
Cisco uses the stored procedure to prepare the reports. the stored procedure is 'sp_csq_interval' to create the report.
Activity report of Queue Service contact"
HTH
Anas
Please note all useful posts
-
Add more than 2 lines for a select statement without inserting rows in the base table
Hi all
I have a below a simple select statement that is querying a table.
Select * from STUDY_SCHED_INTERVAL_TEMP
where STUDY_KEY = 1063;
but here's the situation. As you can see its return 7 ranks. But I must add
2 rows more... with everything else, default or what exist... except the adding more than 2 lines.
I can't insert in the base table. I want my results to end incrementing by 2 days in
measurement_date_Taken on 01-APR-09... so big measurement_date_taken expected to
end at study_end_Date...
IS IT STILL POSSIBLE WITHOUT INSERT ROWS IN THE TABLE AND PLAYIHY ALL AROUND WITH
THE SELECT STATEMENT?
Sorry if this is confusing... I'm on 10.2.0.3
Published by: S2K on August 13, 2009 14:19Well, I don't know if this request is as beautiful as my lawn, but seems to work even when ;)
I used the "simplified" version, but the principle should work for your table, S2K.
As Frank has already pointed out (and I fell on it while clunging): simply select your already existing lines and union them with the 'missing documents', you calculate the number of days that you are "missing" based on the study_end_date:MHO%xe> alter session set nls_date_language='AMERICAN'; Sessie is gewijzigd. Verstreken: 00:00:00.01 MHO%xe> with t as ( -- generating your data here, simplified by me due to cat and lawn 2 select 1063 study_key 3 , to_date('01-MAR-09', 'dd-mon-rr') phase_start_date 4 , to_date('02-MAR-09', 'dd-mon-rr') measurement_date_taken 5 , to_date('01-APR-09', 'dd-mon-rr') study_end_date 6 from dual union all 7 select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('04-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all 8 select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('09-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all 9 select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('14-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all 10 select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('19-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all 11 select 1063, to_date('22-MAR-09', 'dd-mon-rr') , to_date('23-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all 12 select 1063, to_date('22-MAR-09', 'dd-mon-rr') , to_date('30-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual 13 ) -- actual query: 14 select study_key 15 , phase_start_date 16 , measurement_date_taken 17 , study_end_date 18 from t 19 union all 20 select study_key 21 , phase_start_date 22 , measurement_date_taken + level -- or rownum 23 , study_end_date 24 from ( select study_key 25 , phase_start_date 26 , measurement_date_taken 27 , study_end_date 28 , add_up 29 from ( 30 select study_key 31 , phase_start_date 32 , measurement_date_taken 33 , study_end_date 34 , study_end_date - max(measurement_date_taken) over (partition by study_key 35 order by measurement_date_taken ) add_up 36 , lead(measurement_date_taken) over (partition by study_key 37 order by measurement_date_taken ) last_rec 38 from t 39 ) 40 where last_rec is null 41 ) 42 where rownum <= add_up 43 connect by level <= add_up; STUDY_KEY PHASE_START_DATE MEASUREMENT_DATE_TA STUDY_END_DATE ---------- ------------------- ------------------- ------------------- 1063 01-03-2009 00:00:00 02-03-2009 00:00:00 01-04-2009 00:00:00 1063 03-03-2009 00:00:00 04-03-2009 00:00:00 01-04-2009 00:00:00 1063 03-03-2009 00:00:00 09-03-2009 00:00:00 01-04-2009 00:00:00 1063 03-03-2009 00:00:00 14-03-2009 00:00:00 01-04-2009 00:00:00 1063 03-03-2009 00:00:00 19-03-2009 00:00:00 01-04-2009 00:00:00 1063 22-03-2009 00:00:00 23-03-2009 00:00:00 01-04-2009 00:00:00 1063 22-03-2009 00:00:00 30-03-2009 00:00:00 01-04-2009 00:00:00 1063 22-03-2009 00:00:00 31-03-2009 00:00:00 01-04-2009 00:00:00 1063 22-03-2009 00:00:00 01-04-2009 00:00:00 01-04-2009 00:00:00 9 rijen zijn geselecteerd.
Is there a simpler way (in SQL), I hope that others join, and share their ideas/example/thoughts.
I feel that it is using more resources there.
But I have to cut the daisies before now, they interfere my 'grass-green-ess";) -
Get multiple values in a select statement in a variable to a procedure
Hello
I'm trying to craete a procedure where the entry of the procedure will be a similar string "a, b, c, d" and output the values of a table that matches the value separated by commas of in sting.
For this.
create table test (varchar2 (10)) nm;
Insert test values ('a');
Insert test values ('b');
Insert test values ('c');
Insert test values (');
Select * from test;
NM
------
one
b
c
d
Now I'm doing a procedure where the parameter will be the column values NM of TEST table in a string separated by commas like "a, b, c, d, x, l" there could be false values also.
The procedure will return only the values that are adapted with column NM from the TEST table for this I created this procedure.
create or replace procedure p_test (p_nm IN varchar2 / *, THE sys_refcursor p_out * /)
is
number of l_len;
l_val varchar2 (10);
l_val1 varchar2 (10);
Start
l_len: = length (p_nm);
-dbms_output.put_line (l_len);
Start
because me in 1.l_len
loop
Select REGEXP_SUBSTR (p_nm, ' ([^,] *)(,|$)', 1, I, NULL, 1) in double l_val;
-dbms_output.put_line (l_val);
-Open p_out for
Select * into l_val1 of test where nm = l_val;
dbms_output.put_line (l_val1);
output when l_len is null;
end loop;
exception
When no_data_found then
null;
end;
exception
while others then
dbms_output.put_line (' error reason :'||) SQLERRM |' :'|| error code SQLCODE);
end;
EXECUTE p_test ('a, b, c, d, q, w');
OUTPUT-
one
b
c
d
This procedure gives me out as I need, but I need to get this in a variable which should be OUT the parameter of this procedure will be called by the JAVA for our application.
As I already tried to use the refcursor (see the commented part), but it gives me no output during a call there.
Its a call to this procedure when I use the refcursor (removing comments).
declare
l_out sys_refcursor;
l_val varchar2 (20);
l_str varchar2 (20): = 'a, b, c, d;
Start
p_test (l_str, l_out);
loop
extract the l_out in l_val;
dbms_output.put_line (l_val);
dbms_output.put_line ('a');
When the output l_out % notfound;
end loop;
end;
So here I am stuck with that, how to get the result of multiple or I'm missing something here and if there is a better approach to this requirement as I come with that so I'm sharing it here.
OR if someone can tell me what is the problem with this package-
create or replace package p_test_api
is
type t_rec is rendered (name varchar2 (200));
type t_tab is table of index by pls_integer t_rec;
procedure p_pest_proc (p_nm in varchar2, p_out to t_tab);
end p_test_api;
/
create or replace package body p_test_api
is
procedure p_pest_proc (p_nm in varchar2, p_out to t_tab)
is
number of l_len;
l_val varchar2 (10);
l_val1 varchar2 (10);
Start
l_len: = length (p_nm);
Start
because me in 1.l_len
loop
Select REGEXP_SUBSTR (p_nm, ' ([^,] *)(,|$)', 1, I, NULL, 1) in double l_val;
dbms_output.put_line (l_val);
Select * bulk collect into p_out test where nm = l_val;
output when l_len is null;
end loop;
exception
When no_data_found then
null;
end;
exception
while others then
dbms_output.put_line (' error reason :'||) SQLERRM |' :'|| error code SQLCODE);
end p_pest_proc;
end p_test_api;
CALL THIS PACKAGE-
declare
l_out p_test_api.t_tab;
l_str varchar2 (20): = 'a, b, c, d;
Start
P_TEST_API. P_PEST_PROC (l_str, l_out);
dbms_output.put_line ('b');
because me in 1.l_out.count
loop
dbms_output.put_line ('a');
dbms_output.put_line (l_out (i). (Name)
dbms_output.put_line ('a');
When the output l_out.count = 0;
end loop;
dbms_output.put_line ('a');
end;
It won't loop
I am using-
Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production
Thank you
First of all, get rid of it WHEN OTHERS like William already noted. If you do not want to use the collections:
SQL > create or replace
function f_test () 2
3 p_nm varchar2
4 )
5 return varchar2
6 is
v_result 7 varchar2 (4000);
Start 8
9. Select listagg (nm, ',') within the Group (nm control)
10 in v_result
11 test
where the 12 «,» | p_nm | ',' like '%', | NM | ',%';
13 return v_result;
14 end;
15.The function is created.
SQL > start
2 dbms_output.put_line (f_test ('a, b, c, d, x, w'));
3 end;
4.
a, b, c and dPL/SQL procedure successfully completed.
SQL >
SY.
-
Problem in Varray as a parameter to the procedure
Hi all
I've created a type AS
I am passing table as a parameter for the oracle java before procedure. How to spend together in SQL when the condition is it possible to archive?CREATE OR REPLACE TYPE v_tmp_array IS VARRAY(100) OF NUMBER;
Thanks and greetingsCREATE OR REPLACE PROCEDURE Proc_Varry_Para(p_array IN v_tmp_array, v_tmp OUT REF CURSOR) AS BEGIN BMS_OUTPUT.PUT_LINE( 'begin' ); SELECT * FROM ADDRESS WHERE ADDR_ID = p_array; --- need to pass whole array value in where condition. OPEN v_tmp FOR v_sql_text; END; /
SaamiSELECT * FROM ADDRESS, TABLE (p_array) t WHERE ADDR_ID = t.COLUMN_VALUE;
-
issues related to the parameter in the procedure
Hi all
I have a procedure which the code is given below:
create or replace PROCEDURE seods01.get_cert_tx_lot_tmp (acct_alt_id_in in VARCHAR2
, acct_alt_id_cntx_cde_in IN VARCHAR2 default 'COLA account number.
, ibd_id_in IN INTEGER
qry_rslt_out to sys_refcursor)
IS
BEGIN
OPEN FOR Qry_rslt_out
SELECT L.tx_lot_seq_nbr
L.hld_prd_dte
L.orig_purc_dte
L.tx_lot_amt
L.updt_tx_lot_amt
L.tran_desc_txt
OF v_acct_alt_id A
v_cd_tx_lot L
WHERE A.acct_alt_id = acct_alt_id_in
AND A.acct_alt_id_cntx_cde = acct_alt_id_cntx_cde_in
AND A.ibd_id = ibd_id_in
AND L.eods_acct_id = A.eods_acct_id;
EXCEPTION
WHILE OTHERS THEN
dbms_output.put_line(SQLCODE||) SQLERRM);
END get_cert_tx_lot_tmp;
now when I run the SP in the following way it works fine:
VAR C1 REFCURSOR EXECUTE SEODS01.get_cert_tx_lot_tmp ('004000000000000093108026740', 'Number of COLA account', '1',: C1); PRINT C1
When I try to ignore this value by default setting, then it is throwing ' wrong number or types of arguments "error
VAR C1 REFCURSOR EXECUTE SEODS01.get_cert_tx_lot_tmp ('004000000000000093108026740 ', ' 1',: C1); PRINT C1
and when I tried to put this as null or "then it gives me no results. only way through which I can produce results of this procedure without giving the default parameter is the name of the column with the value of the parameter as follows:
VAR C1 REFCURSOR RUN SEODS01.get_cert_tx_lot_tmp (acct_alt_id_in = > '004000000000000093108026740', ibd_id_in = > '1', qry_rslt_out = >: C1); PRINT C1
but the condition is that we do not want our consumers to put names of columns when they do not pass the default value setting, I hope that there should be a way to do it. Could someone help me please on this issue.
Hello
If you want to use positional notation, then you can only omit parameters by default when they are at the end of the parameter list. In your case, this would mean
(acct_alt_id_in in VARCHAR2
ibd_id_in in FULL
qry_rslt_out ON sys_refcursor
acct_alt_id_cntx_cde_in IN VARCHAR2 default 'COLA account number')
Or you can put the procedure in a package and overload
PROCEDURE seods01.get_cert_tx_lot_tmp
(acct_alt_id_in in VARCHAR2
acct_alt_id_cntx_cde_in IN VARCHAR2
ibd_id_in in FULL
qry_rslt_out to sys_refcursor)
PROCEDURE seods01.get_cert_tx_lot_tmp
(acct_alt_id_in in VARCHAR2
ibd_id_in in FULL
qry_rslt_out to sys_refcursor)
In the procedure without the acct_alt_id_cntx_cde_in parameter, you can call the other version and provide the default value.
Concerning
Marcus
-
procedure call with sys_refcursor as a parameter in the procedure
Hello
I tried the following procedure after sys_refcursor as parameter of a procedure,
And confused about the procedure call
How can I call the above procedure to get the dataCREATE OR REPLACE PROCEDURE test_ref (emp_cur IN sys_refcursor) IS emp_rec Z_emp%ROWTYPE; BEGIN LOOP FETCH emp_cur INTO emp_rec; EXIT WHEN emp_cur%NOTFOUND; dbms_output.put_line(emp_rec.ename ||' is a ' || emp_rec.job); END LOOP; END;
Thank youYou must declare a variable sys_refcursor and open it with the necessary query and then pass that variable as a parameter to your procedure.
Something like that.
set serveroutput on declare my_cursor sys_refcursor; begin open my_cursor for select * from employee; test_ref (my_cursor); end; /
-
pass values of parameter to the procedure stored in the URL, possible?
Hi, everyone, our system is Apex4.0.2 in Linux CentOS 5 on Oracle 11 g 2, here is the procedure:
create or replace procedure test_public (Cust_id integer)
is
Start
owa_util.mime_header ("text/xml", FALSE);
owa_util.mime_header ("application/octet", FALSE);
-Close the HTTP header
owa_util.http_header_close;
HTP.p (DBMS_XMLGEN.getXML ("SELECT * FROM demo_orders where customer_id ='|")) cust_ID));
end;
+/+
the call to the stored procedure is SUCCESSFUL when Test_public has no parameters, as:
http://myserver/Apex/myschema.test_public (OK)
the question is: I want to spend the 3 settings in my stored procedure (on production procedure), do not know how?
Any suggestions are greatly appreciatedcreate or replace procedure test_public (param1, param2 IN VARCHAR2, param3 in NUMBER IN number)
http://myserver/apex/myschema.test_public?param1=
¶m2= ¶m3=
Maybe you are looking for
-
HP SimpleSSave: Remove all SimpleSave reader files and starting over?
I have a HP SimpleSave external drive. P/N HPBAAC3200ABK - 00, S/N WXCOA8962886, model number HPsd320a. I filed years ago and went to a larger external drive. All the info on this SimpleSave is on my new drive. I want to remove everything about Simpl
-
Overclocking graphics card on Satellite L650
Hello IM really looking forward by overclocking my GPU (ATI 5470 M) when trying to install ATI catalyst in my laptop (L650 series psk1ja-ofno17), but it keeps getting an error that says that it is not compatible. I also note that the CCC is delivered
-
Help! Challenge continues to restart.
I got challenges him on Friday and had to return because it keeps restarting. They gave me a new and guess what... Well Yes, it does exactly the same thing. Strange thing is that without the sim card installed, it is not a problem, but when it is ins
-
Speakers work, but the microphone does not after OS reinstalled (dv6)
Sound is played through the speakers, but the Bay internal microphone and external microphone device receive no signal. Windows recognizes these devices, but the volume on the sound Panel Monitor is inactive. In addition, the webcam works fine. I jus
-
How to use LabView for Pyros fire (devices)
I searched NI Forums and google on this subject, but can't find much. Can someone help me understand what modules I need to shoot a few different pyros (aka, Squibs devices) such as cable cutters, bottle openers, etc.? We use a 9172 chassis. I can