Dbms_out.put_line??
Is there a setting that nned to on or off for this (dbms_output.put_line) to work? I cannot seem to get to work.
In SQL*Plus, it's SET SERVEROUTPUT ON or your code can run fine but you won't see it on screen.
Similar Messages
-
Execute procedure on oracle apex online
Hi All
CREATE OR REPLACE PROCEDURE TEST_PROC
AS
V_FNAME EMPLOYEES.FIRST_NAME%TYPE;
BEGIN
SELECT FIRST_NAME INTO V_FNAME FROM EMPLOYEES
WHERE FIRST_NAME = 'JOHN';
DBMS_OUT.PUT_LINE(V_FNAME);
END;
I have made this procedure on sql worksheet of http://apex.oracle.com/ on my account.
when i gave EXECUTE TEST_PROC; and CALL TEST_PROC; command to exeute this procedure I'm getting following error ORA-00900: invalid SQL statement.
please tell how can i run this procedure.
thanks in advance.
regards
NeerajSome basic concepts first. Apex is a suite of PL/SQL procedures and functions and packages and database tables. Apex runs totally inside the database as stored procedural code.
What makes it unique and different is that the procedures are called by a web browser URL. This is received by Apache and passed to a module called mod_psql. This module processes the URL from the web browser, determines what database to connect to and what stored procedure call to make.
Inside the PL/SQL environment there is a set of web packages - and a buffer area that can be used to create dynamic web pages. Apex PL/SQL code executes and creates a dynamic web page/web content in this buffer. The code terminates.
The mod_plsql module in Apache then reads this buffer from the Oracle session and it streams the content to the web browser.
DBMS_OUTPUT is not specifically supported by mod_plsql as it is another buffer area (quite primitive in use and interface). It supports a basic console output display for PL/SQL code - and is typically use by session-based clients like TOAD, SQL*Plus and SQL-Developer.
So if you want a web-enabled PL/SQL procedure to display data on the web browser, your code needs to write to the web buffer in PL/SQL and not the DBMS_OUTPUT buffer. Writing to the web buffer can be done using the HTP.prn() call.
Here's a very basic example of outputting data to a web browser using custom PL/SQL code. Create a Apex page. On this page create a text item called something like P1_FIRSTNAME. This enables the web user to supply a parameter value to your PL/SQL procedure.
Create a dynamic PL/SQL region on the page, that calls your procedure:
begin
--// if the user supplied a firstname, we call the procedure to process the data
if :P1_FIRSTNAME is not null then
MyTestProc( firstName => :P1_FIRSTNAME );
end if;
end;The user procedure that receives and processes the data, and supplied web output, will look something like the following:
create or replace procedure MyTestProc( firstName varchar2 ) is
cnt integer;
begin
htp.prn( 'You have entered the search criteria: '||firstName||'<br> ');
select count(*) into cnt from emp where first_name like firstName;
htp.prn( 'Number of matching employees: '||to_char(cnt)||' row(s)<br> ');
end; -
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. -
In which Oracle version is that possibile?
I've tried to create these procedure that I've found.
CREATE OR REPLACE PROCEDURE genlookup (tab IN VARCHAR2, col IN VARCHAR2)
IS
BEGIN
pl ('CREATE OR REPLACE FUNCTION ' || l_ltab || '_row_for (');
pl (' ' || l_lcol || '_in IN ' || l_ltab || '.' || l_lcol || '%TYPE)');
pl ('/');
END;
but I get a compilation error:
PLS-00201: identifier 'PL' must be declared
In which version is the PL istruction available?
I've got Oracle 8i.
My target is to write a procedure that having in Input N tables is able to autogenerate coding of a "select from where" putting in join the N tables by using ALL_DEPENDENCIES table so as to create queries automatically.
The site where I've found the above create procedure, let see that by giving after comlipation "exec genlookup" you get the CREATE OR REPLACE FUNCTION well formed, but as in my case 'pl' istrucion doesn't work, should I create one row of code a time and put it in a varrray and make dbms_out.put_line reporting the whole select or you have any smart way to do it?
Thanks!PL (Feuerstein) en P (Kyte) procedures are usually wrappers around dbms_output, in order to save you from typing dbms_output.put_line constantly.
See:
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1288401763279 for an example of P. Just copy ity and call it PL instead of P -
Complicated PL/SQL questions that involves function with in type parameter
Hello,
I have a question about functions with in-parameters. In the HR schema, I need to get the minimum salary of the job_id that is mentioned as an in-parameter.
this is what I am thinking but I dont know if it's correct or not or what should I do next!
create or replace function get_min_salary (i_job_id in varchar2)
return number
as
min_sal jobs.min_salary%type;
begin
SELECT min_salary INTO min_sal
FROM jobs
where job_id = i_job_id;
RETURN min_sal;
end get_min_salary;if the i_job_id which is the in type parameter does not have a minimum salary then use the following function to register an error:
create or replace procedure insert_error (i_error_code in number,
i_error_message in varchar2)
as
begin
insert into error_table (error_user, error_date, error_code, error_message)
values (user,sysdate,i_error_code,i_error_message);
end insert_error;This function is basically to say that an error has occured and to register that error, at the same time I need to print out the error using the dbms_out.put_line.
Any ideas of how to do that?
Thanks in advance>
minimum salary of the job_id
>
may be
SELECT min(min_salary) INTO min_sal
FROM jobs
where job_id = i_job_id;
if the i_job_id which is the in type parameter does not have a minimum salary then use the following function to register an error:why error?
This function is basically to say that an error has occured and to register that error, at the same time I need to print out the error using the dbms_out.put_line.
create or replace procedure insert_error (i_error_code in number,
i_error_message in varchar2)
as
begin
insert into error_table (error_user, error_date, error_code, error_message)
values (user,sysdate,i_error_code,i_error_message);
-- this
dbms_out.put_line('this');
end insert_error; -
Question about function with in parameters
Hello,
I have a question about functions with in-parameters. In the HR schema, I need to get the minimum salary of the job_id that is mentioned as an in-parameter.
this is what I am thinking but I dont know if it's correct or not or what should I do next!
create or replace function get_minimum_salary (i_job_id in varchar2)
return number
as
begin
SELECT min_salary INTO min_sal
FROM jobs
where job_id = get_minimum_salary(xy);
RETURN i_job_id;
end get_minimum_salary;
thanks in advance
EDIT
Thanks for your help all.
Is it possible to add that if the i_job_id which is the in type parameter does not have a minimum salary then use the following function to register an error:
create or replace procedure insert_error (i_error_code in number,
i_error_message in varchar2)
as
begin
insert into error_table (error_user, error_date, error_code, error_message)
values (user,sysdate,i_error_code,i_error_message);
end insert_error;
This function is basically to say that an error has occured and to register that error, at the same time I need to print out the error using the dbms_out.put_line.
Any ideas of how to do that?
Thanks again
Edited by: Latvian83 on Jun 1, 2011 5:14 AMHI
I have made little bit changes in ur code. try this
create or replace function get_minimum_salary (i_job_id in varchar2)
return number
as
v_Min_sal jobs.salary%type=0;---- Variable declaration
begin
SELECT min_salary INTO v_ min_sal
FROM jobs
where job_id = i_job_id;
RETURN v_Min_sal;
end get_minimum_salary;
Regards
Srikkanth.M -
How to see the datas stored in DBMS_SQL.Varchar2S variable?
how to see the datas stored in DBMS_SQL.Varchar2S variable?
it says error if i use dbms_out.put_line.in PLSQL :
procedure p_try (p_test IN OUT DBMS_SQL.VARCHAR2S) is
begin
p_test.delete ;
p_test( -3000) := '===============' ;
p_test( 22) := 'Hello' ;
p_test( 55555) := 'World' ;
p_test(987654321) := '===============' ;
end p_try;
set serveroutput on
declare
l_test dbms_sql.varchar2s ;
i number ;
begin
p_try (l_test) ;
i := l_test.first ;
while i >= l_test.first and i <= l_test.last loop
dbms_output.put_line (l_test(i)) ;
i := l_test.next(i) ;
end loop ;
end ;
===============
Hello
World
===============when using Forms, you would use TEXT_IO instead of DBMS_OUTPUT -
Accessing database package variables from Forms
I have a database package that populates a table of values, i.e.
type t_route_list is table of rt_route.RTR_ID%type;
route_list t_route_list
route_list gets populated by a package function and I want to access route_list in the Form.
While I can access other package variables by writing a function that returns the variable, Forms doesnt seem to like functions that return a user defined datatype as above. I have also tried using a procedure with an OUT param instead of a function but it also fails with same error.
i.e.
declare
v_route_list pkg_bulk_route_replace.t_route_list;
begin
pkg_bulk_route_replace.init;
pkg_bulk_route_replace.get_route_list(v_route_list);
message(v_route_list(1));
end;
This will not compile, but removing the index (1) from the last line makes it compile but crash with ORA-0600.
The code above with message replaced with dbms_out.put_line works fine on TOAD.
So my question is......
Can my database package return a plsql table to a form and if so, how?!Actually I've got this to work now!
Thde main culprit appears to be a difference in the version of sql or pl/sql used on forms (version 5) and the database (8.1.7).
I had defined my table as a nested table. By redefining this as a indexed table, simply by adding on 'index by binary_integer' on my server package, I am suddenly able to access the elements of the table on my form. Fortunately this did not break the server code either - the table was populated using bulk collect and that still works.
Still got a bit of coding to do, but things are looking up now. -
Dbms_output package on oracle apex
Hi
CREATE OR REPLACE PROCEDURE TEST_PROC
AS
V_FNAME EMPLOYEES.FIRST_NAME%TYPE;
BEGIN
SELECT FIRST_NAME INTO V_FNAME FROM EMPLOYEES
WHERE FIRST_NAME = 'JOHN';
DBMS_OUT.PUT_LINE(V_FNAME);
END;
begin
TEST_PROC;
end;
when we execute procedure like this how to get the output on result screen using DBMS_OUT.PUT_LINE(V_FNAME); sql worksheet of http://apex.oracle.com/ on my account
because set serveroutput on is not working here.
thanksYou don't use DBMS_OUTPUT in apex.
It has ways you can output html within the screen content if you really want (a google search would show you how), though Apex comes with a debug option so you can see what values things have without having to code your own.
Edit: Oh, and p.s. this is the SQL and PL/SQL forum, not the Application Express forum which is here: Oracle Application Express (APEX)
Edited by: BluShadow on 04-Nov-2011 11:05 -
DBMS_OUTPUT in Pro* C
Can anyone suggest way of getting output of a dbms_out.put_line statement used inside a stored procedure called from a Pro*c program.
I want that output to be available inside proc*c program.
Thanks.DBMS_OUTPUT.GET_LINE/DBMS_OUTPUT.GET_LINES
SY. -
Procedure help (urgent)
i AM NEW TO ORACLE
I created this procedure
PROCEDURE P_SUPLR IS
SUPPLIER VARCHAR2(2000);
cursor c1 is SELECT DISTINCT(M.SPLR)supplier FROM DM_MARKETING M
WHERE M.SPLR IN ('ZEG','ZUS','USK');
BEGIN
for rec in c1 loop
supplier := rec.supplier;
end loop;
Dbms_out.put_line(supplier);
END;
But the output is getting only 'ZUS'
BUT I NEED TO GET OUTPUT FOR SUPPLIER IS
'ZEG',ZUS','USK'
CAN ANYBODY MODIFY THE CODE AND HELP ME PLEASE
ITS URGENT
Thanks in advanceYou just need to change the dbms_output.put_line position so that it is inside the loop. If you have a large number of values to display on screen, it may be worth doing SET SERVEROUTPUT ON SIZE 500000 in SQLPLUS before you execute the procedure....
PROCEDURE P_SUPLR IS
SUPPLIER VARCHAR2(2000);
cursor c1 is SELECT DISTINCT(M.SPLR)supplier FROM DM_MARKETING M
WHERE M.SPLR IN ('ZEG','ZUS','USK');
BEGIN
for rec in c1 loop
supplier := rec.supplier;
Dbms_output.put_line(supplier);
end loop;
END;HTH
David -
Returning the control out of the procedure
Gurus,
Please see my code
BEGIN
BEGIN -- To check whether the user(Record) exists in the table
SELECT a.code, a.code_desc
INTO L_code, L_code_desc
FROM CODE_DETAIL a, USER_ROLE_PRIVS b
WHERE a.code_desc = b.granted_role
AND a.code_type like '%CATR%'
AND b.username = I_U_ID;
EXCEPTION
WHEN NO_DATA_FOUND THEN
O_ERR_MSG := 'N';
END;
IF L_CODE <> '1' AND L_CODE <> '2' AND L_CODE <> '3' THEN -- To check whether there is any other role associated other than 1, 2 or 3
O_ERR_MSG := 'Y';
END IF;This is a piece of code which is a part of procedure .. Now whenever I have O_ERR_MSG initialized to Y or N .. it should come out of the procedure... What's happenning now is, variable is getting initialized and executing the rest of the code, which shouldnt happen ..
Can you please tell me how to pass the control back to the procedure without executing the other lines ?
RegardsOk... posting the entire code
CREATE OR REPLACE PROCEDURE AFE_CHECK_SUBMIT (I_u_id in varchar2, I_ord_num in number, O_rol out VARCHAR2, O_app_check OUT Varchar2, O_v_app_check out number, O_v_otb_check out number, O_AMT OUT NUMBER, O_ERR_MSG OUT VARCHAR2, O_error_message IN OUT varchar2 ) IS
L_role varchar2(30);
L_approval_limit number; L_otb_limit number;
L_approval_level varchar2(5);
L_tolerance_limit varchar2(40); L_program VARCHAR2(60) := 'AFE_CHECK_SUBMIT';
L_code VARCHAR2(10);
L_code_desc VARCHAR2(30);
L_app_check NUMBER;
L_otb_check NUMBER;
L_amt NUMBER;
L_otb_amt1 NUMBER;
L_order_no NUMBER;
L_status VARCHAR2(1);
CURSOR C_PO_AMT IS SELECT i.dept, i.class, h.order_type, to_CHAR(h.otb_eow_date, 'MONYYYY') po_month, sum(o.qty_ordered * o.unit_cost) po_amt
FROM ITEM_MASTER i, ORDLOC o, ORDHEAD h
WHERE i.item = o.item
AND o.order_no = h.order_no
AND o.order_no = I_ord_num
GROUP BY i.dept, i.class, h.order_type, to_CHAR(h.otb_eow_date, 'MONYYYY');
CURSOR C_OTB_CALCULATE(order_type VARCHAR2, order_eow_date date, dep number, clas number ) IS
SELECT sum(decode(order_type, 'ARB', a_budget_amt-a_approved_amt,
'BRB', b_budget_amt-b_approved_amt,
'N/B', n_budget_amt-n_approved_amt,
0)) otb_amt1
FROM OTB
WHERE to_char(EOW_DATE,'MONYYYY') = to_char(order_eow_date,'MONYYYY')
AND DEPT = dep
AND CLASS = clas
GROUP BY to_CHAR(ORDER_EOW_DATE,'MONYYYY'),DEPT,CLASS;
C2 C_OTB_CALCULATE%rowtype;
c3 C_PO_AMT%rowtype;
CURSOR C_ROLE_CHECK IS
SELECT a.code, a.code_desc -- checking the role of the user who has logged in
FROM CODE_DETAIL a, USER_ROLE_PRIVS b
WHERE a.code_desc = b.granted_role
AND a.code_type like '%CATR%'
AND b.username = I_U_ID;
L_ROLE_CHECK C_ROLE_CHECK%ROWTYPE;
BEGIN
dbms_output.put_line('User id is :' || I_u_id);
dbms_output.put_line('Selecting the role');
BEGIN
OPEN C_ROLE_CHECK;
LOOP
FETCH C_ROLE_CHECK INTO L_ROLE_CHECK;
EXIT WHEN C_ROLE_CHECK%NOTFOUND;
L_code := L_ROLE_CHECK.code;
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND THEN
dbms_output.put_line('No Record in table');
O_ERR_MSG := 'N';
END;
dbms_output.put_line('Role is :' || L_code);
IF L_CODE <> '1' OR L_CODE <> '2' OR L_CODE <> '3' THEN
O_ERR_MSG := 'Y';
dbms_output.put_line('Unidentified user');
END IF;
IF L_code = '1' THEN -- If user id is planner
O_rol := '1';
dbms_output.put_line('User is PLANNER (ROLE 1)');
SELECT r.ORD_APPR_AMT -- will be checking the approval limit of that role
INTO L_approval_limit
FROM RTK_ROLE_PRIVS r, CODE_DETAIL c
WHERE r.ROLE = c.CODE_DESC
AND c.CODE = L_code;
dbms_output.put_line('Approval limit is :' || L_approval_limit);
OPEN C_PO_AMT; -- OTB check based on dept,class
LOOP
FETCH C_PO_AMT into c3;
EXIT when c_PO_AMT%notfound;
dbms_output.put_line('Entered 1st loop');
OPEN C_OTB_CALCULATE(c3.order_type, TO_DATE(c3.po_month,'MONYYYY'), c3.dept, c3.class);
LOOP
dbms_output.put_line('Entered 2nd loop');
FETCH C_OTB_CALCULATE into c2;
EXIT WHEN C_OTB_CALCULATE%notfound;
L_amt := c3.PO_AMT;
dbms_output.put_line('PO AMT IS:' || L_amt);
IF c3.PO_AMT > L_approval_limit THEN -- Checking whether amount greater than approval lim
dbms_output.put_line('Approval limit exceeded');
L_app_check := 1;
O_app_check := 'T';
O_v_app_check := 1;
O_amt := L_amt;
dbms_output.put_line('Approval check is:' || L_app_check);
dbms_output.put_line('Approval check exceeded? :' || O_app_check);
dbms_output.put_line('Parameter for Approval check is:' || O_v_app_check);
ELSIF C3.PO_AMT <= L_approval_limit then
dbms_output.put_line('Approval limit not exceeded');
dbms_output.put_line('Approval check is:' || L_app_check);
dbms_output.put_line('Parameter for Approval check is:' || O_v_app_check);
L_app_check := 0;
O_v_app_check := 0;
END IF;
IF c3.PO_AMT > c2.OTB_AMT1 THEN -- Checking whether amount greater than OTB amount
dbms_output.put_line('OTB AMT is :' || c2.otb_amt1);
dbms_output.put_line('OTB limit Exceeded');
L_otb_check := 1;
O_app_check := 'T';
O_v_otb_check := 1;
O_amt := L_amt;
dbms_output.put_line('OTB check is:' || L_otb_check);
dbms_output.put_line('OTB check exceeded? :' || O_app_check);
dbms_output.put_line('Parameter for OTB check is:' || O_v_otb_check);
ELSIF C3.PO_AMT <= C2.OTB_AMT1 THEN
dbms_output.put_line('OTB limit not exceeded');
L_otb_check := 0;
O_v_otb_check := 0;
dbms_output.put_line('OTB check is:' || L_otb_check);
dbms_output.put_line('Parameter for OTB check is:' || O_v_otb_check);
END IF;
END LOOP;
CLOSE C_OTB_CALCULATE;
END LOOP;
CLOSE c_PO_AMT;
IF L_app_check = 0 and L_otb_check = 0 then
SELECT ORDER_NO, STATUS -- Checking whether there is a duplicate order number
INTO L_order_no, L_status
FROM AFE_POAPPROVAL
WHERE ORDER_NO = I_ord_num;
IF L_status = 'O' then -- If found and its stauts is open, update the record by changing the status column to "C"
UPDATE AFE_POAPPROVAL
SET STATUS = 'C'
WHERE ORDER_NO = I_ord_num;
COMMIT;
END IF;
INSERT INTO AFE_POAPPROVAL -- Inserting the record into AFE_POAPPROVAL when OTB and approval limit is below the PO amt
VALUES (I_ord_num, 1,'O',I_u_id,'ROLE1','N','N', SYSDATE,'S', L_amt);
dbms_output.put_line('Inserted Record into AFE_POAPPROVAL');
COMMIT;
END IF;
ELSIF L_code = '2' THEN -- If user id is category manager
dbms_output.put_line('User is Category manager (ROLE 2)');
O_rol := '2';
SELECT r.ORD_APPR_AMT -- will be checking the approval limit of that role
INTO L_approval_limit
FROM RTK_ROLE_PRIVS r, CODE_DETAIL c
WHERE r.role = c.CODE_DESC
AND c.CODE = L_code;
dbms_output.put_line('Approval limit is :' || L_approval_limit);
OPEN c_PO_AMT; -- OTB check based on dept,class
LOOP
FETCH c_PO_AMT into c3;
EXIT when c_PO_AMT%notfound;
dbms_output.put_line('Entered 1st loop');
OPEN C_otb_CALCULATE(c3.order_type, TO_DATE(c3.po_month,'MONYYYY'), c3.dept, c3.class);
LOOP
FETCH C_OTB_CALCULATE into c2;
EXIT WHEN C_OTB_CALCULATE%notfound;
dbms_output.put_line('Entered 2nd loop');
L_amt := c3.PO_AMT;
dbms_output.put_line('PO AMT is:' || L_amt);
IF c3.PO_AMT > L_approval_limit THEN -- Checking whether amount greater than approval limit
dbms_output.put_line('Approval limit exceeded');
L_app_check := 1;
O_app_check := 'T';
O_v_app_check := 1;
O_amt := L_amt;
dbms_output.put_line('Approval check is:' || L_app_check);
dbms_output.put_line('Approval check exceeded? :' || O_app_check);
dbms_output.put_line('Parameter for Approval check is:' || O_v_app_check);
ELSE
dbms_output.put_line('Approval limit not exceeded');
L_app_check := 0;
O_v_app_check := 0;
dbms_output.put_line('Approval check is:' || L_app_check);
dbms_output.put_line('Parameter for Approval check is:' || O_v_app_check);
END IF;
L_otb_amt1 := c2.OTB_AMT1;
dbms_output.put_line('Selecting tolerance limit');
SELECT cd.code_desc -- will be chekcing the tolerance limit
INTO L_tolerance_limit
FROM CODE_DETAIL cd, CODE_HEAD ch
WHERE ch.CODE_TYPE = cd.code_type
AND ch.CODE_TYPE = 'OTBT';
L_tolerance_limit := to_number(L_tolerance_limit);
dbms_output.put_line('Tolerance limit is:' || L_tolerance_limit);
L_otb_limit := c2.OTB_AMT1-(c2.OTB_AMT1 * (1- (L_tolerance_limit/100))); -- Will be calculating the tolerance limit
dbms_output.put_line('OTB AMT is :' || L_otb_amt);
IF c3.PO_AMT > L_otb_limit THEN -- Checking whether amount greater than OTB amount
dbms_output.put_line('OTB limit exceeded');
L_otb_check := 1;
O_app_check := 'T';
O_v_otb_check := 1;
O_amt := L_amt;
dbms_output.put_line('OTB check is:' || L_otb_check);
dbms_output.put_line('OTB check exceeded? :' || O_app_check);
dbms_output.put_line('Parameter for OTB check is:' || O_v_otb_check);
ELSE
dbms_out.put_line('OTB Limit not exceeded');
L_otb_check := 0;
O_v_otb_check := 0;
dbms_output.put_line('OTB check is:' || L_otb_check);
dbms_output.put_line('Parameter for OTB check is:' || O_v_otb_check);
END IF;
END LOOP;
CLOSE C_OTB_CALCULATE;
END LOOP;
CLOSE c_PO_AMT;
IF L_app_check = 0 and L_otb_check = 0 THEN
SELECT ORDER_NO, STATUS -- Checking whether there is a duplicate order number
INTO L_order_no, L_status
FROM AFE_POAPPROVAL
WHERE ORDER_NO = I_ord_num;
IF L_status = 'O' then -- If found and its stauts is open, update the record by changing the status column to C
UPDATE AFE_POAPPROVAL
SET STATUS = 'C'
WHERE ORDER_NO = I_ord_num;
COMMIT;
END IF;
INSERT INTO AFE_POAPPROVAL -- Inserting the record into AFE_POAPPROVAL when OTB and approval limit is below the PO amt
VALUES (I_ord_num, 1,'O',I_u_id,'ROLE2','N','N', SYSDATE, 'S', L_amt);
COMMIT;
dbms_output.put_line('Inserted Record into AFE_POAPPROVAL');
END IF;
ELSIF L_code = '3' THEN -- If user id is category head
dbms_output.put_line('User is Category Head (ROLE3)');
O_rol := 3;
OPEN c_PO_AMT; -- OTB check based on dept,class
LOOP
FETCH c_PO_AMT into c3;
EXIT when c_PO_AMT%notfound;
dbms_output.put_line('Entered 1st loop');
OPEN C_OTB_CALCULATE(c3.order_type, to_date(c3.po_month,'MONYYYY'), c3.dept, c3.class);
LOOP
FETCH C_OTB_CALCULATE into c2;
EXIT WHEN C_OTB_CALCULATE%notfound;
dbms_output.put_line('Entered 2nd loop');
L_amt := c3.PO_AMT;
dbms_output.put_line('PO AMT is :' || L_amt);
IF c3.PO_AMT > c2.OTB_AMT1 THEN -- Checking whether amount greater than OTB amount
dbms_output.put_line('OTB AMT is :' || c2.otb_amt1);
dbms_output.put_line('OTB Limit exceeded');
L_otb_check := 1;
O_app_check := 'T';
O_v_otb_check := 1;
O_amt := L_amt;
dbms_output.put_line('OTB check is:' || L_otb_check);
dbms_output.put_line('OTB check exceeded? :' || O_otb_check);
dbms_output.put_line('Parameter for OTB check is:' || O_v_otb_check);
ELSE
dbms_output.put_line('OTB limit not exceeded');
L_otb_check := 0;
O_v_otb_check := 0;
dbms_output.put_line('OTB check is:' || L_otb_check);
dbms_output.put_line('Parameter for OTB check is:' || O_v_otb_check);
END IF;
END LOOP;
CLOSE C_OTB_CALCULATE;
END LOOP;
CLOSE c_PO_AMT;
IF L_otb_check = 0 THEN
IF L_otb_check = 0 THEN
OPEN C_RECORD_CHECK;
LOOP
FETCH C_RECORD_CHECK INTO L_RECORD_CHECK;
EXIT WHEN C_RECORD_CHECK%notfound;
IF C_RECORD_CHECK%FOUND THEN
UPDATE AFE_POAPPROVAL
SET STATUS = 'C'
WHERE ORDER_NO = I_ord_num;
COMMIT;
END IF;
END LOOP;
INSERT INTO AFE_POAPPROVAL -- Inserting the record into AFE_POAPPROVAL when otb and approval limit is below the po amount
VALUES (I_ord_num, 1,'O',I_u_id,'ROLE3','Y','N', SYSDATE,'S', L_amt);
COMMIT;
dbms_output.put_line('Inserted Record into AFE_POAPPROVAL');
END IF;
END IF;
EXCEPTION
WHEN OTHERS THEN
O_error_message := SQL_LIB.CREATE_MSG('PACKAGE_ERROR',
SQLERRM,
L_program,
TO_CHAR(SQLCODE));
END AFE_CHECK_SUBMIT;
/Now i am executing the procedure ...
SQL>SQL> @OUT_SUBMIT;
Enter value for user: RMS12DEV
old 12: o_user :='&user';
new 12: o_user :='RMS12DEV';
Enter value for order: 6139
old 13: o_order :=ℴ
new 13: o_order :=6139;
User id is :RMS12DEV
Selecting the role
No Record in table
Role is :
o_rol:
O_app_check:
O_v_app_check:
O_v_otb_check:
O_amt:
O_ERR_MSG: N
O_error_message:
PL/SQL procedure successfully completed.
If you have looked at the output .. after the variable is intialized to 'N', still I am getting msgs displayed .. Hope this is clear .. Now can you suggest the solution...
Regards
Message was edited by:
Seshu
Message was edited by:
Seshu -
Hello
I will explain the scenario:
In our java web page, we are using three text boxes to enter "Part number,Description and Aircraft type". Every time the user no need to enter all these data. The person can enter any combination of data or only one text box. Actually the output data corresponding to this input entries is from five Oracle table. If we are using a single query to take data from all the five tables, the database will hang. So I written a procedure "SEARCH1",this will accept any combination of values (for empty values we need to pass NULL to this procedure) and output data from all the five tables. When I executing this procedure in SQL editor, the execution is very fast and giving exact result. I used "dbms_output.put_line" clause for outputing multiple records in my procedure. The output variables are "Serial No, part Number, Description, Aircraft type,Part No1,Part No2,Part No3,Part No4". I want to use the same procedure "SEARCH1" for outputing data in java web page.The passing argument I can take from the text box provided in java web page. I am using jdbc thin driver to connect our java web page to Oracle 9i database.
Note1 : If any combination of search item not available, in procedure itself I am outputing a message like "Part Number not found". Here I am using four words ("Part" is the first word,"Number" is the second,"Not" s the third, and "found" is the fourth) for outputing this message.Is it necessary to equalise number of words I am using here to the record outputing eight variable?
Our current development work is stopped because of this issue. So any one familier in this field,plese help me to solve our issue by giving the sample code for the same scenario.
My Email-id is : [email protected]
I will expect yor early mail.
With thanks
Pramod kumar.Hello Avi,
I am trying to solve this issue by using objects. But the following part of code also throwing some warning like "PLS-00302: component must be declared". Plese cross check my code and help me to solve this issue.
drop type rectab;
create or replace type rectype as object(PartNo varchar2(30),Description varchar2(150),AIrcraft_type varchar2(15),status_IPC varchar2(30),status_ELOG varchar2(30),status_SUPCAT varchar2(30),status_AIRODWH varchar2(30));
create or replace type rectab as table of rectype;
create or replace package ioStructArray as
procedure testsch2(pno in varchar2,pdes in varchar2,air in varchar2,orec in out rectab);
end ioStructArray;
create or replace package body ioStructArray as
procedure testsch2(pno in varchar2,pdes in varchar2,air in varchar2,orec in out rectab) is
mdescription varchar2(150);
mpartnum varchar2(30);
mpno varchar2(30);
mdes varchar2(150);
mair varchar2(15);
mstat varchar2(1);
cursor c1 is select partnum,description,aircraft_type from master_catalog where partnum=mpno and aircraft_type=mair and description like ltrim(rtrim(mdes))||'%';
cursor c2 is select partnum from ipc_master where partnum=mpartnum;
cursor c3 is select partnum from fedlog_data where partnum=mpartnum;
cursor c4 is select partnum from superparts where partnum=mpartnum;
cursor c5 is select part_no from supplier_catalog where part_no=mpartnum;
mpno1 varchar2(30);
mpno2 varchar2(30);
mpno3 varchar2(30);
mpno4 varchar2(30);
mpno5 varchar2(30);
maircraft_type varchar2(15);
mstat1 varchar2(30);
mstat2 varchar2(30);
mstat3 varchar2(30);
mstat4 varchar2(30);
begin
mstat:='N';
mpno:=pno;
mdes:=pdes;
mair:=air;
if mpno is not null and mdes is not null and mair is not null then
begin
mstat:='N';
mpno:=pno;
mdes:=pdes;
mair:=air;
for i in c1 loop
mstat:='N';
mstat1:='N';
mstat2:='N';
mstat3:='N';
mstat4:='N';
mpno1:=i.partnum;
mpartnum:=i.partnum;
mdescription:=i.description;
maircraft_type:=i.aircraft_type;
for j in c2 loop
mpno2:=j.partnum;
end loop;
for k in c3 loop
mpno3:=k.partnum;
end loop;
for l in c4 loop
mpno4:=l.partnum;
end loop;
for m in c5 loop
mpno5:=m.part_no;
end loop;
if mpno2=mpartnum then
mstat1:=mpno2;
end if;
if mpno3=mpartnum then
mstat2:=mpno3;
end if;
if mpno4=mpartnum then
mstat3:=mpno4;
end if;
if mpno5=mpartnum then
mstat4:=mpno5;
end if;
if mpno1=mpartnum then
mstat:='Y';
orec.PartNo:=mpno1;
orec.Description:=mdescription;
orec.AIrcraft_type:=maircraft_type;
orec.status_IPC:=mstat1;
orec.status_ELOG:=mstat2;
orec.status_SUPCAT:=mstat3;
orec.STATUS_AIRODWH:=status_AIRODWH;
end if;
end loop;
end;
end if;
end testsch2;
end ioStructArray;
Expecting your early reply.
With thanks
Pramod kumar. -
Concurrent HOST program calling a proc to log using fnd_file.put_line
Hello all,
I have a concurrent HOST program that does 3 main things
1. Calls a sqlplus program to do some initializing. This program is a proc in a package.
2. Runs sqlldr to load data to custom tables.
3. Calls a sqlplus program to do manipulate the data. This program is a proc in a package.
In step 3 of above, the package procedue does a "submit_request" to call the "Supplier Open Interface Import". This
request actually fires. However my problem is the subsequent call to fnd_file.put_line(fnd_file.log, 'Test message'), does not get logged
to the log file of the HOST program, nor to the log file of the "Supplier Open Interfface Import" log file. A check
of $APPLPTMP (or /usr/tmp) shows that a file of say " l0023761.tmp" contains my 'Test message' text.
I believe the problem is that the put_line() call has no association with the HOST or the "Supplier Open Interface Import. How
do I associate the logging to either program? Is it even possible? I want the logging, so as to see the progress
of the HOST program.
The sniippet of proc code is:
PROCEDURE abc() IS
BEGIN
request_id:= FND_REQUEST.SUBMIT_REQUEST
(Application => 'SQLAP'
,Program => 'APXSUIMP'
,Description => NULL
,Start_time => SYSDATE
,Sub_Request => FALSE
,Argument1 => 'ALL'
,Argument2 => 1000
,Argument3 => 'N'
,Argument4 => 'N'
,Argument5 => 'N'
fnd_file.put_line (fnd_file.log,'Test message');
COMMIT;
END abc;
Alex.Shell scripts are very hard to develop and maintain. Many things that developers previously had to do in shell scripts, developers can now do in PL/SQL. Hence, I recommend that you avoid shell scripts as much as possible.
As well, SQL*Loader is an old, inflexible tool. Instead, define your OS file as an external table, and then extract from the external table using a normal select statement. http://www.orafaq.com/node/848 I recommend that you avoid SQL*Loader and use external tables instead.
Using PL/SQL and external tables - and avoiding the shell script and SQL*Loader - a much better way to accomplish the same thing all inside one packaged procedure that is registered as a concurrent program:
- initialize
- select from the external table
- manipulate the data -
PL/SQL function not showing DMBS_OUTPUT.PUT_LINE result
I have compiled a function and when I call it, the DMBS value is not shown.
I have set serveroutput on
I am using 9i.
The function completes and provides a result:
SQL> select textrawio.HEXTONUM('0D') from dual;
TEXTRAWIO.HEXTONUM('0D')
13
The script:
CREATE OR REPLACE PACKAGE BODY textrawio
AS
FUNCTION hextonum(v_hex VARCHAR2) RETURN NUMBER
IS
hex VARCHAR2(4);
num NUMBER;
num1 NUMBER;
num2 NUMBER;
BEGIN
dbms_output.put_line ('hello');
hex := SUBSTRB(v_hex,1,1);
IF ( hex >= '0' and hex <= '9' ) THEN
num1 := TO_NUMBER(hex);
END IF;
IF hex = 'A' TH...Any ideas from this snippet?
I have never had a prob with DBMS_OUTPUT previously.
There is no DMBS_OUTPUT_GET_LINE code.The full PL/SQL is
CREATE OR REPLACE PACKAGE TEXTRAWIO
IS
FUNCTION tidblobchar(v_object_id char) RETURN VARCHAR2;
END; -- Package Specification TEXTRAWIO
SET SERVEROUTPUT ON
CREATE OR REPLACE PACKAGE BODY textrawio
AS
FUNCTION tidblobchar(v_object_id char) RETURN VARCHAR2
-- This function converts the long raw column of TIDBLOB to
-- its character representation for manipulation.
-- It can only be called for an object type of T.
IS
raw_data LONG RAW;
rawlen NUMBER;
hex_data VARCHAR2(32760);
char_data VARCHAR2(32760);
loop_counter NUMBER;
BEGIN
-- Get the blob using the rowid passed in.
-- Will always retrun only one row.
dbms_output.put_line ('1');
SELECT data
INTO raw_data
FROM ifsapp.client_profile_load
WHERE v_object_id = rowid;
dbms_output.put_line ('2');
-- Convert the raw data to hex.
hex_data := rawtohex(raw_data);
rawlen := length(hex_data);
loop_counter := 1;
dbms_output.put_line ('3');
-- Loop through and convert the hex to characters.
WHILE loop_counter <= rawlen LOOP
char_data := char_data || CHR(to_number(SUBSTRB(hex_data,loop_counter,2),'xx'));
loop_counter := loop_counter + 2;
END LOOP;
RETURN char_data;
END;
END;
/Both parts compile but when I run it:
SQL> select
2 user_name, profile_name, data_length, textrawio.tidblobchar(rowid) data, timestamp
3 from ifsapp.client_profile_load
4 where data is not null
5 ;
user_name, profile_name, data_length, textrawio.tidblobchar(rowid) data, timestamp
ERROR at line 2:
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at "IFSAPP.TEXTRAWIO", line 18I was hoping to use DBMS_OUTPUT to find which is the actual line having the error and later, what values it was dealing with.
Thanks
Maybe you are looking for
-
Composite AV connector stopped sending video
my composite AV connector stopped sending video....... audio still works but NO video. I even exchanged the cable for new one. Any advise??
-
Missing $10 certificate for Call of Duty Advanced Warfare pre-order
Also haven't received Dragon Age Inquisition yet, but it has yet to be 20 days. I miss having a separate rewards site to keep track of all this as it was much easier than the present format. The way orders and point searching is integrated is not v
-
hi all. i cant finish understand when to use a correlation in BPM. i was reading at Help Sap but the idea still is not clear. can anyone explain me with your own word what is a correlation and when for example i can use it. im watching BpmPatternSyn
-
Is there such a thing as a 'gift certificate' for photo services in iPhoto?
friends of ours just got back from germany and im sure will be wanting to make albums of it all. my wife and i were wanting to give a 'gift certificate' to make some books in iPhoto, but how is that done?? i know the ITMS has its own cards you can re
-
HP SWP not compatible with firefox 3.6.3
NO update for HP SWP for firefox 3.6.3? when will the HP Geeks will provide a new update for the firefox version, it's to late man, are they taking a powerful nap. Half the world has upgarded from firefox 3.5.9 to 3.6.3. I also want to upgrade but it