Simple query concat quotes question
Posted on 2006-11-06
I am trying a fairly simple thing in pl/sql (oracle 9i). I need to check if a table exist or not. If is does then do some stuff else email user.
The problem is with the quotes around the string. my query is
SELECT COUNT(*) into tblYesNo FROM sys.all_objects WHERE object_type = 'TABLE' AND object_name = || CHR(39) || MY_TABLE || CHR(39) AND owner = CHR(39) || MY_OWNER || CHR(39);
Here tblYesNo, MY_TABLE, MY_OWNER are all variables and are being passed to this statement. As you know for comparison in where clause they should be concatinated with the quote e.g.'name'. I am not sure what is the way to concatinate a quote on both left and right side of my variable. I tried using its ASSI code which is CHR(39). It show correct statement when i debut.print but my statement returns nothing i.e. 0
Also is ther a way to get the date when a table was last analyzed if at all ?
what should i do. Please suggest.