Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> IF in PL/SQL-Block

IF in PL/SQL-Block

From: Caja <carsten.jacobs_at_web.de>
Date: 27 Dec 2005 04:41:18 -0800
Message-ID: <1135687278.186346.282240@z14g2000cwz.googlegroups.com>


Hi all,

I have a simple problem but can't get it fixed. I want to execute an DELETE-statement only if a certain table (order) exists.
The following PL/SQL-Block in an .sql-file runs always into the IF -body.
What is wrong with it?

DECLARE
        amount NUMBER;
BEGIN

        amount := 0;
        -- only database, which includes the table 'order'

        SELECT count(*)
        INTO amount
        FROM all_tables
        WHERE lower(table_name) = 'order';

        IF amount = 1 THEN
                DELETE FROM order WHERE delivered = 0;
                COMMIT;
        END IF;

END; Thanx for any help

Carsten Received on Tue Dec 27 2005 - 06:41:18 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US