ColdFusion cfquery and Oracle Temporary Tables

2011-03-17 Thread Chester Austin

I am running ColdFusion 8 and Oracle 10g.

I am running three stored procedures to insert data into three separate 
temporary tables.  From there, I run a union statement to against the three 
temporary tables and output out the results.  However, I am running into an 
unexpected error:

Stored Procedure A writes to Temporary Table A, Stored Procedure B writes to 
Temporary Table B, Stored Procedure C writes to Temporary Table C.

Query 1 performs a select union on TTA, TTB, and TTC.  Depending on some logic, 
Stored Procedure A, B, or C may or may not run and therefore, TTA, TTB, or TTC 
SHOULD be empty.  However, it is not.  I am sure that these tables are 
temporary and are created as a global temporary table.

Any help is greatly appreciated.  Please let me know if more information 
needed. 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:343111
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Temporary Tables

2008-09-22 Thread Robert Rawlins
Guys,

 

I'm looking to run a query which creates a SQL Server temporary table. This
has got me a little confused as the SQL requires to have a # in the midst of
it to create the table.

 

What's the correct syntax for this? Do I use a double ## or a triple ###?

 

For instance, if I have a query like so:

 

  cfquery name=LOCAL.qCreate datasource=MyDSN

CREATE TABLE ##MessageStaging (

 

Is that creating a temp table? Of is the ## just an nonexistent value and
its creating a physical table?

 

I'd appreciate your thoughts guys,

 

Robert



~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312886
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: Temporary Tables

2008-09-22 Thread Dawson, Michael
For each #, you will need two ##.  So, you need CREATE TABLE  for it
to create your temp table.

The easy way to determine is to look at the data dictionary in your
database server.

Use CFDBINFO, for example, if you have CF8.

Mike

-Original Message-
From: Robert Rawlins [mailto:[EMAIL PROTECTED] 
Sent: Monday, September 22, 2008 6:12 AM
To: CF-Talk
Subject: Temporary Tables

Guys,

 

I'm looking to run a query which creates a SQL Server temporary table.
This has got me a little confused as the SQL requires to have a # in the
midst of it to create the table.

 

What's the correct syntax for this? Do I use a double ## or a triple
###?

 

For instance, if I have a query like so:

 

  cfquery name=LOCAL.qCreate datasource=MyDSN

CREATE TABLE ##MessageStaging (

 

Is that creating a temp table? Of is the ## just an nonexistent value
and its creating a physical table?

 

I'd appreciate your thoughts guys,

 

Robert

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312891
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: CF and SQL Server temporary tables

2008-04-18 Thread James Holmes
That's my understanding too - CF gets a connection from the pool on
the first query in a request and keeps that connection for the
duration of the request, using it for all subsequent queries.

On Fri, Apr 18, 2008 at 1:09 PM, Dave Watts [EMAIL PROTECTED] wrote:
  It's entirely possible for a CF page to change connections in
   the middle of processing a request, and therefore lose sight
   of the temp table.

  Actually, I don't think that's possible. My understanding is that a
  connection used by a page is retained by the page for the duration of its
  execution.

-- 
mxAjax / CFAjax docs and other useful articles:
http://www.bifrost.com.au/blog/

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:303721
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: CF and SQL Server temporary tables

2008-04-18 Thread Mark Kruger
I'm with Dave... The connection persists for the length of the request. I
wonder however about scoping and components. For example, what if I did the
following:

1)   createobject(component,com.dbObj).createTempTable() 

2)
createobject(component,com.dbObj).getDataFromTempTable(firstname='Bob');


Could  the second instantiation of the object result in the use of a
different connection? Since the scope is sort of agnostic of the request I
wonder if that would be the case. It might be interesting to find out.



-Mark


Mark A. Kruger, CFG, MCSE
(402) 408-3733 ext 105
www.cfwebtools.com
www.coldfusionmuse.com
www.necfug.com

-Original Message-
From: Dave Watts [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 18, 2008 12:09 AM
To: CF-Talk
Subject: RE: CF and SQL Server temporary tables

 It's entirely possible for a CF page to change connections in the 
 middle of processing a request, and therefore lose sight of the temp 
 table.

Actually, I don't think that's possible. My understanding is that a
connection used by a page is retained by the page for the duration of its
execution.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Training: Adobe/Google/Paperthin Certified Partners
http://training.figleaf.com/

WebManiacs 2008: the ultimate conference for CF/Flex/AIR developers!
http://www.webmaniacsconference.com/



~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:303725
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


RE: CF and SQL Server temporary tables

2008-04-18 Thread Brad Wood
This topic came up back in December.  Read this post here:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:265101

Jochem clarified that Adobe ColdFusion does maintain the same connection
for the duration of a page, but one should not rely on that behavior
since it is un-documented.  Furthermore, alternative CFML engines like
BlueDragon don't follow the same behavior.  If you want to be sure your
code will be 1) portable and 2) forward compatible, use a cftransaction
to force it to reuse the same connection.

~Brad

-Original Message-
From: James Holmes [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 18, 2008 2:02 AM
To: CF-Talk
Subject: Re: CF and SQL Server temporary tables

That's my understanding too - CF gets a connection from the pool on
the first query in a request and keeps that connection for the
duration of the request, using it for all subsequent queries.

On Fri, Apr 18, 2008 at 1:09 PM, Dave Watts [EMAIL PROTECTED] wrote:
  It's entirely possible for a CF page to change connections in
   the middle of processing a request, and therefore lose sight
   of the temp table.

  Actually, I don't think that's possible. My understanding is that a
  connection used by a page is retained by the page for the duration of
its
  execution.

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:303758
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


CF and SQL Server temporary tables

2008-04-17 Thread Rick Root
so I have a question about temporary tables in SQL Server 2005.

From the SQL Server documentation for CREATE TABLE:

You can create local and global temporary tables. Local temporary tables are
visible only in the current session, and global temporary tables are visible
to all sessions. Temporary tables cannot be partitioned.

Prefix local temporary table names with single number sign (#*table_name*),
and prefix global temporary table names with a double number sign (##*
table_name*).
What exactly does current session mean as it applies to a Coldfusion
request?  The life of the request?  the life of the transaction, if any?
The life of the executing query?  Or, since CF maintains the database
connection between requests, and pools connections, how does that affect
things?

I'm hoping that each cf request is a separate session as far as SQL Server
is concerned.

Thanks!

Rick


-- 
Rick Root
New Brian Vander Ark Album, songs in the music player and cool behind the
scenes video at www.myspace.com/brianvanderark


~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:303662
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: CF and SQL Server temporary tables

2008-04-17 Thread James Smith
If I remember correctly if you have CF maintaining connections your
temp table will hang around almost indefinitely, best practice would
be to DROP it once you are done with it.

Also worth noting that if the page that creates the table can be
called multiple times simultaneously (by different users of the system
for example) then the second request will fail and error on you
because the table has already been created.

If you need a truly temporary table you could lock the database (to
prevent other requests getting in the way) create the table, do what
you need it for, then drop the table and unlock the database.  If the
table will hold data needed by multiple requests I would look at some
way of creating a permanent table and managing the data across
requests.

--
Jay

On Thu, Apr 17, 2008 at 1:13 PM, Rick Root [EMAIL PROTECTED] wrote:
 so I have a question about temporary tables in SQL Server 2005.

  From the SQL Server documentation for CREATE TABLE:

  You can create local and global temporary tables. Local temporary tables are
  visible only in the current session, and global temporary tables are visible
  to all sessions. Temporary tables cannot be partitioned.

  Prefix local temporary table names with single number sign (#*table_name*),
  and prefix global temporary table names with a double number sign (##*
  table_name*).
  What exactly does current session mean as it applies to a Coldfusion
  request?  The life of the request?  the life of the transaction, if any?
  The life of the executing query?  Or, since CF maintains the database
  connection between requests, and pools connections, how does that affect
  things?

  I'm hoping that each cf request is a separate session as far as SQL Server
  is concerned.

  Thanks!

  Rick


  --
  Rick Root
  New Brian Vander Ark Album, songs in the music player and cool behind the
  scenes video at www.myspace.com/brianvanderark


  

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:303663
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: CF and SQL Server temporary tables

2008-04-17 Thread Rick Root
On Thu, Apr 17, 2008 at 8:38 AM, James Smith [EMAIL PROTECTED]
wrote:

 If I remember correctly if you have CF maintaining connections your
 temp table will hang around almost indefinitely, best practice would
 be to DROP it once you are done with it.


 Well I did some tests... and I determined that the table *DOES* get
deleted at the end of the request... that's good.  Basically I ran a query
that created a temp table, then I ran another request that selected from
that temp table and it wasn't there .. so either it got deleted at the end
of the request, *OR* the second request was a separate session and thus CF
couldn't see the original temp table.

Either way, that's good.

rick


~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:303664
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: CF and SQL Server temporary tables

2008-04-17 Thread Don L
On Thu, Apr 17, 2008 at 8:38 AM, James Smith [EMAIL PROTECTED]
wrote:

 If I remember correctly if you have CF maintaining connections your
 temp table will hang around almost indefinitely, best practice would
 be to DROP it once you are done with it.


 Well I did some tests... and I determined that the table *DOES* get
deleted at the end of the request... that's good.  Basically I ran a query
that created a temp table, then I ran another request that selected from
that temp table and it wasn't there .. so either it got deleted at the end
of the request, *OR* the second request was a separate session and thus CF
couldn't see the original temp table.

Either way, that's good.

rick

For temporary data manipulation, in general, variable table, is more 
efficient than creating temporary tables, however, there are two exceptions 
where one can't use this technique.  You may consider BOL for more detail.


~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:303673
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: CF and SQL Server temporary tables

2008-04-17 Thread Jaime Metcher
It's entirely possible for a CF page to change connections in the middle of
processing a request, and therefore lose sight of the temp table.  It's also
possible for the new connection to be one that was previously used by
another invocation of the same page, producing the problem that James
mentions.

You can avoid both of these problems by wrapping the relevant code in a
cftransaction - the transaction binds the connection to the CF thread -
but, like all locking, you have to consider the impact on throughput.

Jaime Metcher

 -Original Message-
 From: James Smith [mailto:[EMAIL PROTECTED]
 Sent: Thursday, 17 April 2008 10:38 PM
 To: CF-Talk
 Subject: Re: CF and SQL Server temporary tables


 If I remember correctly if you have CF maintaining connections your
 temp table will hang around almost indefinitely, best practice would
 be to DROP it once you are done with it.

 Also worth noting that if the page that creates the table can be
 called multiple times simultaneously (by different users of the system
 for example) then the second request will fail and error on you
 because the table has already been created.

 If you need a truly temporary table you could lock the database (to
 prevent other requests getting in the way) create the table, do what
 you need it for, then drop the table and unlock the database.  If the
 table will hold data needed by multiple requests I would look at some
 way of creating a permanent table and managing the data across
 requests.

 --

 Jay

 On Thu, Apr 17, 2008 at 1:13 PM, Rick Root
 [EMAIL PROTECTED] wrote:
  so I have a question about temporary tables in SQL Server 2005.
 
   From the SQL Server documentation for CREATE TABLE:
 
   You can create local and global temporary tables. Local
 temporary tables are
   visible only in the current session, and global temporary
 tables are visible
   to all sessions. Temporary tables cannot be partitioned.
 
   Prefix local temporary table names with single number sign
 (#*table_name*),
   and prefix global temporary table names with a double number sign (##*
   table_name*).
   What exactly does current session mean as it applies to a Coldfusion
   request?  The life of the request?  the life of the
 transaction, if any?
   The life of the executing query?  Or, since CF maintains the database
   connection between requests, and pools connections, how does
 that affect
   things?
 
   I'm hoping that each cf request is a separate session as far
 as SQL Server
   is concerned.
 
   Thanks!
 
   Rick
 
 
   --
   Rick Root
   New Brian Vander Ark Album, songs in the music player and cool
 behind the
   scenes video at www.myspace.com/brianvanderark
 
 
 

 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:303698
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


RE: CF and SQL Server temporary tables

2008-04-17 Thread Dave Watts
 It's entirely possible for a CF page to change connections in 
 the middle of processing a request, and therefore lose sight 
 of the temp table.

Actually, I don't think that's possible. My understanding is that a
connection used by a page is retained by the page for the duration of its
execution.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Training: Adobe/Google/Paperthin Certified Partners
http://training.figleaf.com/

WebManiacs 2008: the ultimate conference for CF/Flex/AIR developers!
http://www.webmaniacsconference.com/

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:303715
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


SOT: Temporary tables in SQL2K

2002-11-05 Thread A.Little
Hi all,

I'm writing a stored procedure (in SQL Server 2K) in which I need to create
a couple of temporary tables (which are dropped when the sp has completed).

How do I get around the fact that 2 users of the website may run the sp at
(precisely) the same time, creating the possibility that one of the sp's
drops the temp table before the other has finished with it.

The SQL documentation refers to the fact that each 'connection' will create
it's own copy of the temp table - avoiding the problem above, but when the
db is connected to the website, I only have the one connection between CF
and SQL, so the problem may occur - or will it?

Does anyone have any advice/best practice for this situation?

thanks,

Alex
~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm



RE: Temporary tables in SQL2K

2002-11-05 Thread A.Little
Nevermind, I've found I can use the TABLE variable type in my sp so the
table is only created locally to the sp (btw, this is new to SQL2K).

Any advice/experience on the performance of this would still be appreciated,

Alex

 
 I'm writing a stored procedure (in SQL Server 2K) in which I 
 need to create
 a couple of temporary tables (which are dropped when the sp 
 has completed).
 
 How do I get around the fact that 2 users of the website may 
 run the sp at
 (precisely) the same time, creating the possibility that one 
 of the sp's
 drops the temp table before the other has finished with it.
 
 The SQL documentation refers to the fact that each 
 'connection' will create
 it's own copy of the temp table - avoiding the problem above, 
 but when the
 db is connected to the website, I only have the one 
 connection between CF
 and SQL, so the problem may occur - or will it?
 
 Does anyone have any advice/best practice for this situation?
 

~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm



RE: Temporary tables in SQL2K

2002-11-05 Thread Andy Clary
We use table variables extensively in our sp's.  They seem to work quite
nicely.  Also, bol (books online) mentions that they perform better than
temp tables.

Andy

-Original Message-
From: A.Little [mailto:A.Little;open.ac.uk]
Sent: Tuesday, November 05, 2002 2:43 AM
To: CF-Talk
Subject: RE: Temporary tables in SQL2K


Nevermind, I've found I can use the TABLE variable type in my sp so the
table is only created locally to the sp (btw, this is new to SQL2K).

Any advice/experience on the performance of this would still be appreciated,

Alex

 
 I'm writing a stored procedure (in SQL Server 2K) in which I 
 need to create
 a couple of temporary tables (which are dropped when the sp 
 has completed).
 
 How do I get around the fact that 2 users of the website may 
 run the sp at
 (precisely) the same time, creating the possibility that one 
 of the sp's
 drops the temp table before the other has finished with it.
 
 The SQL documentation refers to the fact that each 
 'connection' will create
 it's own copy of the temp table - avoiding the problem above, 
 but when the
 db is connected to the website, I only have the one 
 connection between CF
 and SQL, so the problem may occur - or will it?
 
 Does anyone have any advice/best practice for this situation?
 


~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at http://www.coolfusion.com



RE: Temporary Tables

2002-05-19 Thread jgeorges

Josh,



Eventually as in the current connection.



Thanks for the detailed response.



Sam









--- On Sat 05/18, Joshua Tipton  wrote:

 Eventually as in the current connection or eventually as in sometime this

 week?

 

 Temp table straight out of books online

 

 You can create local and global temporary tables. Local temporary tables

 are

 visible only in the current session; global temporary tables are visible

 to

 all sessions.

 






Visit iWon.com - the Internet's largest guaranteed cash giveaway!
__
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



Temporary Tables

2002-05-18 Thread jgeorges

I am building records from several datasources.  I would like to save the data in a 
temporary table which I will eventually query and pass the query results to CFX_Excel 
to create an xls file.



I am using Cold Fusion 5.  My datasources are SQL Server databases.



What are my options for saving the data that I can eventually query using CFQUERY?



TIA,



Sam










Visit iWon.com - the Internet's largest guaranteed cash giveaway!
__
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Temporary Tables

2002-05-18 Thread Joshua Tipton

Eventually as in the current connection or eventually as in sometime this
week?

Temp table straight out of books online

You can create local and global temporary tables. Local temporary tables are
visible only in the current session; global temporary tables are visible to
all sessions.

Prefix local temporary table names with single number sign (#table_name),
and prefix global temporary table names with a double number sign
(##table_name).

SQL statements reference the temporary table using the value specified for
table_name in the CREATE TABLE statement:

CREATE TABLE #MyTempTable (cola INT PRIMARY KEY)
INSERT INTO #MyTempTable VALUES (1)

If a local temporary table is created in a stored procedure or application
that can be executed at the same time by several users, SQL Server has to be
able to distinguish the tables created by the different users. SQL Server
does this by internally appending a numeric suffix to each local temporary
table name. The full name of a temporary table as stored in the sysobjects
table in tempdb consists of table name specified in the CREATE TABLE
statement and the system-generated numeric suffix. To allow for the suffix,
table_name specified for a local temporary name cannot exceed 116
characters.

Temporary tables are automatically dropped when they go out of scope, unless
explicitly dropped using DROP TABLE: 

A local temporary table created in a stored procedure is dropped
automatically when the stored procedure completes. The table can be
referenced by any nested stored procedures executed by the stored procedure
that created the table. The table cannot be referenced by the process which
called the stored procedure that created the table.


All other local temporary tables are dropped automatically at the end of the
current session.


Global temporary tables are automatically dropped when the session that
created the table ends and all other tasks have stopped referencing them.
The association between a task and a table is maintained only for the life
of a single Transact-SQL statement. This means that a global temporary table
is dropped at the completion of the last Transact-SQL statement that was
actively referencing the table when the creating session ended. 
A local temporary table created within a stored procedure or trigger is
distinct from a temporary table with the same name created before the stored
procedure or trigger is called. If a query references a temporary table, and
two temporary tables with the same name exist at that time, it is not
defined which table the query is resolved against. Nested stored procedures
can also create temporary tables with the same name as a temporary table
created by the stored procedure that called it. All references to the table
name in the nested stored procedure are resolved to the table created in the
nested procedure, for example:

CREATE PROCEDURE Test2
AS
CREATE TABLE #t(x INT PRIMARY KEY)
INSERT INTO #t VALUES (2)
SELECT Test2Col = x FROM #t
GO
CREATE PROCEDURE Test1
AS
CREATE TABLE #t(x INT PRIMARY KEY)
INSERT INTO #t VALUES (1)
SELECT Test1Col = x FROM #t
EXEC Test2
GO
CREATE TABLE #t(x INT PRIMARY KEY)
INSERT INTO #t VALUES (99)
GO
EXEC Test1
GO

Here is the result set:

(1 row(s) affected)

Test1Col
--- 
1   

(1 row(s) affected)

Test2Col
--- 
2   

When you create local or global temporary tables, the CREATE TABLE syntax
supports constraint definitions with the exception of FOREIGN KEY
constraints. If a FOREIGN KEY constraint is specified in a temporary table,
the statement returns a warning message indicating that the constraint was
skipped, and the table is still created without the FOREIGN KEY constraints.
Temporary tables cannot be referenced in FOREIGN KEY constraints.

Consider using table variables instead of temporary tables. Temporary tables
are useful in cases when indexes need to be created explicitly on them, or
when the table values need to be visible across multiple stored procedures
or functions. In general, table variables contribute to more efficient query
processing. For more information, see table.


Josh

-Original Message-
From: jgeorges [mailto:[EMAIL PROTECTED]] 
Sent: Saturday, May 18, 2002 7:13 PM
To: CF-Talk
Subject: Temporary Tables

I am building records from several datasources.  I would like to save the
data in a temporary table which I will eventually query and pass the query
results to CFX_Excel to create an xls file.



I am using Cold Fusion 5.  My datasources are SQL Server databases.



What are my options for saving the data that I can eventually query using
CFQUERY?



TIA,



Sam










Visit iWon.com - the Internet's largest guaranteed cash giveaway!

__
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
FAQ