DBMS_OUTPUT.PUTLINE Not Working
I am new to Application express.I am unable to display anything on the screen (under the Results tab) in SQL Commands. I have the following program:
set serveroutput on;
Declare
vfirstname varchar2(35);
vlastname varchar2(35);
ccounter CONSTANT NUMBER:=0;
begin
select first_name, last_name into vfirstname, vlastname
from student_sby
where student_id=123;
dbms_OUTPUT.PUT_LINE ('student name: ' || ' ' || vlastname);
end;
When I run the program, it does not produce any error and any out put.
If I just have the select statement I get the results displayed.
select first_name, last_name
from student_sby
where student_id=123;
Any help will be appreciated. I am using Oracle Application Express version 4.x.
If you want to see debug information perhaps it's best if you use APEX_DEBUG_MESSAGE http://docs.oracle.com/cd/E17556_01/doc/apirefs.40/e15519/apex_debug.htm
For a quick output, use htp.p in a PL/SQL Region.
Like this
Declare
vfirstname varchar2(35);
vlastname varchar2(35);
ccounter CONSTANT NUMBER:=0;
begin
select first_name, last_name into vfirstname, vlastname
from student_sby
where student_id=123;
htp.p ('student name: ' || ' ' || vlastname);
end;
That will output the message to the page.
Thanks
-Jorge
Similar Messages
-
I am using Oracle 10.1.0.4.2 SQL Plus, and dbms_output.put_line is not working. It returns the dbms_output ONLY from outside the procedure. I have dbms_output INSIDE my procedure, and none of it gets returned. Please help!
Here is what I enter:
set serveroutput on size 1000000;
DECLARE
x number:=0;
begin
DBMS_OUTPUT.ENABLE;
c2reports.c2proc(x,'TEST');
DBMS_OUTPUT.PUT_LINE('testX');
END;
testX
There should be more besides the 'testX' that gets returned. The first line in my procedure has output code to print testY. Thanks in advance!This is the forum for the Oracle's SQL Developer (Not for general SQL/PLSQL questions). You should ask question like this in the PL/SQL forum
-
DBMS_OUTPUT.PUT_LINE not working in Stored Functions
Hi All,
I have one doubt, why is dbms_output.put_line not supported in Stored Functions?
create or replace function func_in_sql(var number) return varchar2
is
begin
If var is not null then
return to_char(dbms_output.put_line(var));
else
return to_char(dbms_output.put_line('null'));
end if;
end;
Returns error -
LINE/COL ERROR
5/3 PL/SQL: Statement ignored
5/18 PLS-00222: no function with name 'PUT_LINE' exists in this scope
7/3 PL/SQL: Statement ignored
7/18 PLS-00222: no function with name 'PUT_LINE' exists in this scope
Any idea why this is happening?
I know that to print value one can just use return statement and value will be printed in SQL Prompt.
But what makes me think is why error for PUT_LINE method?
If error is not thrown at DBMS_OTUPUT then doesnt that mean all methods of DBMS_OUTPUT should be accessible in a function.
Thanks in advance!
Av.Hi,
For cant call proc inside func, or in-line thing you mentioned, just tried following -
Here is our previous Func -
create or replace function func_in_sql(var number) return varchar2
is
begin
/*If var is not null then
return to_char(dbms_output.put_line(var));
else
return to_char(dbms_output.put_line('null'));
end if;
exception_test;
return 'a';
end;
and here is our proc -
procedure exception_test
as
v_count1 number;
v_count2 number;
begin
select count(test_id)
INTO V_COUNT1
from TEST_TABLE;
If SQL%NOTFOUND Then
dbms_output.put_line('notfound');
End If;
dbms_output.put_line(v_count1);
exception
when no_data_found then
If SQL%NOTFOUND Then
dbms_output.put_line('notfound');
End If;
dbms_output.put_line('no_data');
WHEN TOO_MANY_ROWS THEN
dbms_output.put_line('too many rows');
when others then
dbms_output.put_line('others');
end;
and here is the call to func -
SQL> select func_in_sql(x) from t1;
FUNC_IN_SQL(X)
a
a
a
a
4 rows selected.
So this shows it works.
Is this what you said? or Am I getting you wrong?
Thanks!
Av. -
30EA2 dbms_output.put_line not working
Hi All,
I've testing new release SQL Developer and
the code bellow is not put any data to output? Is it an issue new version ?
BEGIN
dbms_output.put_line('[text]');
END;
SQL Developer
Version 3.0.02
Build MAIN-02.83
Thank you in advance
EdvardHi Edvard,
Yes, dbms_output is borked on 3.0EA2, but you can make it work if you put 'SET SERVEROUTPUT ON' in front of your statement:
SET SERVEROUTPUT ON
BEGIN
dbms_output.put_line('[text]');
END;
And run it as a script (F5 on Windows, I think)
See EA2: Dbms Output broken? for more. -
Dbms_output.put_line not working
Hi, i am trying to use dbms_output.put_line to execute a sql in a bat script on windows...i get no errors , but the "alter tablespace" just prints but does not execute.
What exactly am i missing? Part of the script shown below..
thanks
set HFILE=%SCRIPT_HOME%\remove_bkupmode.sql
echo connect sys/%INTPWD% as sysdba >>%HFILE%
echo set termout off heading off feedback off >>%HFILE%
echo set linesize 300 pagesize 0 >>%HFILE%
echo set serveroutput on size 1000000 >>%HFILE%
echo spool %SCRIPT_HOME%\cleanup.sql >>%HFILE%
echo Declare >>%HFILE%
echo cursor c1 is SELECT t.name FROM V$DATAFILE d, V$TABLESPACE t, V$BACKUP b WHERE d.TS#=t.TS# AND b.FILE#=d.FILE# AND b.STATUS='ACTIVE'; >>%HFILE%
echo Begin >>%HFILE%
echo for tbs in c1 loop >>%HFILE%
echo dbms_output.put_line(' alter tablespace '^|^|tbs.name ^|^|' end backup;'); >>%HFILE%
echo end loop; >>%HFILE%
echo dbms_output.put_line('exit;'); >>%HFILE%
echo End; >>%HFILE%
echo / >>%HFILE%
echo spool off >>%HFILE%
echo exit; >>%HFILE%
START /wait SQLPLUS /NOLOG @%HFILE%thanks guys...did i bring back memories?
yeah its an old script. part of an old hot backup script i inherited, for a 24/7 live 9.2.0.1 database that can't be upgraded due to customizations lol
i setup rman, but since i'n still new to rman, i wanted to continue with the user- managed hot backups
this script will run afer the backup, just in case, to ensure that no tablespaces are left in backup mode.
J -
Dbx WS6U2 bulitin exists function not working
The exists function always returns 1 regardless.
This used to work in 5.0.
This causes the prettyprint function in /opt/SUNWspro/WS6U2/lib/dbxrc not to work.
Any fixes/workarounds available ?Ok...I got the function working.
But now I need some help...
I'm confused about how to properly use the function.
I mean, I know I only want to pass to it two values, the user input Student ID and Date,
but how does my function know to compare those dates/studentid's to the ones in the
table student_schedule.
here's my code:
create or replace function student_GPA
(StdntID IN Student_schedule.Student_ID%Type,
DateAssgn IN Student_Schedule.DATE_GRADE_ASSIGNED%Type,
EnterID IN Number, EnterDate IN VarChar2)
return number is
GPA number;
InsDate varchar2(11);
StdID varchar2(8);
begin
DBMS_OUTPUT.PUT_LINE('--------Get student GPA--------------');
StdID := EnterID;
InsDate:=EnterDate;
-- Calculate the average grade point for this student based on all
-- classes for which a grade has been assigned.
select avg(decode(grade, 'A+', 4.25, 'A', 4, 'A-', 3.75,
'B+', 3.25, 'B', 3, 'B-', 2.75,
'C+', 2.25, 'C', 2, 'C-', 1.75,
'D+', 1.25, 'D', 1, 'D-', 0.75, 'F', 0))
into GPA
from student_schedule
where
StdntID = StdID
AND
DateAssgn >=InsDate
Order by Date_Grade_Assigned Desc;
return GPA;
end;
declare
StID student_schedule.Student_ID%type;
DateGAssgn student_schedule.Date_Grade_Assigned%type;
OutPut varchar2(50);
Begin
StID := &StudentID;
DateGAssgn:=&DateForStudent;
OutPut:=Student_GPA(StID,DateGAssgn);
DBMS_OUTPUT.PUTLINE('Student GPA IS: '||OutPut);
End;
I'm rushing now, so maybe I'm missing the obvious...
any ideas? -
PL/SQL program not working when connect database via SqlNet
Hi,
This is a segment of a PL/SQL program before opening a cursor using input descriptor. It is working fine ( to get the value of unOutputCount ) without connect to a database via SqlNet, can anyone tell me why it is not working ( unOutputCount return 0)while connecting to a database via SqlNet and how to make it work without opening a cursor before DESCRIBE OUTPUT ...?
EXEC SQL ALLOCATE DESCRIPTOR GLOBAL 'input_111'
WITH MAX 100;
EXEC SQL ALLOCATE DESCRIPTOR GLOBAL 'output_111'
WITH MAX 100;
EXEC SQL PREPARE STMT1 FROM :psSqlStatement;
EXEC SQL DECLARE CURSOR1 CURSOR FOR STMT1;
EXEC SQL DESCRIBE INPUT STMT1
USING DESCRIPTOR GLOBAL 'input_111';
/* Get count of input parameters in statement */
EXEC SQL GET DESCRIPTOR GLOBAL 'input_111' :unInputCount = COUNT;
EXEC SQL DESCRIBE OUTPUT STMT1
USING DESCRIPTOR GLOBAL 'output_111';
/* Get count of output parameters in statement */
EXEC SQL GET DESCRIPTOR GLOBAL 'output_111'
:unOutputCount = COUNT;Hi,
Welcome to Oracle OTN Forums!
I changed your code a little. I think this help you
CREATE OR REPLACE
PROCEDURE xx_test
IS
v_pid VARCHAR2(100);
v_cn VARCHAR2(100);
v_id VARCHAR2(1000);
v_val VARCHAR2(1000);
CURSOR C1
IS
(SELECT product_id, 'PRODUCT_ID' cn
FROM product1 );
BEGIN
FOR V1 IN C1
LOOP
FETCH C1 INTO v_pid, v_cn;
dbms_output.put_line('==== '||v_pid||'==== '||v_cn);
EXECUTE IMMEDIATE
'SELECT product_id, DECODE(COUNT (product_id),1,MAX (product_id))||'''||V_CN||''' as val
FROM product1
WHERE product_id =:a
GROUP BY product_id)' INTO v_id, v_val USING v_pid;
dbms_output.put_line('==== '||v_id||'==== '||v_val);
EXECUTE IMMEDIATE 'UPDATE product2 SET '||v_cn||' = ' ||''''|| v_val ||''''|| ' WHERE product_id = :b' USING v_pid;
dbms_output.put_line('++++ '||v_cn||'++++ '||v_val||'++++ '||v_pid);
END LOOP;
END xx_test; -
My first PL/SQL block not working with using Select query within begin
I am new to PL/SQL , just started with basics of BLOCKS .
I am having a query here in executing a block .
When i am doing a insert oprtation in Blocks Begin method everything is working fine , but when ever i tried to do select operation , some error is being thrown .
First of all This is my Table :
select from try :*
KEY VALUE
Key Value
Key1 Value1
Key2 Value2
Key3 Value3
======================
This is the code which is not working : Please see the code and tell me what is the problem .
DECLARE
v_KEY VARCHAR2(20);
v_VALUE VARCHAR2(20);
BEGIN
select key into v_KEY FROM try where v_value='Value' ;
dbms_output.put_line(v_KEY);
END;
When i run this code , it is saying Data Not Found on this line " select key into v_KEY FROM try where v_value='Value' ;"
wheer when i run tis individually it worked fine :
select KEY FROM try where VALUE='Value' ;"
please share your ideas .as why it isn't running ??
Edited by: user10503747 on Sep 20, 2010 3:16 AMHi,
user10503747 wrote:
I am new to PL/SQL , just started with basics of BLOCKS .
I am having a query here in executing a block .
When i am doing a insert oprtation in Blocks Begin method everything is working fine , but when ever i tried to do select operation , some error is being thrown .
First of all This is my Table :
select from try :*
KEY VALUE
Key Value
Key1 Value1
Key2 Value2
Key3 Value3
======================
This is the code which is not working : Please see the code and tell me what is the problem .
DECLARE
v_KEY VARCHAR2(20);
v_VALUE VARCHAR2(20);
BEGIN
select key into v_KEY FROM try where v_value='Value' ;
dbms_output.put_line(v_KEY);
END;
When i run this code , it is saying Data Not Found on this line " select key into v_KEY FROM try where v_value='Value' ;"
wheer when i run tis individually it worked fine :
select KEY FROM try where VALUE='Value' ;"
please share your ideas .as why it isn't running ??
Edited by: user10503747 on Sep 20, 2010 3:16 AMInstead of:
{code}
select key into v_KEY FROM try where v_value='Value' ;
{code}
perhaps you meant something like:
{code}
v_value := 'Value1';
select key into v_KEY FROM try where v_value=Value ; -- No quotes
{code}
Until you assign a vlue to a variable, like v_value, it is NULL, so your original statement was equivalent to
{code}
select KEY FROM try where NULL='Value' ;
{code}
In PL/SQL, a SELECT ... INTO statement must return exactly one row, or else you will get an error (either NO_DATA_FOUND or TOO_MANY_ROWS). This is different from SQL, where a query cn return any number of rows, including 0, without raising an error. -
Date type parameters do not work package procedure
a cordial greeting to the whole community, in advance thank you very much for your precious time
a general way I have the following, a package in which I have a main procedure which I recible three parameters: a start date, a final, and a number of client
to use the dates I enter as parameter to query yields no records, but if I assign the date internally in the procedure, if it sheds records, the strange thing is that both the data and the parameters that are identical internally assigned even in its length and I checked, the truth and I stay out of ideas thank you very much for your time attaching the code
for now I'm just using the second query forget the first
------call to procedure-----
DECLARE
errcode VARCHAR2(200);
errbuf VARCHAR2(200);
BEGIN
xxxxx.pkg.xxxinitial_end(errcode ,errbuf
,'2013/08/19 00:00:00'
,'2013/08/23 00:00:00','456456456546');
END;
-----------------------------------------------------------------procedure---------------------------------------------------------------------
PROCEDURExxxinitial_end (ERRCODE OUT VARCHAR2
, ERRBUFF OUT VARCHAR2
, p_initial_date IN VARCHAR2
, p_end_date IN VARCHAR2
, customer IN VARCHAR2)IS
l_encoding_line VARCHAR2(240);
cur_without_customer SYS_REFCURSOR;
cur_with_customer SYS_REFCURSOR;
initial_date DATE;
end_date DATE;
initial_date2 DATE;
end_date2 DATE;
BEGIN
l_encoding_line := '<?xml version="1.0" encoding=' || '"iso-8859-1"' ||
' ?>' || chr(10) || '<XXOCS_TOTAL_VENTAS_SINEXP>';
initial_date := to_date(p_initial_date, 'YYYY/MM/DD HH24:MI:SS');-----------------input parameters NOT WORKING
end_date := to_date(p_end_date, 'YYYY/MM/DD HH24:MI:SS');-------------------input parameters
initial_date2:=to_date('2013/08/19 00:00:00', 'YYYY/MM/DD HH24:MI:SS');---------------------default values
end_date2:=to_date('2013/08/23 00:00:00', 'YYYY/MM/DD HH24:MI:SS');---------------------default values WORKING FINE
IF customer IS NULL THEN
-- OPEN cur_without_customer;
DBMS_OUTPUT.PUT_LINE('se ejecuto el primero');
-------------------------cursor -----------------------------------
OPEN cur_without_customer FOR
SELECT rct.customer_trx_id
,rctl.customer_trx_line_id
,hp.party_name ---cliente
,hca.account_number ----N° Cliente
,rctl.line_number -----item
,rctt.name---descripcion transaccion
,rct.trx_number -----numero
,rctt.type ------tipo de transaccion
,hp.party_id--control solamente
,rct.trx_date------Fecha de emisión Comprobante de Venta
,rct.attribute1 ---No. de autorización del Comprobante de Venta
,mp.attribute9||rct.trx_number N_Comprobante---No. de Comprobante de Venta
,rct.attribute4-----Unidad Estratégica de Negocio
,mp.attribute9---- N° de establecimiento
,rctl.description-----Descripción (Tipo de Combustible)
,rctl.quantity_invoiced---Cantidad Vendida en galones
,rctl.unit_selling_price---Precio de venta unitario
--,rctl.taxable_amount-------Valor Base Imponible --restriccion
--,rctl.extended_amount---valor iva 12%
-- ,NVL(importe_12(rctl.customer_trx_line_id,rct.customer_trx_id),'N/A')
FROM ra_customer_trx_all rct,
ra_customer_trx_lines_all rctl,
hz_cust_accounts hca,
hz_parties hp,
ra_cust_trx_types_all rctt,
mtl_parameters mp
-- mtl_system_items_b msi,
-- zx_lines zl
--ra_batch_sources_all rbs
WHERE
--rct.trx_date BETWEEN initial_date AND end_date --parametros de fecha
rct.trx_date BETWEEN to_date('2013/08/19 00:00:00', 'YYYY/MM/DD HH24:MI:SS')/*initial_date*/ AND to_date('2013/08/23 00:00:00', 'YYYY/MM/DD HH24:MI:SS')/*end_date*/
AND rct.sold_to_customer_id = hca.cust_account_id
AND hca.party_id = hp.party_id
AND rct.customer_trx_id=rctl.customer_trx_id
--AND rctl.inventory_item_id=msi.inventory_item_id
AND mp.organization_id=rctl.warehouse_id
AND rct.cust_trx_type_id = rctt.cust_trx_type_id;
print_output(fnd_file.output, l_encoding_line);
get_xml(cur_without_customer, 'G_REGISTER', 'CABECERA', ERRCODE);
IF ERRCODE = 1 THEN
ERRBUFF := 'El reporte no arrojo datos para los parametros ingresados';
ERRCODE := 2;
RETURN;
ELSIF ERRCODE = 2 THEN
ERRBUFF := SQLERRM;
RETURN;
END IF;
print_output(fnd_file.output, '</XXOCS_TOTAL_VENTAS_SINEXP>');
ELSE
-- OPEN cur_with_customer;
DBMS_OUTPUT.PUT_LINE('se ejecuto el segundo');
-----------------------cursor 2---------------------------
DBMS_OUTPUT.PUT_LINE('customer ' || customer);
DBMS_OUTPUT.PUT_LINE('ASI ESTAN ENTRANDO LOS PARAMETROS '||length(p_initial_date));
DBMS_OUTPUT.PUT_LINE('ASI ESTAN ENTRANDO LOS PARAMETROS '||length(p_end_date));
DBMS_OUTPUT.PUT_LINE('customer ' || customer);
DBMS_OUTPUT.PUT_LINE('ASI ESTAN ENTRANDO LOS PARAMETROS quemados '|| length(initial_date2));
DBMS_OUTPUT.PUT_LINE('ASI ESTAN ENTRANDO LOS PARAMETROS quemados '|| length(end_date2));
DBMS_OUTPUT.PUT_LINE('customer ' || customer);
DBMS_OUTPUT.PUT_LINE('ASI ESTAN ENTRANDO LOS PARAMETROS convertidso '|| length(initial_date));
DBMS_OUTPUT.PUT_LINE('ASI ESTAN ENTRANDO LOS PARAMETROS convertidos '|| length(end_date));
OPEN cur_with_customer FOR
SELECT rct.customer_trx_id
,rctl.customer_trx_line_id
,hp.party_name ---cliente
,hca.account_number ----N° Cliente
,rctl.line_number-----item
,rctt.name---descripcion transaccion
,rct.trx_number -----numero
,rctt.type ------tipo de transaccion
,hp.party_id---control solamente
,rct.trx_date------Fecha de emisión Comprobante de Venta
,rct.attribute1 ---No. de autorización del Comprobante de Venta
,mp.attribute9||rct.trx_number N_Comprobante--No. de Comprobante de Venta
,rct.attribute4------ Unidad Estratégica de Negocio
,mp.attribute9---------N° de establecimiento
,rctl.description---------Descripción (Tipo de Combustible)
,rctl.quantity_invoiced----Cantidad Vendida en galones
,rctl.unit_selling_price ---Precio de venta unitario
-- ,rctl.taxable_amount-------Valor Base Imponible --restriccion
-- ,rctl.extended_amount---valor iva 12%
-- ,NVL(importe_12(rctl.customer_trx_line_id,rct.customer_trx_id),'N/A')
FROM ra_customer_trx_all rct,
ra_customer_trx_lines_all rctl,
hz_cust_accounts hca,
hz_parties hp,
ra_cust_trx_types_all rctt,
mtl_parameters mp
-- mtl_system_items_b msi,
--zx_lines zl
WHERE hca.account_number=customer
AND hca.party_id=hp.party_id
AND hca.cust_account_id=rct.sold_to_customer_id
AND rct.customer_trx_id=rctl.customer_trx_id
-- AND rctl.inventory_item_id=msi.inventory_item_id
AND mp.organization_id=rctl.warehouse_id
AND rct.cust_trx_type_id = rctt.cust_trx_type_id
AND rownum = 1
AND rct.trx_date BETWEEN initial_date AND end_date;<------------when I assign these parameters( initial_date AND end_date )--are the insert by parameter initial_date2 AND end_date2 defualt
DBMS_OUTPUT.PUT_LINE('customer ' || customer);
DBMS_OUTPUT.PUT_LINE('fe inicial ' || initial_date);
DBMS_OUTPUT.PUT_LINE('fe final ' ||end_date);
print_output(fnd_file.output, l_encoding_line);
get_xml(cur_with_customer, 'G_REGISTER', 'CABECERA', ERRCODE);
IF ERRCODE = 1 THEN
ERRBUFF := 'El reporte no arrojo datos para los parametros ingresados';
ERRCODE := 2;
RETURN;
ELSIF ERRCODE = 2 THEN
ERRBUFF := SQLERRM;
RETURN;
END IF;
print_output(fnd_file.output, '</XXOCS_TOTAL_VENTAS_SINEXP>');
END IF;
EXCEPTION
WHEN OTHERS THEN
print_output(fnd_file.log, 'Error Ventas sin Exportaciones:' || SQLERRM);
ERRCODE := 2;
ERRBUFF := SQLERRM;
-- Initialization
END xxxinitial_end;Welcome. As a note, this question has nothing to do with PL/SQL XML programming and everything to do with SQL and PL/SQL
That said, the simple test case I setup, because I don't have all your tables, works just fine.
declare
l_errcode VARCHAR2(300);
l_errbuff VARCHAR2(300);
PROCEDURE xxxinitial_end (ERRCODE OUT VARCHAR2
, ERRBUFF OUT VARCHAR2
, p_initial_date IN VARCHAR2 -- why not a date?
, p_end_date IN VARCHAR2 -- why not a date?
, customer IN VARCHAR2)
IS
initial_date DATE;
end_date DATE;
l_value VARCHAR2(10);
BEGIN
initial_date := to_date(p_initial_date, 'YYYY/MM/DD HH24:MI:SS');
end_date := to_date(p_end_date, 'YYYY/MM/DD HH24:MI:SS');
-- Not trapping the No Data Found on purpose
SELECT 'hit'
INTO l_value
FROM dual
WHERE SYSDATE BETWEEN initial_date AND end_date;
END xxxinitial_end;
begin
-- Test statements here
xxxinitial_end(l_errcode, l_errbuff
,'2013/08/19 00:00:00'
,'2013/10/19 00:00:00'
,null);
end;
As a comment above says, if you are dealing with dates, why not use a DATE parameter in the procedure and avoid the conversion in your code.
Also, you can simplify your code a bit by using a third sys_refcursor and setting one of the opened cursors to it. This allows you to pull out the common logic following the OPEN and only have one copy of it.
PROCEDURE xxxinitial_end (ERRCODE OUT VARCHAR2
, ERRBUFF OUT VARCHAR2
, p_initial_date IN VARCHAR2 -- why not a date?
, p_end_date IN VARCHAR2 -- why not a date?
, customer IN VARCHAR2)
IS
l_encoding_line VARCHAR2(240);
cur_without_customer SYS_REFCURSOR;
cur_with_customer SYS_REFCURSOR;
cur_comm SYS_REFCURSOR;
initial_date DATE;
end_date DATE;
BEGIN
l_encoding_line := '<?xml version="1.0" encoding=' || '"iso-8859-1"' ||
' ?>' || chr(10) || '<XXOCS_TOTAL_VENTAS_SINEXP>';
initial_date := to_date(p_initial_date, 'YYYY/MM/DD HH24:MI:SS');-----------------input parameters NOT WORKING
end_date := to_date(p_end_date, 'YYYY/MM/DD HH24:MI:SS');-------------------input parameters
IF customer IS NULL THEN
-------------------------cursor -----------------------------------
OPEN cur_without_customer FOR
SELECT rct.customer_trx_id
,rctl.customer_trx_line_id
,hp.party_name ---cliente
,hca.account_number ----N° Cliente
,rctl.line_number -----item
,rctt.name---descripcion transaccion
,rct.trx_number -----numero
,rctt.type ------tipo de transaccion
,hp.party_id--control solamente
,rct.trx_date------Fecha de emisión Comprobante de Venta
,rct.attribute1 ---No. de autorización del Comprobante de Venta
,mp.attribute9||rct.trx_number N_Comprobante---No. de Comprobante de Venta
,rct.attribute4-----Unidad Estratégica de Negocio
,mp.attribute9---- N° de establecimiento
,rctl.description-----Descripción (Tipo de Combustible)
,rctl.quantity_invoiced---Cantidad Vendida en galones
,rctl.unit_selling_price---Precio de venta unitario
--,rctl.taxable_amount-------Valor Base Imponible --restriccion
--,rctl.extended_amount---valor iva 12%
-- ,NVL(importe_12(rctl.customer_trx_line_id,rct.customer_trx_id),'N/A')
FROM ra_customer_trx_all rct,
ra_customer_trx_lines_all rctl,
hz_cust_accounts hca,
hz_parties hp,
ra_cust_trx_types_all rctt,
mtl_parameters mp
-- mtl_system_items_b msi,
-- zx_lines zl
--ra_batch_sources_all rbs
WHERE
--rct.trx_date BETWEEN initial_date AND end_date --parametros de fecha
rct.trx_date BETWEEN to_date('2013/08/19 00:00:00', 'YYYY/MM/DD HH24:MI:SS')/*initial_date*/ AND to_date('2013/08/23 00:00:00', 'YYYY/MM/DD HH24:MI:SS')/*end_date*/
AND rct.sold_to_customer_id = hca.cust_account_id
AND hca.party_id = hp.party_id
AND rct.customer_trx_id=rctl.customer_trx_id
--AND rctl.inventory_item_id=msi.inventory_item_id
AND mp.organization_id=rctl.warehouse_id
AND rct.cust_trx_type_id = rctt.cust_trx_type_id;
cur_comm := cur_without_customer;
ELSE
-----------------------cursor 2---------------------------
OPEN cur_with_customer FOR
SELECT rct.customer_trx_id
,rctl.customer_trx_line_id
,hp.party_name ---cliente
,hca.account_number ----N° Cliente
,rctl.line_number-----item
,rctt.name---descripcion transaccion
,rct.trx_number -----numero
,rctt.type ------tipo de transaccion
,hp.party_id---control solamente
,rct.trx_date------Fecha de emisión Comprobante de Venta
,rct.attribute1 ---No. de autorización del Comprobante de Venta
,mp.attribute9||rct.trx_number N_Comprobante--No. de Comprobante de Venta
,rct.attribute4------ Unidad Estratégica de Negocio
,mp.attribute9---------N° de establecimiento
,rctl.description---------Descripción (Tipo de Combustible)
,rctl.quantity_invoiced----Cantidad Vendida en galones
,rctl.unit_selling_price ---Precio de venta unitario
-- ,rctl.taxable_amount-------Valor Base Imponible --restriccion
-- ,rctl.extended_amount---valor iva 12%
-- ,NVL(importe_12(rctl.customer_trx_line_id,rct.customer_trx_id),'N/A')
FROM ra_customer_trx_all rct,
ra_customer_trx_lines_all rctl,
hz_cust_accounts hca,
hz_parties hp,
ra_cust_trx_types_all rctt,
mtl_parameters mp
-- mtl_system_items_b msi,
--zx_lines zl
WHERE hca.account_number=customer
AND hca.party_id=hp.party_id
AND hca.cust_account_id=rct.sold_to_customer_id
AND rct.customer_trx_id=rctl.customer_trx_id
-- AND rctl.inventory_item_id=msi.inventory_item_id
AND mp.organization_id=rctl.warehouse_id
AND rct.cust_trx_type_id = rctt.cust_trx_type_id
AND rownum = 1
AND rct.trx_date BETWEEN initial_date AND end_date;<------------when I assign these parameters( initial_date AND end_date )--are the insert by parameter initial_date2 AND end_date2 defualt
cur_comm := cur_with_customer;
END IF;
print_output(fnd_file.output, l_encoding_line);
get_xml(cur_comm, 'G_REGISTER', 'CABECERA', ERRCODE);
CLOSE cur_comm;
IF ERRCODE = 1 THEN
ERRBUFF := 'El reporte no arrojo datos para los parametros ingresados';
ERRCODE := 2;
RETURN;
ELSIF ERRCODE = 2 THEN
ERRBUFF := SQLERRM;
RETURN;
END IF;
EXCEPTION
WHEN OTHERS THEN
print_output(fnd_file.log, 'Error Ventas sin Exportaciones:' || SQLERRM);
ERRCODE := 2;
ERRBUFF := SQLERRM;
-- Initialization
END xxxinitial_end; -
Insert statement will not work if select statement has less number of colum
Hi,
One of my thread is already resolved on the following URL : unable to insert rows into the table
DROP TABLE TEMP;
CREATE TABLE TEMP AS SELECT * FROM CASE_101 WHERE 1=2;
DECLARE
S VARCHAR2(200);
STMT VARCHAR2(500);
begin
for C in (select TABLE_NAME INTO S from USER_TABLES where TABLE_NAME like 'CASE%' TABLE_NAME NOT like '%OLD' and Num_ROWS > 0 order by TABLE_NAME) loop
STMT := 'INSERT INTO TEMP SELECT * FROM ';
STMT:=STMT || C.TABLE_NAME;
EXECUTE IMMEDIATE STMT;
dbms_output.put_line(c.table_name);
end loop;
end;
i am facing now some different; almost all the tables have same number of columns except in few of tables have some additional columns. As above i am creating a table "TEMP" who has highest column temp(by doing some manual process). The table who has less columns than "TEMP" table : Insert statement will not work. 'INSERT INTO TEMP SELECT * FROM less_columns_table_name'.
Please let me know , how can i execute proper way.
Thanks.
Best Regards
Arshaduser13360241 wrote:
Hi,
One of my thread is already resolved on the following URL : unable to insert rows into the table
DROP TABLE TEMP;
CREATE TABLE TEMP AS SELECT * FROM CASE_101 WHERE 1=2;
DECLARE
S VARCHAR2(200);
STMT VARCHAR2(500);
begin
for C in (select TABLE_NAME INTO S from USER_TABLES where TABLE_NAME like 'CASE%' TABLE_NAME NOT like '%OLD' and Num_ROWS > 0 order by TABLE_NAME) loop
STMT := 'INSERT INTO TEMP SELECT * FROM ';
STMT:=STMT || C.TABLE_NAME;
EXECUTE IMMEDIATE STMT;
dbms_output.put_line(c.table_name);
end loop;
end;
i am facing now some different; almost all the tables have same number of columns except in few of tables have some additional columns. As above i am creating a table "TEMP" who has highest column temp(by doing some manual process). The table who has less columns than "TEMP" table : Insert statement will not work. 'INSERT INTO TEMP SELECT * FROM less_columns_table_name'.
Please let me know , how can i execute proper way.
Thanks.
Best Regards
Arshadmore often than not "TEMP" tables are NOT required & are highly inefficient in Oracle.
Either only specify explicit column in TEMP to get data,
or provide value for "extra" column in TEMP -
It is not working when use trigger to check data from other table.
Please help me with this, I have put a trigger on a table but it can not work as I expect.
case study: one class has many students, only one of them goes to match.
The purpose of this trigger is to check when choose a student goes to match, this student must in his class where he belongs to.
Version of Oracle is 10.2.0.1.0.
--table:
DROP TABLE STU;
DROP TABLE CLASS;
create table CLASS(
CID VARCHAR2(5) PRIMARY KEY,
CNAME VARCHAR2(20) NOT NULL,
SCHOSEN VARCHAR2(5));
create table STU(
SID VARCHAR2(5) PRIMARY KEY,
SNAME VARCHAR2(20) NOT NULL,
CID VARCHAR2(5) NOT NULL REFERENCES CLASS(CID) ON DELETE CASCADE);
--data:
--CLASS
INSERT INTO CLASS(CID,CNAME) VALUES(1,'SUN');
INSERT INTO CLASS(CID,CNAME) VALUES(2,'MOON');
INSERT INTO CLASS(CID,CNAME) VALUES(3,'EARTH');
--STU
INSERT INTO STU VALUES(1,'JACK',1);
INSERT INTO STU VALUES(2,'TOM',1);
INSERT INTO STU VALUES(3,'LILY',2);
INSERT INTO STU VALUES(4,'DUSTIN',3);
--TRIGGER
CREATE OR REPLACE TRIGGER CHECK_SCHOSEN
BEFORE INSERT OR UPDATE OF SCHOSEN ON CLASS
FOR EACH ROW WHEN (NEW.SCHOSEN IS NOT NULL)
DECLARE
DUMMY INTEGER;
INVALID_STU EXCEPTION;
VALID_STU EXCEPTION;
MUTATING_TABLE EXCEPTION;
PRAGMA EXCEPTION_INIT(MUTATING_TABLE, -4091);
CURSOR DUMMY_CURSOR (ST VARCHAR2, CL VARCHAR2) IS
SELECT SID FROM STU, CLASS
WHERE STU.SID=ST AND STU.CID=CLASS.CID AND CLASS.CID=CL
FOR UPDATE OF CLASS.SCHOSEN;
BEGIN
OPEN DUMMY_CURSOR(:NEW.SCHOSEN, :NEW.CID);
FETCH DUMMY_CURSOR INTO DUMMY;
IF DUMMY_CURSOR%NOTFOUND THEN
RAISE INVALID_STU;
ELSE
RAISE VALID_STU;
END IF;
CLOSE DUMMY_CURSOR;
EXCEPTION
WHEN INVALID_STU THEN
CLOSE DUMMY_CURSOR;
DBMS_OUTPUT.PUT_LINE('PLEASE RE-ENTER CLASS ID AND STUDENT ID AS CLASS OR STUDENT IS NOT VALID.');
WHEN VALID_STU THEN
CLOSE DUMMY_CURSOR;
DBMS_OUTPUT.PUT_LINE('STUDENT CHOOSE SUCCEFULLY!');
WHEN MUTATING_TABLE THEN
NULL;
END;
/Just copy and paste above and try to run following:
UPDATE CLASS
SET SCHOSEN=3
WHERE CID=1;
Clearly,you can not choose student which is 3 as match member of class 1. Please help me. Thanks.
Edited by: 991096 on 01-Mar-2013 02:36
Edited by: 991096 on 01-Mar-2013 03:03
Edited by: 991096 on 01-Mar-2013 03:11Hi,
Welcome to the forum!
Like the others, I can't see a business purpose for this trigger. I assume it's just an experiment to learn how triggers work.
991096 wrote:
Please help me with this, I have put a trigger on a table but it can not be triggered.Sorry, I don't understand what you want help with.
Are you saying the trigger doesn't fire? It does fire; it just raises the mutating table error, so you don't see anything.
case study: one class has many students, only one of them goes to match.What do you mean when you say "goes to match"?
--table:
DROP TABLE STU;
DROP TABLE CLASS;
create table CLASS(
CID VARCHAR2(5) PRIMARY KEY,
CNAME VARCHAR2(20) NOT NULL,
SCHOSEN VARCHAR2(5));
create table STU(
SID VARCHAR2(5) PRIMARY KEY,
SNAME VARCHAR2(20) NOT NULL,
CID VARCHAR2(5) NOT NULL REFERENCES CLASS(CID) ON DELETE CASCADE);
--data:
--CLASS
INSERT INTO CLASS(CID,CNAME) VALUES(1,'SUN');
INSERT INTO CLASS(CID,CNAME) VALUES(2,'MOON');
INSERT INTO CLASS(CID,CNAME) VALUES(3,'EARTH');
--STU
INSERT INTO STU VALUES(1,'JACK',1);
INSERT INTO STU VALUES(2,'TOM',1);
INSERT INTO STU VALUES(3,'LILY',2);
INSERT INTO STU VALUES(4,'DUSTIN',3);
--TRIGGER
CREATE OR REPLACE TRIGGER CHECK_SCHOSEN
BEFORE INSERT OR UPDATE OF SCHOSEN ON CLASS
FOR EACH ROW WHEN (NEW.SCHOSEN IS NOT NULL)
DECLARE
DUMMY INTEGER;
INVALID_STU EXCEPTION;
VALID_STU EXCEPTION;
MUTATING_TABLE EXCEPTION;
PRAGMA EXCEPTION_INIT(MUTATING_TABLE, -4091);
CURSOR DUMMY_CURSOR (ST VARCHAR2, CL VARCHAR2) IS
SELECT SID FROM STU, CLASS
WHERE STU.SID=ST AND STU.CID=CLASS.CID AND CLASS.CID=CL
FOR UPDATE OF CLASS.SCHOSEN;
BEGIN
OPEN DUMMY_CURSOR(:NEW.SCHOSEN, :NEW.CID);
FETCH DUMMY_CURSOR INTO DUMMY;
IF DUMMY_CURSOR%NOTFOUND THEN
RAISE INVALID_STU;
ELSE
RAISE VALID_STU;
END IF;
CLOSE DUMMY_CURSOR;
EXCEPTION
WHEN INVALID_STU THEN
CLOSE DUMMY_CURSOR;
DBMS_OUTPUT.PUT_LINE('PLEASE RE-ENTER CLASS ID AND STUDENT ID AS CLASS OR STUDENT IS NOT VALID.');
WHEN VALID_STU THEN
CLOSE DUMMY_CURSOR;
DBMS_OUTPUT.PUT_LINE('STUDENT CHOOSE SUCCEFULLY!');
WHEN MUTATING_TABLE THEN
NULL;
END;
/Thanks for posting the CREATE TABLE, INSERT and CREATE TRIGGER statements; that really helps!
See the forum FAQ {message:id=9360002} for other helpful tips, such as how to use \ tags to post formatted code.
Just copy and paste above and try to run following:
UPDATE CLASS
SET SCHOSEN=3
WHERE CID=1;
Clearly,you can not choose student which is 3 as match member of class 1. The trigger did not be triggered. Please help me. Thanks.You can't do DML, or even query, the class table from a FOR EACH ROW trigger on the same class table.
Add 3 more calls to put_line to see this:CREATE OR REPLACE TRIGGER CHECK_SCHOSEN
BEFORE INSERT OR UPDATE OF SCHOSEN ON CLASS
FOR EACH ROW WHEN (NEW.SCHOSEN IS NOT NULL)
DECLARE
DUMMY INTEGER;
INVALID_STU EXCEPTION;
VALID_STU EXCEPTION;
MUTATING_TABLE EXCEPTION;
PRAGMA EXCEPTION_INIT (MUTATING_TABLE, -4091);
CURSOR DUMMY_CURSOR (ST VARCHAR2, CL VARCHAR2) IS
SELECT SID
FROM STU
, CLASS
WHERE STU.SID = ST
AND STU.CID = CLASS.CID
AND CLASS.CID = CL
FOR UPDATE OF CLASS.SCHOSEN;
BEGIN
dbms_output.put_line (:NEW.schosen || ' = schosen entering check_schosen'); -- ***** NEW *****
OPEN DUMMY_CURSOR (:NEW.SCHOSEN, :NEW.CID);
dbms_output.put_line ('Cursor is open now.'); -- ***** NEW *****
FETCH DUMMY_CURSOR INTO DUMMY;
IF DUMMY_CURSOR%NOTFOUND THEN
RAISE INVALID_STU;
ELSE
RAISE VALID_STU;
END IF;
CLOSE DUMMY_CURSOR;
EXCEPTION
WHEN INVALID_STU THEN
CLOSE DUMMY_CURSOR;
DBMS_OUTPUT.PUT_LINE ('PLEASE RE-ENTER CLASS ID AND STUDENT ID AS CLASS OR STUDENT IS NOT VALID.');
WHEN VALID_STU THEN
CLOSE DUMMY_CURSOR;
DBMS_OUTPUT.PUT_LINE ('STUDENT CHOOSE SUCCEFULLY!');
WHEN MUTATING_TABLE THEN
DBMS_OUTPUT.PUT_LINE ('MUTATING TABLE'); -- ***** NEW *****
NULL;
END;
Output, when trying to UPDATE class:3 = schosen entering check_schosen
MUTATING TABLE
1 row updated.
Obviously, the trigger fired, since you see the message "3 = schosen entering check_schosen"
Obviously, the OPEN statement raised an error, since you don't see the message 'Cursor is open now.'
Obviously, the mutating table error was raised, since you see the message 'MUTATING TABLE'.
So the trigger fired, and went to the EXCEPTION handler almost immediately. The EXCEPTION handler printed a message, as instructed, and the trigger ended. Then the actual UPDATE took place.
I hope this answers your question.
If not, what is your question? It may be very clear to you, but a complete mystery to others. Ask clear questions, such as "Why did ... happen? I thought ... would happen, be ... as the PL/SQL manual says at ...". -
Clob is not working for bulk data files in PL/SQL XML program
Hi Odie,
we took your help to fix the our issue before
"https://forums.oracle.com/forums/thread.jspa?threadID=2238458&tstart=105"
working fine for : program is working for smaller size data.
Issue : now we have problem with the largr size data .
getting the below error:
Arguments
P_dir_name='/tmp'
P_file_name='CCBGO.COLO_CNG.RESPONSES.20120802.00054131826'
Environment will now switch to UTF-8 code-set.
Parts of this log file may not display correctly
as a result. This is an expected behavior.
XML_REPORTS_XENVIRONMENT is :
/apps/applmgr/product/OFDEV/ofdevora/806/guicommon6/tk60/admin/Tk2Motif_UTF8.rgb
XENVIRONMENT is set to /apps/applmgr/product/OFDEV/ofdevora/806/guicommon6/tk60/admin/Tk2Motif_UTF8.rgb
Current NLS_LANG and NLS_NUMERIC_CHARACTERS Environment Variables are :
American_America.UTF8
stat_low = 8B
stat_high = 0
emsg:was terminated by signal 11
Appreciated for your earlier support.
Kindly suggest .
Many Thanks,
Ramesh.Thanks ALex,
your are true it is concurrent program error ,
but it is working for small amount of data and generating the output and it is not working for larger data.
i have placed the code which i have used kindly suggest where i am going wrong.
i am calling the .rdf through the concurrent program, i've used the below query in RDF
select
BATCHHEADER
,BATCHTRAILER
,RqUID
,Severity
,PmtRefId
,StatusDesc
,ErrorDesc
,AsOfDate
,AsOfTime
,RqUID1
,SPRefId
from table(CL_CXFRFXFH_PKG.rcacknowledgments(:P_dir_name,:P_file_name));
kindly find the below code for the package CL_CXFRFXFH_PKG.
==========================
CREATE OR REPLACE package body APPS.CL_CXFRFXFH_PKG is
function rcacknowledgments (p_directory in varchar2, p_filename in varchar2)
return TRecordTable pipelined
is
nb_rec number := 1;
tmp_xml clob;
tmp_file clob;
rec TRecord;
begin
dbms_lob.createtemporary(tmp_file, true);
tmp_file := dbms_xslprocessor.read2clob(p_directory, p_filename);
rec.BATCHHEADER := regexp_replace(tmp_file, '.*<BATCHHEADER>(.*)</BATCHHEADER>.*', '\1', 1, 1, 'n');
rec.BATCHTRAILER := regexp_replace(tmp_file, '.*<BATCHTRAILER>(.*)</BATCHTRAILER>.*', '\1', 1, 1, 'n');
loop
tmp_xml := regexp_substr(tmp_file, '<\?xml[^?]+\?>\s*<([^>]+)>.*?</\1>', 1, nb_rec, 'n');
exit when length(tmp_xml) = 0;
--dbms_output.put_line(tmp_rec);
nb_rec := nb_rec + 1;
select RqUID, Severity, PmtRefId, StatusDesc, ErrorDesc, AsOfDate, AsOfTime, RqUID1, SPRefId
into rec.RqUID
, rec.Severity
, rec.PmtRefId
, rec.StatusDesc
, rec.ErrorDesc
, rec.AsOfDate
, rec.AsOfTime
, rec.RqUID1
, rec.SPRefId
from xmltable(
'/CMA/BankSvcRq' passing xmltype(tmp_xml)
columns RqUID varchar2(3000) path 'RqUID'
, Severity varchar2(3000) path 'XferAddRs/Status/Severity'
, PmtRefId varchar2(3000) path 'XferAddRs/Status/PmtRefId'
, StatusDesc varchar2(3000) path 'XferAddRs/Status/StatusDesc'
, ErrorDesc varchar2(3000) path 'XferAddRs/Status/ErrorDesc'
, AsOfDate varchar2(3000) path 'XferAddRs/Status/AsOfDate'
, AsOfTime varchar2(3000) path 'XferAddRs/Status/AsOfTime'
, RqUID1 varchar2(3000) path 'XferAddRs/RqUID'
, SPRefId varchar2(3000) path 'XferAddRs/SPRefId'
pipe row ( rec );
end loop;
dbms_lob.freetemporary(tmp_file);
return;
end;
end;
============================================
Many Thanks,
Ramesh. -
HTML not working in PL/SQL block..Help me ASAP
declare
l_col VARCHAR2(30) :=to_number(to_char(to_date('01-feb-2011','dd-mon-yyyy'),'dd'));
CURSOR name_cur IS
select name
from od_shift_schedule
where year=2011
and (month)=('Feb')
and decode(l_col,1,"01",2,"02",3,"03",4,"04",5,"05",6,"06",7,
"07",8,"08",9,"09",10,"10",11,"11",12,"12",13,"13",14,"14",15,"15",16,"16",17,"17",18,"18",19,"19",20,"20",
21,"21",22,"22",23,"23",24,"24",25,"25",26,"26",
27,"27",28,"28",29,"29",30,"30",31,"31")='W';
BEGIN
DELETE FROM nam;
commit;
FOR i IN name_cur
LOOP
dbms_output.put_line(i.name);
htp.p('<b>Employee '||i.name||' has been ticked.
</b><br/>');
EXECUTE IMMEDIATE 'insert into nam(name) values('''||i.name||''')';
commit;
END LOOP;
end;Kindly help me with this
If i'm wrong here kindly help me that how can i place a display messageRe: HTML not working in PL/SQL block..Help me ASAP
Using the community discussion forums for urgent issues is rude and a violation of the terms and conditions.
http://www.oracle.com/html/terms.html
>
4. Use of Community Services
Community Services are provided as a convenience to users and Oracle is not obligated to provide any technical support for, or participate in, Community Services. While Community Services may include information regarding Oracle products and services, including information from Oracle employees, they are not an official customer support channel for Oracle.
You may use Community Services subject to the following: (a) Community Services may be used solely for your personal, informational, noncommercial purposes; (b) Content provided on or through Community Services may not be redistributed; and (c) personal data about other users may not be stored or collected except where expressly authorized by Oracle
>
Also please read the FAQ on how to ask questions.
SQL and PL/SQL FAQ
>
2) Thread Subject line
Give your thread a meaningful subject, not just "help please", "Query help" or "SQL". This is the SQL and PL/SQL forum. We know your question is going to be about those things, make it meaningful to the type of question so that people with the right sort of knowledge can pick it up and those without can ignore it. Never, EVER, mark your subject as "URGENT" or "ASAP"; this forum is manned by volunteers giving their own time to help and your question is never urgent or more important than their own work or than other people's questions. It may be urgent to you, but that's not forum members issue. -
Case statement and Decode function both are not working in Select cursor.
I have tried both the Case statement and Decode function in Select cursor, but both the things are not working. On the other hand both the things work in just select statement.
See the first column in select (PAR_FLAG), I need to have this evaluated along with other fields. Can you please suggest some thing to make this work. And also I would like to
know the reason why decode is not working, I heard some where Case statement do not work with 8i.
Author : Amit Juneja
Date : 06/20/2011
Description:
Updates the Diamond MEMBER_MASTER table with the values from
INC.MEM_NJ_HN_MEMBER_XREF table.
declare
rec_cnt number(12) := 0;
commit_cnt number(4) := 0;
cursor select_cur is
Select DECODE(1,
(Select 1
from hsd_prov_contract R
where R.seq_prov_id = PM.seq_prov_id
and R.line_of_business = H.line_of_business
and R.PCP_FLAG = 'Y'
and R.participation_flag = 'P'
and SYSDATE between R.EFFECTIVE_DATE AND
NVL(R.TERM_DATE,
TO_DATE('31-DEC-9999', 'DD-MON-YYYY'))),
'Y',
'N') PAR_FLAG,
H.SEQ_ELIG_HIST,
H.SEQ_MEMB_ID,
H.SEQ_SUBS_ID,
H.SUBSCRIBER_ID,
H.PERSON_NUMBER,
H.EFFECTIVE_DATE,
H.TERM_DATE,
H.TERM_REASON,
H.RELATIONSHIP_CODE,
H.SEQ_GROUP_ID,
H.PLAN_CODE,
H.LINE_OF_BUSINESS,
H.RIDER_CODE_1,
H.RIDER_CODE_2,
H.RIDER_CODE_3,
H.RIDER_CODE_4,
H.RIDER_CODE_5,
H.RIDER_CODE_6,
H.RIDER_CODE_7,
H.RIDER_CODE_8,
H.MEDICARE_STATUS_FLG,
H.OTHER_STATUS_FLAG,
H.HIRE_DATE,
H.ELIG_STATUS,
H.PREM_OVERRIDE_STEP,
H.PREM_OVERRIDE_AMT,
H.PREM_OVERRIDE_CODE,
H.SEQ_PROV_ID,
H.IPA_ID,
H.PANEL_ID,
H.SEQ_PROV_2_ID,
H.SECURITY_CODE,
H.INSERT_DATETIME,
H.INSERT_USER,
H.INSERT_PROCESS,
H.UPDATE_DATETIME,
H.UPDATE_USER,
H.UPDATE_PROCESS,
H.USER_DEFINED_1,
H.SALARY,
H.PEC_END_DATE,
H.REASON_CODE,
H.PEC_WAIVED,
H.BILL_EFFECTIVE_FROM_DATE,
H.BILLED_THRU_DATE,
H.PAID_THRU_DATE,
H.SUBSC_DEPT,
H.SUBSC_LOCATION,
H.USE_EFT_FLG,
H.BENEFIT_START_DATE,
H.SEQ_ENROLLMENT_RULE,
H.MCARE_RISK_ACCRETION_DATE,
H.MCARE_RISK_DELETION_DATE,
H.MCARE_RISK_REFUSED_DATE,
H.COMMENTS,
H.USER_DEFINED_2,
H.USER_DEFINED_3,
H.RATE_TYPE,
H.PCPAA_OCCURRED,
H.PRIVACY_ON,
H.PCP_CHANGE_REASON,
H.SITE_CODE,
H.SEQ_SITE_ADDRESS_ID,
PM.seq_prov_id rendered_prov
from hsd_member_elig_history H,
INC.PCP_REASSIGN_RPRT_DATA P,
hsd_prov_master PM
where P.subscriber_id = H.subscriber_id
and P.rendered_pcp = PM.provider_ID
and H.elig_status = 'Y'
and (H.term_date is NULL or H.term_date >= last_day(sysdate))
order by H.Seq_memb_id;
begin
for C in select_cur loop
rec_cnt := rec_cnt + 1;
update hsd_member_elig_history
set term_date = TRUNC(SYSDATE - 1),
term_reason = 'PCPTR',
update_datetime = SYSDATE,
update_user = USER,
update_process = 'TD33615'
where seq_elig_hist = C.seq_elig_hist
and seq_memb_id = C.seq_memb_id;
INSERT INTO HSD_MEMBER_ELIG_HISTORY
(SEQ_ELIG_HIST,
SEQ_MEMB_ID,
SEQ_SUBS_ID,
SUBSCRIBER_ID,
PERSON_NUMBER,
EFFECTIVE_DATE,
TERM_DATE,
TERM_REASON,
RELATIONSHIP_CODE,
SEQ_GROUP_ID,
PLAN_CODE,
LINE_OF_BUSINESS,
RIDER_CODE_1,
RIDER_CODE_2,
RIDER_CODE_3,
RIDER_CODE_4,
RIDER_CODE_5,
RIDER_CODE_6,
RIDER_CODE_7,
RIDER_CODE_8,
MEDICARE_STATUS_FLG,
OTHER_STATUS_FLAG,
HIRE_DATE,
ELIG_STATUS,
PREM_OVERRIDE_STEP,
PREM_OVERRIDE_AMT,
PREM_OVERRIDE_CODE,
SEQ_PROV_ID,
IPA_ID,
PANEL_ID,
SEQ_PROV_2_ID,
SECURITY_CODE,
INSERT_DATETIME,
INSERT_USER,
INSERT_PROCESS,
UPDATE_DATETIME,
UPDATE_USER,
UPDATE_PROCESS,
USER_DEFINED_1,
SALARY,
PEC_END_DATE,
REASON_CODE,
PEC_WAIVED,
BILL_EFFECTIVE_FROM_DATE,
BILLED_THRU_DATE,
PAID_THRU_DATE,
SUBSC_DEPT,
SUBSC_LOCATION,
USE_EFT_FLG,
BENEFIT_START_DATE,
SEQ_ENROLLMENT_RULE,
MCARE_RISK_ACCRETION_DATE,
MCARE_RISK_DELETION_DATE,
MCARE_RISK_REFUSED_DATE,
COMMENTS,
USER_DEFINED_2,
USER_DEFINED_3,
RATE_TYPE,
PCPAA_OCCURRED,
PRIVACY_ON,
PCP_CHANGE_REASON,
SITE_CODE,
SEQ_SITE_ADDRESS_ID)
values
(hsd_seq_elig_hist.nextval,
C.SEQ_MEMB_ID,
C.SEQ_SUBS_ID,
C.SUBSCRIBER_ID,
C.PERSON_NUMBER,
trunc(SYSDATE),
C.TERM_DATE,
C.TERM_REASON,
C.RELATIONSHIP_CODE,
C.SEQ_GROUP_ID,
C.PLAN_CODE,
C.LINE_OF_BUSINESS,
C.RIDER_CODE_1,
C.RIDER_CODE_2,
C.RIDER_CODE_3,
C.RIDER_CODE_4,
C.RIDER_CODE_5,
C.RIDER_CODE_6,
C.RIDER_CODE_7,
C.RIDER_CODE_8,
C.MEDICARE_STATUS_FLG,
C.OTHER_STATUS_FLAG,
C.HIRE_DATE,
C.ELIG_STATUS,
C.PREM_OVERRIDE_STEP,
C.PREM_OVERRIDE_AMT,
C.PREM_OVERRIDE_CODE,
C.SEQ_PROV_ID,
C.IPA_ID,
C.PANEL_ID,
C.SEQ_PROV_2_ID,
C.SECURITY_CODE,
SYSDATE,
USER,
'TD33615',
SYSDATE,
USER,
'TD33615',
C.USER_DEFINED_1,
C.SALARY,
C.PEC_END_DATE,
C.REASON_CODE,
C.PEC_WAIVED,
C.BILL_EFFECTIVE_FROM_DATE,
C.BILLED_THRU_DATE,
C.PAID_THRU_DATE,
C.SUBSC_DEPT,
C.SUBSC_LOCATION,
C.USE_EFT_FLG,
C.BENEFIT_START_DATE,
C.SEQ_ENROLLMENT_RULE,
C.MCARE_RISK_ACCRETION_DATE,
C.MCARE_RISK_DELETION_DATE,
C.MCARE_RISK_REFUSED_DATE,
C.COMMENTS,
C.USER_DEFINED_2,
C.USER_DEFINED_3,
C.RATE_TYPE,
C.PCPAA_OCCURRED,
C.PRIVACY_ON,
C.PCP_CHANGE_REASON,
C.SITE_CODE,
C.SEQ_SITE_ADDRESS_ID);
commit_cnt := commit_cnt + 1;
if (commit_cnt = 1000) then
dbms_output.put_line('Committed updates for 1000 records.');
commit;
commit_cnt := 0;
end if;
end loop;
commit;
dbms_output.put_line('Total number of MEMBER_ELIG_HISTROY records inserted : ' ||
rec_cnt);
exception
when others then
raise_application_error(-20001,
'An error was encountered - ' || sqlcode ||
' -error- ' || sqlerrm);
end;user10305724 wrote:
I have tried both the Case statement and Decode function in Select cursor, but both the things are not working. Please define what you mean by not working even if your computer screen is near the internet we can't see it.
You should also look at the FAQ about how to ask a question
SQL and PL/SQL FAQ
Particularly *9) Formatting with {noformat}{noformat} Tags* and posting your version.
know the reason why decode is not working, I heard some where Case statement do not work with 8i.
Does this mean you are using 8i? Then scalar sub queries - selects within the select list, are not supported, along with CASE in PL/SQL.
Select DECODE(1,
* (Select 1
from hsd_prov_contract R
where R.seq_prov_id = PM.seq_prov_id
and R.line_of_business = H.line_of_business
and R.PCP_FLAG = 'Y'
and R.participation_flag = 'P'
and SYSDATE between R.EFFECTIVE_DATE AND
NVL(R.TERM_DATE,
TO_DATE('31-DEC-9999', 'DD-MON-YYYY')))*,
'Y',
'N') PAR_FLAG,
>
exception
when others then
raise_application_error(-20001,
'An error was encountered - ' || sqlcode ||
' -error- ' || sqlerrm);
http://tkyte.blogspot.com/2008/01/why-do-people-do-this.html -
create procedure name emp_test as
cursor c1 is select * from emp where deptno=10;
begin
for i in c1 loop
begin
insert into emp1(col1,col2,col3)value(i.col1,i.col2..........);
exception
when no_data_fund then
dbms_output.put_line( 'no data found from thhis deptno' || i.deptno);
end;
end loop;
end;
my question is, exception is not working when no datafound in my cursor.
Please help me out in this regard.
thanks in advance
Dharma.You are using a for loop, in case no data is found by the cursor c1, the statement in the for loop is not executed so there is no question of exception.
Try the below code, the exception will be raised -
declare
v_cnt number;
begin
select count(*) into v_cnt from emp where deptno=-999;
insert into emp1(col1,col2,col3)value(i.col1,i.col2..........);
exception
when no_data_found then
dbms_output.put_line( 'no data found from thhis deptno' );
end;
Maybe you are looking for
-
I can't open apps on my iPhone. The touch screen doesn't work. I have restored it already but it still won't work. What can I do.
-
My Keynote interactive links don't work in remote mode (ipad to iphone)
I have interactive links to videos that don't work when I am in the remote mode, my ipad is controlling my iphone the is connected to a monitor.
-
No Process Table in Biw 3.5
Hi, I have updated Biw 3.5 with EP 6.0 once after restart I cant get the process table for BIW, But it shows green and process list is running with MSG_Server and En_server. Pls guide me in restoring Process table of BIW Regards, Saravanan
-
Over two weeks and still no phoneline or internet ...
No phone line or internet...Reported fault on 17th December, told would be fixed by 20th December, Called on 20/21 december to be told the fault was LOST in the system they would close it and re open.... told would be fixed by 25th December then told
-
what would be the sufficient tables to check for rights given to other users in the same database or different databases accessing our database through a link. I use 'all_col_privs' for privileges given on columns & 'user_tab_privs' for privileges on