I haven't tried this,

but maybe if you write a stored proc to return a flag to CF,

<CFSTOREDPROC 
                PROCEDURE="p_FlagTableExistence" 
                DATASOURCE="#REQUEST.dsn#" 
                USERNAME="#REQUEST.user#" 
                PASSWORD="#REQUEST.key#">
                        
                        <CFPROCPARAM DBVARNAME="@EXFlag"
CFSQLTYPE="CF_SQL_INTEGER" TYPE="OUT" VARIABLE="EXFlag">
</CFSTOREDPROC>

///THEN YOUR PROC

CREATE PROCEDURE p_FlagTableExistence

(
@EXFlag int OUT
)

AS

SELECT TOP 1 TableID
FROM    TABLENAME
ORDER BY TableID DESC

IF @@ERROR <> 0
        BEGIN
                //table does not exit
                @EXFlag = 1
                //or instead of sending a flag write your sql to create the
table if thats what you want to do
        END
IF @@ERROR <> 1
        BEGIN
                //table does exit
                @EXFlag = 0
        END

This is of course you want to keep your error handling inside SQL,

or just use try and catch in CF,


-----Original Message-----
From: Jason Congerton - Mcaonline
[mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 22, 2002 1:52 PM
To: CF-Talk
Subject: Check for table existence??


Dear ALL

 
A bit new to all this..

Can you check to see if a table exists within a database with cold fusion?
If so can someone tell me how please.

The reason for this, is one part of my database copies a table into another
which is name uniquley by a the users id, however this table needs to be
deleted once the user has logged off, problem being if the user does not log
off correctly the table will still be there, so I need to be check for
existence and delete at the logon stage.

Regards


Jason


This e-mail and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
[EMAIL PROTECTED]

Whilst every endeavour is taken to ensure that e-mails are free from
viruses, no liability can be accepted and the recipient is requested
to use their own virus checking software.



______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to