Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 8 of 8 total
Thread Creating a table in a different Database within a procedure
Sun, Apr 6 2008 4:06 AMPermanent Link

Uli Becker
Hi,

I want to create a table in a memory-database if it doesn't exist.
Use MemoryDB is obviously not allowed in procedures. So: how can I do that?

BEGIN
 DECLARE Result CURSOR with Return for Stmt;
 Prepare Stmt from 'select name from MemoryDb.Information.Tables
   where name = ''PrintRechnungenCopies''';
 Open Result;
 if RowsAffected(Stmt) = 1 then
    Execute Immediate 'delete from MemoryDB.PrintRechnungenCopies';
 ELSE
   USE MemoryDB;   <-------------------------------------------------------------
   Execute Immediate 'Create Table PrintRechnungenCopies as
     select * from Informa.PrintRechnungen';
 end if;
END

Thanks. Uli.
Sun, Apr 6 2008 5:37 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Uli


I learnt this one a while back Smiley Essentially a CREATE TABLE statement can ONLY be run from a script that has the appropriate database set.

Set the databasename at the component level to the memory database then reference all other db's you use within the script apart from the memory db.

So your    USE MemoryDB;  is there - sort of - but can't be set from within a procedure.

Rather badly explained but I hope it helps.

Roy Lambert [Team Elevate]
Sun, Apr 6 2008 5:42 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Uli


I've just read another post from Tim and USE database is there, so I think we need Tim to clarify.

Roy Lambert [Team Elevate]
Sun, Apr 6 2008 6:33 AMPermanent Link

Uli Becker
Roy,

> I learnt this one a while back Smiley Essentially a CREATE TABLE statement can ONLY be run from a script that has the appropriate database set.
> So your    USE MemoryDB;  is there - sort of - but can't be set from within a procedure.

I know all that. The point is that it must be possible to create an
In-Memory-Table within a procedure of a non-memory database.
Tim will tell us how it works, I hope.

Regards Uli
Mon, Apr 7 2008 6:24 AMPermanent Link

"Jose Eduardo Helminsky"
Uli

I had asked the same question.
See the thread DBISAM -> ElevateDB posted in NG elevatedb.general (04/04/08)

Eduardo

Mon, Apr 7 2008 7:10 AMPermanent Link

Uli Becker
Jose,

> I had asked the same question.
> See the thread DBISAM -> ElevateDB posted in NG elevatedb.general (04/04/08)

I read that, but the difference is, that you are using a script and want
to use a procedure. Smile

Regards Uli
Mon, Apr 7 2008 1:04 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Uli,

<< I know all that. The point is that it must be possible to create an
In-Memory-Table within a procedure of a non-memory database.Tim will tell us
how it works, I hope. >>

No, you cannot do so.  For stored procedures, you should use a temporary
table instead of an in-memory table if you want a temporary table.  Any
objects contained with a specific database and catalog can only access
objects within that same database catalog.

Scripts and jobs are not catalog-level objects, so they can use the USE
statement to access multiple databases.  The upcoming session-level
procedures and functions that Roy asked for will also be able to use the USE
statement.

--
Tim Young
Elevate Software
www.elevatesoft.com

Tue, Apr 8 2008 6:28 AMPermanent Link

"Uli Becker"
Tim,

> No, you cannot do so.  For stored procedures, you should use a temporary
> table instead of an in-memory table if you want a temporary table.  Any
> objects contained with a specific database and catalog can only access
> objects within that same database catalog.

Thanks for the clarification.

Regards Uli
Image