2

Without into tables_found procedure will run but i need to check if this table exist in my database .

CREATE OR replace PROCEDURE dropdb(tables_found out number) IS
    BEGIN                                  
        execute immediate 'SELECT COUNT(*) into tables_found FROM user_tables where table_name=''USERS''';
    if (tables_found = 1) then 
        execute immediate ' drop table users';
    END IF;
END dropdb;

ERROR LOG :

ora-00905 missing keyword

Politank-Z
  • 3,653
  • 3
  • 24
  • 28
gtzinos
  • 1,205
  • 15
  • 27

2 Answers2

0

It must be this

Execute immediate 'SELECT COUNT(*) FROM user_tables where table_name=''USERS'''  into tables_found;

or even better:

Execute immediate 'SELECT COUNT(*) FROM user_tables where table_name=:name'  into tables_found using 'USERS';
Wernfried Domscheit
  • 54,457
  • 9
  • 76
  • 110
0

Try:

execute immediate 'SELECT COUNT(*) into :x FROM user_tables
where table_name=''USERS''' 
USING OUT tables_found ;

If the above will not work, try this:

   execute immediate 'DECLARE x NUMBER; BEGIN SELECT COUNT(*) into x
   FROM user_tables
    where table_name=''USERS'';
    :tables := x END' 
    USING OUT tables_found ;
krokodilko
  • 35,300
  • 7
  • 55
  • 79