0

i need to confirm the table is present in the db before select operation .

here is my code ,

 set @table_name_count = CONCAT('SELECT COUNT(*) into @xcount  FROM '  , table_name, ' where issueNumber=','30030',' and ISSNcode=','112640402');
     select 'hellooo3' from dual; 
     PREPARE statement from @table_name_count;
     EXECUTE statement;
     DEALLOCATE PREPARE statement;
     select 'hello4' from dual;
     select @xcount AS xcount;
     IF @xcount > 0 and  THEN
       DELETE from table_name where issueNumber='30030' and ISSNcode='112640402' ;
     END IF  ;

how can i confirm the table is present in db without creating it and need to return a boolen or some int value to show the status .

user1703145
  • 165
  • 1
  • 4
  • 13
  • What?!? A schema that can't be relied upon? Rubbish! In any case, see http://stackoverflow.com/questions/1525784/mysql-check-if-a-table-exists-without-throwing-an-exception – user2864740 Jan 10 '14 at 07:55
  • (Also, since this is for a "dynamic" table_name, consider using a [*whitelist*](http://en.wikipedia.org/wiki/Whitelist) to limit which tables - that should exist! - can be used.) – user2864740 Jan 10 '14 at 07:58

0 Answers0