How to tune a plsql procedure
Hi folks,
Need some guide line or tips, how one should tune or better to say monitor/check the processing and functionality of a pl/sql procedure or even function or package too, at least for now I need to review one pl/sql procedure.
I know how to verify/check individual sql, but in this case this procedure involves in a bulk collect.
Any idea, thoughts, guideline or suggestions would highly be appreciated.
Thanks in advance.
user8604530 wrote:
Hi folks,
Need some guide line or tips, how one should tune or better to say monitor/check the processing and functionality of a pl/sql procedure or even function or package too, at least for now I need to review one pl/sql procedure.
I know how to verify/check individual sql, but in this case this procedure involves in a bulk collect.
Any idea, thoughts, guideline or suggestions would highly be appreciated.
Thanks in advance.Thread: HOW TO: Post a SQL statement tuning request - template posting
HOW TO: Post a SQL statement tuning request - template posting
DBMS_SESSION.SESSION_TRACE_ENABLE(TRUE,TRUE,'ALL_EXECUTIONS');
-- invoke the problem procedure here
DBMS_SESSION.SESSION_TRACE_ENABLE(FALSE,FALSE,NULL);
Similar Messages
-
How to tune the follwoing procedure?
create or replace procedure sample(verror_msg in out varchar2,
vbrn_num in tb_branches.brn_num%type) is
ltext1 varchar2(500);
ltext2 varchar2(500);
ltable_name varchar2(50);
lcolumn_name varchar2(50);
ldata_type varchar2(50);
lold_rcn_num number;
lnew_rcn_num number;
lvalue varchar2(50);
lunit_type char(1);
lsql_stmt1 varchar2(500);
lstring varchar2(500);
lcol varchar2(10);
lstart_time VARCHAR2(100);
lend_time VARCHAR2(100);
lcommit VARCHAR2(10) := 'COMMIT;';
lfile_handle1 utl_file.file_type;
lfile_handle2 utl_file.file_type;
lfile_handle3 utl_file.file_type;
lfile_handle4 utl_file.file_type;
lfile_name1 VARCHAR2(50) := 'RCN_UPDATE_STMTS_' || vbrn_num || '.SQL';
lfile_name2 VARCHAR2(50) := 'RCNSUCCESS_' || vbrn_num || '.TXT';
lfile_name3 VARCHAR2(50) := 'RCNFAIL_' || vbrn_num || '.TXT';
lfile_name4 VARCHAR2(50) := 'RCNERROR_' || vbrn_num || '.TXT';
ldirectory_name VARCHAR2(100);
ldirectory_path VARCHAR2(100);
lspool_on VARCHAR2(100);
lspool_off VARCHAR2(100);
TYPE ref_cur IS REF CURSOR;
cur_tab_cols ref_cur;
cursor c1 is
SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE
FROM USER_TAB_COLS
WHERE TABLE_NAME NOT LIKE 'TB_CONV%'
and TABLE_NAME LIKE 'TB_%'
AND COLUMN_NAME LIKE '%RCN%'
UNION
SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE
FROM USER_TAB_COLS
WHERE TABLE_NAME in ('TB_UNITCODES', 'TB_HIST_UNITCODES')
AND COLUMN_NAME = 'UNIT_CODE'
order by table_name;
BEGIN
verror_msg := nvl(verror_msg, 0);
begin
SELECT DISTINCT directory_path, directory_name
INTO ldirectory_path, ldirectory_name
FROM tb_conv_path
WHERE brn_num = vbrn_num;
EXCEPTION
WHEN NO_DATA_FOUND THEN
SP_CO_RAISEERROR('00SY00402', 'F', 'T');
WHEN others THEN
SP_CO_RAISEERROR('00SY00401X', 'F', 'T');
END;
lfile_handle1 := utl_file.fopen(ldirectory_name, lfile_name1, 'W', 32767);
lfile_handle2 := utl_file.fopen(ldirectory_name, lfile_name2, 'W', 32767);
lfile_handle3 := utl_file.fopen(ldirectory_name, lfile_name3, 'W', 32767);
lfile_handle4 := utl_file.fopen(ldirectory_name, lfile_name4, 'W', 32767);
SELECT 'SPOOL ' || ldirectory_path || '/LOG_' || lfile_name1
INTO lspool_on
FROM dual;
utl_file.put_line(lfile_handle1, lspool_on);
utl_file.new_line(lfile_handle1, 1);
select 'EXEC SP_CONV_START_TIMELOG(' || '''' || 'LOG_' || lfile_name1 || '''' || ',' ||
vbrn_num || ');'
into lstart_time
from dual;
UTL_FILE.PUT_LINE(lfile_handle1, lstart_time);
UTL_FILE.NEW_LINE(lfile_handle1, 1);
open C1;
loop
Fetch C1
into ltable_name, lcolumn_name, ldata_type;
Exit When C1%notFound;
lsql_stmt1 := 'select column_name from user_tab_columns where table_name =' || '''' ||
ltable_name || '''' ||
' AND column_name in (''BRN_NUM'',''BRANCH'',''BRANCH_NUMBER'')';
begin
execute immediate lsql_stmt1
into lcol;
exception
when no_data_found then
lcol := null;
end;
if lcol is not null then
if ltable_name in ('TB_UNITCODES', 'TB_HIST_UNITCODES') then
ltext2 := 'select distinct ' || lcolumn_name || ' from ' ||
ltable_name ||
' a, (select distinct new_rcn_num col from tb_conv_rcn_mapping where brn_num = ' ||
vbrn_num || ') b where a.' || lcolumn_name ||
' = b.col(+) and b.col is null and a.' || lcolumn_name ||
' is not null and ' || lcol || ' = ' || vbrn_num ||
' and a.unit_type=''9''';
else
ltext2 := 'select distinct ' || lcolumn_name || ' from ' ||
ltable_name ||
' a, (select distinct new_rcn_num col from tb_conv_rcn_mapping where brn_num = ' ||
vbrn_num || ') b where a.' || lcolumn_name ||
' = b.col(+) and b.col is null and a.' || lcolumn_name ||
' is not null and ' || lcol || ' = ' || vbrn_num;
end if;
OPEN cur_tab_cols FOR ltext2;
loop
fetch cur_tab_cols
into lvalue;
exit when cur_tab_cols%notfound;
begin
IF VBRN_NUM IN (21, 6, 7, 8) THEN Commented during NAP HK SIT cycle1
SELECT DISTINCT NEW_RCN_NUM, OLD_RCN_NUM
INTO LNEW_RCN_NUM, LOLD_RCN_NUM
FROM TB_CONV_RCN_MAPPING
WHERE OLD_RCN_NUM = LVALUE
AND BRN_NUM = VBRN_NUM;
/* ELSE
SELECT DISTINCT NEW_RCN_NUM, OLD_RCN_NUM
INTO LNEW_RCN_NUM, LOLD_RCN_NUM
FROM TB_CONV_RCN_MAPPING
WHERE OLD_RCN_NUM = LVALUE
AND NEW_RCN_NUM NOT LIKE '40%'
AND NEW_RCN_NUM NOT LIKE '41%'
AND NEW_RCN_NUM NOT LIKE '42%'
AND NEW_RCN_NUM NOT LIKE '65%'
AND BRN_NUM = VBRN_NUM;
END IF; */ -- Commented during NAP HK SIT cycle1
if ldata_type = 'NUMBER' then
if ltable_name in ('TB_UNITCODES', 'TB_HIST_UNITCODES') and
lcolumn_name = 'UNIT_CODE' then
begin
select distinct unit_type
into lunit_type
from TB_UNITCODES
where lcol = vbrn_num
and unit_code = lvalue
and unit_type = '9';
exception
when no_data_found then
lunit_type := null;
end;
if lunit_type is not null then
ltext1 := 'update ' || ltable_name || ' set ' ||
lcolumn_name || ' = ' || lnew_rcn_num ||
' where ' || lcolumn_name || ' = ' ||
lold_rcn_num || ' and ' || lcol || ' = ' ||
vbrn_num || ' and unit_type = ' || '''9''' || ';';
utl_file.put_line(lfile_handle1, ltext1);
utl_file.new_line(lfile_handle1, 0);
utl_file.put_line(lfile_handle1, lcommit);
utl_file.put_line(lfile_handle2,
ltable_name || ' - ' || lcolumn_name ||
' - ' || lold_rcn_num || ' - ' ||
lnew_rcn_num || ' - ' || vbrn_num);
utl_file.new_line(lfile_handle2, 0);
end if;
else
ltext1 := 'update ' || ltable_name || ' set ' || lcolumn_name ||
' = ' || lnew_rcn_num || ' where ' || lcolumn_name ||
' = ' || lold_rcn_num || ' and ' || lcol || ' = ' ||
vbrn_num || ';';
utl_file.put_line(lfile_handle1, ltext1);
utl_file.new_line(lfile_handle1, 0);
utl_file.put_line(lfile_handle1, lcommit);
utl_file.new_line(lfile_handle1, 0);
utl_file.put_line(lfile_handle2,
ltable_name || ' - ' || lcolumn_name ||
' - ' || lold_rcn_num || ' - ' ||
lnew_rcn_num || ' - ' || vbrn_num);
utl_file.new_line(lfile_handle2, 0);
end if;
else
if ltable_name in ('TB_UNITCODES', 'TB_HIST_UNITCODES') and
lcolumn_name = 'UNIT_CODE' then
begin
lstring := 'select distinct unit_type from ' || ltable_name ||
' where ' || lcol || ' = ' || vbrn_num ||
' and ' || lcolumn_name || ' = ' || '''' ||
lvalue || '''' || ' and unit_type = ' || '''9''';
execute immediate lstring
into lunit_type;
exception
when no_data_found then
lunit_type := null;
end;
if lunit_type is not null then
ltext1 := 'update ' || ltable_name || ' set ' ||
lcolumn_name || ' = ' || '''' || lnew_rcn_num || '''' ||
' where ' || lcolumn_name || ' = ' || '''' ||
lold_rcn_num || '''' || ' and ' || lcol || ' = ' ||
vbrn_num || ' and unit_type = ' || '''9''' || ';';
utl_file.put_line(lfile_handle1, ltext1);
utl_file.new_line(lfile_handle1, 0);
utl_file.put_line(lfile_handle1, lcommit);
utl_file.new_line(lfile_handle1, 0);
utl_file.put_line(lfile_handle2,
ltable_name || ' - ' || lcolumn_name ||
' - ' || lold_rcn_num || ' - ' ||
lnew_rcn_num || ' - ' || vbrn_num);
utl_file.new_line(lfile_handle2, 0);
end if;
else
ltext1 := 'update ' || ltable_name || ' set ' || lcolumn_name ||
' = ' || '''' || lnew_rcn_num || '''' || ' where ' ||
lcolumn_name || ' = ' || '''' || lold_rcn_num || '''' ||
' and ' || lcol || ' = ' || vbrn_num || ';';
utl_file.put_line(lfile_handle1, ltext1);
utl_file.new_line(lfile_handle1, 0);
utl_file.put_line(lfile_handle1, lcommit);
utl_file.new_line(lfile_handle1, 0);
utl_file.put_line(lfile_handle2,
ltable_name || ' - ' || lcolumn_name ||
' - ' || lold_rcn_num || ' - ' ||
lnew_rcn_num || ' - ' || vbrn_num);
utl_file.new_line(lfile_handle2, 0);
end if;
end if;
exception
When NO_DATA_FOUND THEN
utl_file.put_line(lfile_handle3,
ltable_name || ' - ' || lcolumn_name || ' - ' ||
lvalue || ' - ' || 'NO MAPPING FOUND' ||
' - ' || vbrn_num);
utl_file.new_line(lfile_handle3, 0);
when others then
utl_file.put_line(lfile_handle4,
ltable_name || ' - ' || lcolumn_name || ' - ' ||
lvalue || ' - ' || SQLERRM || ' - ' ||
vbrn_num);
utl_file.new_line(lfile_handle4, 0);
end;
end loop;
ELSE
ltext2 := 'select distinct ' || lcolumn_name || ' from ' ||
ltable_name ||
' a, (select distinct new_rcn_num col from tb_conv_rcn_mapping where brn_num = ' ||
vbrn_num || ') b where a.' || lcolumn_name ||
' = b.col(+) and b.col is null and a.' || lcolumn_name ||
' is not null';
OPEN cur_tab_cols FOR ltext2;
loop
fetch cur_tab_cols
into lvalue;
exit when cur_tab_cols%notfound;
begin
IF VBRN_NUM IN (21, 6, 7, 8) THEN Commented during NAP HK SIT cycle1
SELECT DISTINCT NEW_RCN_NUM, OLD_RCN_NUM
INTO LNEW_RCN_NUM, LOLD_RCN_NUM
FROM TB_CONV_RCN_MAPPING
WHERE OLD_RCN_NUM = LVALUE
AND BRN_NUM = VBRN_NUM;
/* ELSE
SELECT DISTINCT NEW_RCN_NUM, OLD_RCN_NUM
INTO LNEW_RCN_NUM, LOLD_RCN_NUM
FROM TB_CONV_RCN_MAPPING
WHERE OLD_RCN_NUM = LVALUE
AND NEW_RCN_NUM NOT LIKE '40%'
AND NEW_RCN_NUM NOT LIKE '41%'
AND NEW_RCN_NUM NOT LIKE '42%'
AND NEW_RCN_NUM NOT LIKE '65%'
AND BRN_NUM = VBRN_NUM;
END IF; */ -- Commented during NAP HK SIT cycle1
if ldata_type = 'NUMBER' then
ltext1 := 'update ' || ltable_name || ' set ' || lcolumn_name ||
' = ' || lnew_rcn_num || ' where ' || lcolumn_name ||
' = ' || lold_rcn_num || ';';
utl_file.put_line(lfile_handle1, ltext1);
utl_file.new_line(lfile_handle1, 0);
utl_file.put_line(lfile_handle1, lcommit);
utl_file.new_line(lfile_handle1, 0);
utl_file.put_line(lfile_handle2,
ltable_name || ' - ' || lcolumn_name || ' - ' ||
lold_rcn_num || ' - ' || lnew_rcn_num ||
' - ' || vbrn_num);
utl_file.new_line(lfile_handle2, 0);
else
ltext1 := 'update ' || ltable_name || ' set ' || lcolumn_name ||
' = ' || '''' || lnew_rcn_num || '''' || ' where ' ||
lcolumn_name || ' = ' || '''' || lold_rcn_num || '''' || ';';
utl_file.put_line(lfile_handle1, ltext1);
utl_file.new_line(lfile_handle1, 0);
utl_file.put_line(lfile_handle1, lcommit);
utl_file.new_line(lfile_handle1, 0);
utl_file.put_line(lfile_handle2,
ltable_name || ' - ' || lcolumn_name || ' - ' ||
lold_rcn_num || ' - ' || lnew_rcn_num ||
' - ' || vbrn_num);
utl_file.new_line(lfile_handle2, 0);
end if;
exception
When NO_DATA_FOUND THEN
utl_file.put_line(lfile_handle3,
ltable_name || ' - ' || lcolumn_name || ' - ' ||
lvalue || ' - ' || 'NO MAPPING FOUND' ||
' - ' || vbrn_num);
utl_file.new_line(lfile_handle3, 0);
when others then
utl_file.put_line(lfile_handle4,
ltable_name || ' - ' || lcolumn_name || ' - ' ||
lvalue || ' - ' || SQLERRM || ' - ' ||
vbrn_num);
utl_file.new_line(lfile_handle4, 0);
end;
end loop;
end if;
end loop;
close c1;
utl_file.new_line(lfile_handle1, 1);
select 'EXEC SP_CONV_END_TIMELOG(' || '''' || 'LOG_' || lfile_name1 || '''' || ',' ||
vbrn_num || ');'
into lend_time
from dual;
UTL_FILE.PUT_LINE(lfile_handle1, lend_time);
UTL_FILE.NEW_LINE(lfile_handle1, 1);
SELECT 'SPOOL OFF;' INTO lspool_off FROM dual;
utl_file.put_line(lfile_handle1, lspool_off);
utl_file.new_line(lfile_handle1, 1);
utl_file.fclose(lfile_handle1);
utl_file.fclose(lfile_handle2);
utl_file.fclose(lfile_handle3);
utl_file.fclose(lfile_handle4);
exception
when others then
verror_msg := sqlcode || ' ~ ' || sqlerrm;
utl_file.put_line(lfile_handle4,
ltable_name || ' - ' || lcolumn_name || ' - ' ||
lvalue || ' - ' || SQLERRM || ' - ' || vbrn_num);
utl_file.new_line(lfile_handle4, 0);
utl_file.new_line(lfile_handle4, 0);
utl_file.fclose(lfile_handle1);
utl_file.fclose(lfile_handle2);
utl_file.fclose(lfile_handle3);
utl_file.fclose(lfile_handle4);
end sample;duplicate:
how to tune the follwoing procedure? -
How Can i get PLSQL Procedure out values in Shell Script?
Hi,
I need to use PLSQL Procedure out values in shell script by using that parameter i need to check and call the other procedure. Please can you guide me how can i?
#!/bin/ksh
# Function to call validation program
SQL_PKG_CALL()
echo "Inside SQL_PKG_CALL for $file"
sqlplus -s /nolog << EOF
whenever sqlerror exit failure
connect ${APPS_LOGIN}
variable exit_value NUMBER
set serveroutput on size 100000
DECLARE
l_errbuf VARCHAR2(10000) := NULL; l_retcode NUMBER := NULL;lv_test VARCHAR2(4000) := NULL;
BEGIN
fnd_global.apps_initialize ( USER_ID => ${USER_ID}, RESP_ID => ${RESP_ID}, RESP_APPL_ID => ${RESP_APPL_ID}
, SECURITY_GROUP_ID => ${SECURITY_GROUP_ID}
#Calling PLSQL procedure for create and attache document
XXAFPEEP_SO_DOC_ATTACH_INT.DOCUMENT_ATTACH (p_errbuf => l_errbuf, p_retcode => :RETMSG, p_fileName => $file
, p_debug => 'Y', p_rettest => lv_test);
# to print the procedure return values
DBMS_OUT.PUT_LINE('Return Message: '|| lv_test);
#${RETCODE}=l_retcode;
print :RETMSG;
END;
EXIT 0
EOF
# Program starts here
echo "+---------------------------------------------------------------------------+"
echo "Program Start"
APPS_LOGIN=${1} # Apps Login
USER_ID=${2} # User ID
RESP_ID=${5} # Responsiblity ID
RESP_APPL_ID=${6} # Responsiblity Application ID
SECURITY_GROUP_ID=${7} # Security Group ID
DIRECTORY_PATH=${8} # Directory --Attached file locations
DIRECTORY_NAME=${9} # Directory Name for plsql
echo "User ID : $USER_ID"
echo "Responsibility ID : $RESP_ID"
echo "Responsibilith Application ID : $RESP_APPL_ID"
echo "Security Goup ID : $SECURITY_GROUP_ID"
echo "Directory Path : $DIRECTORY_PATH"
echo "Direcotry Name : $DIRECTORY_NAME"
echo
#files direcotry
cd $DIRECTORY_PATH
echo Present Working Directory: `pwd`
echo
#for all file names
ALL_FILES=`ls *.pdf`
for file in $ALL_FILES
do
if [ -f $file ]
then
#log "Processing $file" # future
echo Processing: $file
# Calling the PL/SQL Program
SQL_PKG_CALL;
#echo "Retcode : $RETCODE"
echo "RetMessage : $RETMSG"
else
log "Skipped $file: invalid file"
echo "Skipping current file $file: not a valid file."
fi
done
Thanks
SudheerSaubhik's provided the solution, but just for fun:
Test procedure:
create or replace procedure get_ename
( p_empno in emp.empno%type
, p_ename_out out emp.ename%type )
is
begin
select ename into p_ename_out
from emp
where empno = p_empno;
end get_ename;Test data:
SQL> select empno, ename from emp order by 1;
EMPNO ENAME
7369 SMITH
7499 ALLEN
7521 WARD
7566 JONES
7654 MARTIN
7698 BLAKE
7782 CLARK
7788 SCOTT
7839 KING
7844 TURNER
7876 ADAMS
7900 JAMES
7902 FORD
7934 MILLER
14 rows selectedTest call from SQL*Plus to show it working:
SQL> declare
2 v_ename emp.ename%type;
3 begin
4 get_ename(7844,v_ename);
5 dbms_output.put_line(v_ename);
6 end;
7 /
TURNER
PL/SQL procedure successfully completed.Demo shellscript (borrowing the function idea from Saubhik):
#!/bin/ksh
empno=${1:-NULL}
exec_sql() {
sqlplus -s william/w@//vm.starbase.local:1521/eleven <<END_SQL
spool get_out_value.sh.log
set serverout on size 2000 feedback off
declare
v_name emp.ename%type;
begin
get_ename(${empno},v_name);
dbms_output.put_line('# ' || v_name);
end;
spool off
exit
END_SQL
ename=$(exec_sql ${empno} | awk '/^# / {print $2}')
print Employee ${empno} = ${ename}Demo:
/Users/williamr: get_out_value.sh 7844
Employee 7844 = TURNER
/Users/williamr: get_out_value.sh
Employee NULL =Note this substitutes the word NULL if no empno is passed, and it ignores error output or anything else by only looking for lines beginning '# ' and then taking the following word. Error messages will appear in the logfile. (In this example it probably doesn't need the NULL substitution because a missing parameter would cause a syntax error which the script will handle anyway, but it could be useful in more complex examples.)
For a production script you should probably use an OS authenticated account so you don't have to deal with password strings. -
How to call a PLSQL procedure from MSexcel ?
Hi all.
This is a beginner question. I do not know anything about OLE DB.
I have an Excel sheet on one side.
I have a 9i DB 9.0.1.4 on Sun Sparc on the other side.
I need to call a PLSQL procedure directly from Excel.
HOW TO ?
(This is simply because I need to pass eastern europe special caracters to my PLSQL procedure. Is there another way to do so?)
Best Regards.In MS Excel you use VBA as the Macro Language.
You will need to install the Oracle client and the OLEdb provider.
Once this is done, Run the samples in Visual basic to test connectivity to your database (if you can).
In either case, look at the VB code that connects and calls an Oracle stored procedure. THis code is almost identical in VBA.
Make sure you reference the Microsoft ADO references. -
hi all,
tell me any one how to tune the plsql code in oracle plsqlYou could have googled a bit ->
http://www.google.co.in/#hl=en&q=tuning+pl+sql+in+oracle&meta=&aq=&oq=tuning+pl+sql+in+oracle&fp=3c5f05f17abf6d93
Regards.
Satyaki De. -
Update a table using plsql procedure
Can any one help me to write a plsql procedure to update a table with new records and changes;
Table rtest1 contains following records:
deptno(number) deptname(varchar2(10)
10 EWP
20 PWD
30 EPF
Table rtest2 contains follwing records:
deptno(number) deptname(varchar2(10)
10 prod
40 ops
how to write a plsql procedure to to update table rtest2 using rtest1 data .use a merge statement, like this:
SQL> create table rtest1
2 as
3 select 10 deptno, 'EWP' deptname from dual union all
4 select 20, 'PWD' from dual union all
5 select 30, 'EPF' from dual
6 /
Tabel is aangemaakt.
SQL> create table rtest2
2 as
3 select 10 deptno, 'prod' deptname from dual union all
4 select 40, 'ops' from dual
5 /
Tabel is aangemaakt.
SQL> create procedure my_merge
2 is
3 begin
4 merge into rtest2 r2
5 using (select deptno, deptname from rtest1) r1
6 on (r2.deptno = r1.deptno)
7 when matched then
8 update set deptname = r1.deptname
9 when not matched then
10 insert (deptno,deptname) values (r1.deptno,r1.deptname)
11 ;
12 end;
13 /
Procedure is aangemaakt.
SQL> exec my_merge
PL/SQL-procedure is geslaagd.
SQL> select * from rtest2 order by deptno
2 /
DEPTNO DEPT
10 EWP
20 PWD
30 EPF
40 ops
4 rijen zijn geselecteerd.Regards,
Rob. -
How to call plsql procedure or function and getting back the string?
Hi Everyone,
i am using Jdev 11.1.1.5.0.
i have a requirement to call plsql procedure or function from my backing bean java file and get back the returned value from the procedure or function.
what piece of simple code i need to write in my backing bean?
please suggest.
Thanks.As always you write the method to call he pl/sql in the application module, expose this method to the client (so you see it in the datacontroll) then create a operation binding to the method and call this operation from the bean. The result you get by operation.getResult();
You should never call pl/sql from the bean directly!
The doc shows how to call the procedure from an application module: http://docs.oracle.com/cd/E21764_01/web.1111/b31974/bcadvgen.htm#sm0297
Timo -
How to pass int array as an IN parameter to PLSQL Procedure
Hi,
How to pass int array in java to a stored procedure througn jdbc
and what type of data type I should declare to this IN parameter
in PLSQL Procedure.
Thanks,
SimiHi,
The best way to do what you want depends on what you want. Start by describing what you need to do. It's best to post some sample data (CREATE TABLE and INSERT statments) and what results you want from that sample data. (See the forum FAQ: https://forums.oracle.com/message/9362002)
If you have ideas about how to do the job (e.g., populating a temporary table) it can be helpful to include those, too, but distinguish clearly between WHAT you need to do and HOW you might do it.
As Bencol suggested, a SYS_REFCURSOR might be the best way to pass back the results.
Since you didn't post your table, or even describe what you wanted to do with it, I'll illustrate using scott.emp, which is probably on your system.
Say you wanted a procedure that took a DATE as an argument, and returned a some designated columns (empno, ename and hiredate in the example below) for all employees hired on or after the given DATE. You might write a procedure like this:
CREATE OR REPLACE PROCEDURE hired_since
( start_date IN DATE
, out_data OUT SYS_REFCURSOR
AS
BEGIN
OPEN out_data FOR
SELECT empno, ename, hiredate
FROM scott.emp
WHERE hiredate >= start_date;
END hired_since;
SHOW ERRORS
You can test it in SQL*Plus like this:
VARIABLE c REFCURSOR
EXEC hired_since (DATE '1982-01-01', :c);
PRINT :c
The output I got from this test was:
EMPNO ENAME HIREDATE
7788 SCOTT 19-APR-87
7876 ADAMS 23-MAY-87
7934 MILLER 23-JAN-82 -
How to use dynamically column_name and column_name value in plsql procedure
hi,
how to use dynamically column_name and column_name value in plsql procedure.
for example, i have one table with column col1.i want write plsql code with dynamically execute the insert one schema to another schema.
by
sivaDECLARE
CURSOR C
IS
SELECT cc_cd
FROM TEMP1 WHERE s_flg ='A' AND b_num IN('826114');--,'709537','715484');
CURSOR D
IS
SELECT * FROM cONSTRAINTS_test ORDER BY SRL_NUM;
STMT VARCHAR2(4000);
p_target_schema VARCHAR2(30):='schema1';
p_source_schema VARCHAR2(30):='schema2';
BEGIN
FOR REC IN C
LOOP
FOR REC1 IN D
LOOP
STMT := 'INSERT INTO '||p_target_schema||''||'.'||''||REC1.CHILD_TABLE||' SELECT * FROM '||p_source_schema||''||'.'||''||REC1.CHILD_TABLE||' where '||REC1.COLUMN_NAME||'='||REC.cntrct_cd||'';
Dbms_Output.Put_Line('THE VALUE STMT:'||STMT);
END LOOP;
END LOOP;
END;
cc_cd='434se22442ss3433';
cc_t_ms is parent table-----------------------pk_cc_cd is primary key
cc_cd is column name
CONSTRAINTS_test table
CHILD_TABLE NOT NULL VARCHAR2(30)
CONSTRAINT_NAME NOT NULL VARCHAR2(30)
COLUMN_NAME NOT NULL VARCHAR2(400)
R_CONSTRAINT_NAME VARCHAR2(30)
CONSTRAINT_TYPE VARCHAR2(1)
PARENT_TABLE NOT NULL VARCHAR2(30)
SRL_NUM NUMBER(4)
CHILD_TABLE CONSTRAINT_NAME COLUMN_NAME R_CONSTRAINT_NAME CONSTRAINT_TYPE PARENT_TABLE SRL_NUM
a aaa cc_CD pk_cc_CD R cc_t_MS 1
bb bbb Cc_CD PK_CC_CD R cc_t_MS 2
bb_v bb_vsr S_NUM PK_S_NUM R bb_v 3
cC_HS_MS cc_hs_CD cc_CD PK_CC_CD R cc_t_MS 4
cC_HS_LNK cc_HIS_LNK_CD H_CD PK_HS_HCD R cC_hs_ms 5
cC_D_EMP cc_d_EMP Cc_CD PK_CC_CD R cc_t_MS 6
i want insert schema1 to schema2 with run time of column_name and column value.the column_name and values should dynamically generated
with refential integrity.is it possible?
can any please quick solution.its urgent
by
siva -
How to call a Asynchronous bpel process from a PLSQL procedure?
How to call a Asynchronous bpel process from a PLSQL procedure?
Hi,
You could do something smart and technical very spiffy with soap-stacks in the database and/or dbms_ws/dbms_http. But I allways find AQ with AQ-adapter the simplest. Let Pl/sql enqueue a message on an aq-queue and subscribe an aq-adapter process on it. That can call your async-bpel process. If you want to get answer back in pl/sql, let the aq-adapter process enqueue a response message on another queue or on the same queue with another consumer name. Give it a correlation-id that you provided in the payload of your request message. Your pl/sql process can then do a dequeue on that correlation-id. It will sit and wait until a message with that correlation id is enqueued on the queue.
Regards,
Martien -
Help Required:How Upload Excel file Into Oracle Table Using PLSQL Procedure
Please Help , Urgent Help Needed.
Requirement is to Upload Excel file Into Oracle Table Using PLSQL Procedure/Package.
Case's are :
1. Excel File is On Users/ Client PC.
2. Application is on Remote Server(Oracle Forms D2k).
3. User Is Using Application Using Terminal Server LogIn.
4. So If User Will Use to GET_FILE_NAME() function of D2K to Get Excel File , D2k Will Try to pick File from That Remote Server(Bcs User Logind from Terminal Server Option).
5. Cannot Use Util_File Package Or Oracle Directory to Place That File on Server.
6. we are Using Oracle 8.7
So Need Some PL/SQL Package or Fuction/ Procedure to Upload Excel file on User's Pc to Oracle Table.
Please Guide me wd some Code. or with Some Pl/SQL Package, or With SOme Hint. Or any Link ....
Jus help to Sort This Issue ........
you can also write me on :
[email protected], [email protected]TEXT_IO is a PL/SQL package available only in Forms (you'll want to post in the Forms forum for more information). It is not available in a stored procedure in the database (where the equivalent package is UTL_FILE).
If the Terminal Server machine and the database machine do not have access to the file system on the client machine, no application running on either machine will have access to the file. Barring exceptional setups (like the FTP server on the client machine), your applications are not going to have more access to the client machine than the operating system does.
If you map the client drives from the Terminal Server box, there is the potential for your Forms application to access those files. If you want the files to be accessible to a stored procedure in the database, you'll need to move the files somewhere the database can access them.
Justin -
How to trace the flow of plsql procedures/functions in oracle 10g
Hi All,
Recently I came to know that there is dbms_hprof PL/SQL built-in package in Oracle 11g which can be used to trace PL/SQL calls in a Hierarchical way. (acts as a PL/SQL Hierarchical Profiler).
Steps are given in -
http://www.oracle-base.com/articles/11g/PlsqlHierarchicalProfiler_11gR1.php
I would like to know whether there is a similar package in Oracle 10g because I want to trace the flow of plsql procedure and function calls in order to generate an output in a hierarchical way (for debug purposes).
The following example shows the flow of procedure calls when I execute PACKAGE_A.Proceudure_A. I want to generate that kind of an output.
Ex -
PACKAGE_A.Proceudure_A
----|_PACKAGE_A.Proceudure_B
----|------|_PACKAGE_B.Proceudure_C
----|_PACKAGE_B.Proceudure_M
----|------|_PACKAGE_A.Proceudure_B
----|-------------|_PACKAGE_C.Proceudure_C
----|_PACKAGE_Z.Proceudure_Z
If there is no similar package in *10g* I would really appreciate if someone can provide me directions to get the job done using the exsting packages and tables in Oracle 10g. Thanks in advance.
Edited by: user8326781 on Nov 28, 2008 8:57 PM
Edited by: user8326781 on Nov 28, 2008 8:58 PM
Edited by: user8326781 on Nov 29, 2008 12:19 AMI am not sure that this would serve the purpose or not but still, I guess its worth to atleast be mentioned,
http://www.oracle-base.com/articles/9i/DBMS_TRACE.php
HTH
Aman.... -
How to trace plsql procedures call stack in EBS?
Hi experts,
I'm an newbie EBS user. EBS itself provides excellent trace function, which tells us sql scripts executed and corresponding cost information.
This is quite useful for EBS performance tuning, but not for debugging. At many times, i need to know which PLSQL procedures are called and
the complete stack after i do some operation on the EBS GUI. But no solution comes to me.
Appreciate your help, thanks in advance.
TedCraigB wrote:
This forum is for general Oracle Forms questions. Please post your question in the General EBS Discussion forum. If you have a general Forms question, by all means, ask it here! ;-)
Craig...Hi Craig, already transferred, thanks for your reminder. -
How to convert sql server procedure in to plsql procedure
hi guys
i have requirement where in i have to convert sql server procedure into plsql procedure.
can some one help me out .
thanks,
Vamshi.DHi Vamshi,
As you want to convert sql server procedure in to plsql procedure
i.e SQL SERVER ->ORACLE Right
FYI
SQL SERVER Proc. Syntax are totally different as compared to ORACLE Proc.
So, better you study Logic of SQL-SERVER Proc and convert into
Oracle Procedure.
Thanks,
Samadhan -
Business Event not triggering the PLSQL procedure.. What to do?
We need to call a plsql procedure when the GL Approval workflow has ended with approval. I thought i could do this by customizing the relevant business event.
We are on EBS 12.1.3 with RDBMS : 11.2.0.3.0.
I saw that the business event oracle.apps.gl.Journals.journal.approve was disabled currently. I enabled it and created a subscription for it. Subscription was a PLSQL procedure. Currently, for test purpose only thing it is doing is to insert a row into a table.
Business Event Subscription settings:
System: ORDEBS.SYSTEM.COM
Triggering Event
Source Type:Local
Event Filter: oracle.apps.gl.Journals.journal.approve
Execution Condition
Phase: 100
Status: Enabled
Rule Data: Message
Action Type:Custom
On Error: Stop and Rollback
Action
PL/SQL Rule Function: XX_GL_APPROVE_BE_PKG.Get_Attributes
Priority: Normal
Documentation (Not sure what value to be given for these. I went with the below values.)
Owner: Company Name
Owner Tag: Custom Schema
Using the below query i can see that the business event is getting called when the approval happens (One row added each time approval happened). But I cant see any rows in the table where it should insert a row. What could be going wrong? How can i verify that the procedure has been called?
select * from WF_DEFERRED where corrid ='APPS:oracle.apps.gl.Journals.journal.approve'
Procedure:
CREATE OR REPLACE PACKAGE BODY APPS.XX_GL_APPROVE_BE_PKG
AS
PROCEDURE Get_Attributes
IS
BEGIN
INSERT INTO xx.xx_test_table VALUES ('From BE');
COMMIT;
END Get_Attributes;
END XX_GL_APPROVE_BE_PKG;Thanks Alejandro. Now this is working.
Changes i made:
1. Added the WFERROR workflow as a subscription to this event. So i could see that the function i am calling from the event did not have proper signature.
2. Changed the function signature to have standard parameters like:
CREATE OR REPLACE PACKAGE BODY XX_GL_APPROVE_BE_PKG
AS
function subscription(p_subscription_guid in raw,
p_event in out nocopy wf_event_t) return varchar2 is
l_result varchar2(20);
begin
insert into xxvtv.xxvtv_test_table values ('From BE');
commit;
exception
when others then
wf_core.context('XX_GL_APPROVE_BE_PKG','function subscription', p_event.getEventName(), p_event.getEventKey());
wf_event.setErrorInfo(p_event, 'ERROR');
return 'ERROR';
end subscription;
END XX_GL_APPROVE_BE_PKG;
3. Changed the owner name and owner tag both to the custom schema name (XX)
Maybe you are looking for
-
Where are the Files uploaded to KM stored, in database or some location
Hi All, Say for example we have created a pdf file and uploaded this to KM Folder in the portal server. How and where this files stored in the server. Whether they are stored as objects in the database or in any location of the hard disk as a file sy
-
When I click on either the printer icon or file-Print I getAdobe Reader has stopped working. The error in the event log is: Faulting application AcroRd32.exe, version 10.0.0.396, time stamp 0x4cc5e97b, faulting module ntdll.dll, version 6.0.6002.1800
-
Dear expert, what are different reports in SAP-QM related to results recording, defects entry based on lot no because we are creating lot no. manually & results recording , defects entry & ud done through QA32. i want report lot no. wise. thanx vimle
-
Operating system from Windows 8 to Windows 7
I recently switched opreating system from Windows 8 to Windows 7. I have no driver loaded for SM Bus Controller. How can I locate this to load the driver?
-
Apple TV status light blinking white
My apple TV status light is blinking white and the TV gets no signal. I have re-booted the apple tv and it gives me the sign to plug it into iTunes. I cannot do that as it has no USB connection so I am bit lost. I also have no idea how to tell whi