I have to call a procedure ("B") (in Oracle 10g) within a procedure ("A") with an if-condition. But I can't get it work.
Procedure "B" collects data from several tables and writes it to an xml-file. If I call "B" without condition, it writes the file. But it writes the file (with the xml-Header) wether there is data or not. So I need the if-condition to check for data.
The code:
CREATE OR REPLACE PROCEDURE A
AS
l_count varchar2(3);
CURSOR c_EXISTSDATA IS
select count(*) into l_count from bv.history where upddate > sysdate -.015 and tabelle = 'MEDIEN' and userid != 'DATENTAUSH';
BEGIN
IF (l_count != 0)
THEN
B;
END IF;
END;
/
With this if-condition there is not output at all - also if l_count !=0. What is wrong here?
Thank's for help! Regards Christoph
VARCHAR2
is not a good choice for storing numeric data. I suggest that you define l_count
using the data type NUMBER
. Furthermore, you define a cursor but you never execute it. You might try:
CREATE OR REPLACE PROCEDURE A
AS
l_count NUMBER;
BEGIN
select count(*)
into l_count
from bv.history
where upddate > sysdate - INTERVAL '20' MINUTE and
tabelle = 'MEDIEN' and
userid != 'DATENTAUSH';
IF l_count != 0 THEN
B;
END IF;
END;
I'm not sure what time interval you meant by 0.015
. That equates to 21.6 minutes, so I changed it to the (clearer) INTERVAL '20' MINUTE
. Adjust as necessary.
I think you'll find this works better.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.