On 06/07/2012 6:33 PM, Albert Berry wrote:
I use this construct
SELECT COUNT(*) INTO vCount from sys_tables WHERE sys_table_name =
'table'
If vcount > *0* then
drop table table
endif
Albert
On 06/07/2012 1:48 PM, Mike Byerley wrote:
I always just do:
Set Error Variable vERR
set var vIntErr Integer = 0
list table Tablename
set var vIntErr = .vERR
Then check the value of .vIntErr for non zero
----- Original Message -----
From: "Jason Kramer" <[email protected]>
To: "RBASE-L Mailing List" <[email protected]>
Sent: Friday, July 06, 2012 1:52 PM
Subject: [RBASE-L] - CHKTABLE
: Over the years, I have noticed several people asking for a way
to check
for the existence of a table along the likes of the CHKFILE function. I
wrote a stored procedure that will check for a table and return a 1
or a 0
if it exists or not. Since it returns a value, it can be used in an IF
statement (IF (CALL CHKTABLE('tablename')) = 1 THEN...). I'll paste the
code below. It is not terribly original, but someone may find it
useful.
If you use it, you will need to set vctocheck TEXT 128 as the only
argument
(table names in 9.5 x64 max out at 128 characters, if you are using
another
version adjust as necessary), and the return value as an integer.
:
: -- CHKTABLE Stored Procedure
: -- Jason Kramer
: -- 07-05-2012
:
: -- This RMD file is used by the CHKTABLE stored procedure (SP). It
requires
: -- one parameter, the table name to check, and returns a 0 (not
found) or
a 1
: -- (found).
:
: -- Required parameter - vctocheck TEXT - the name to check.
:
: -- Return value - 0 or 1:
: -- 0 - Table does not exist.
: -- 1 - Table exists.
:
: SET VAR vctretval INTEGER = NULL
:
: SELECT COUNT sys_table_name INTO vctretval FROM sys_tables WHERE
sys_table_name = .vctocheck
:
: RETURN .vctretval
:
: Jason Kramer
: University Archives and Records Management
: 002 Pearson Hall
: (302) 831 - 3127 (voice)
: (302) 831 - 6903 (fax)
-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2012.0.2195 / Virus Database: 2437/5114 - Release Date:
07/06/12
-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2012.0.2195 / Virus Database: 2437/5114 - Release Date: 07/06/12