Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Create memory table
Mon, Apr 14 2008 12:41 PMPermanent Link

"Jose Eduardo Helminsky"
Tim

Memory.Execute('create table x as select * from table2 with data');

DBISAM override the table x if it already exists. ElevateDB will raise an
error if x alread exists.

try
  Memory.Execute('drop table x');
except
  // Do nothing
end;
Memory.Execute('create table x as select * from table2 with data');

Is there another way to migrate a lot of scripts from DBISAM to ElevateDB ?

Eduardo

Mon, Apr 14 2008 2:13 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Jose


This is something Tim sent me with a bit of a mod (I think)

-----------------------------------------------------------------------------------------------------------------------
SCRIPT (IN SQLStatement VARCHAR, IN TableName VARCHAR, IN IdxSet VARCHAR)
BEGIN     
DECLARE InfoCursor SENSITIVE CURSOR FOR InfoStmt;
DECLARE ResultCursor SENSITIVE CURSOR WITH RETURN FOR ResultStmt;

PREPARE InfoStmt FROM 'SELECT * FROM Information.Tables WHERE Name=?';
OPEN InfoCursor USING TableName;

IF (ROWCOUNT(InfoCursor) > 0) THEN
 EXECUTE IMMEDIATE 'DROP TABLE "'+TableName+'"';
END IF;

CLOSE InfoCursor;

PREPARE ResultStmt FROM 'CREATE TABLE "'+TableName+'" AS '+SQLStatement+' WITH DATA';
EXECUTE ResultStmt;

IF IdxSet IS NOT NULL THEN
 PREPARE ResultStmt FROM 'CREATE INDEX Idx ON "'+TableName+'"('+IdxSet+')';
 EXECUTE  ResultStmt;
END IF;
END
-----------------------------------------------------------------------------------------------------------------------

It works well and could be extended to analyse the statement you stuff in to extract the table name. In the example you quote you'd pass the parameters as

ParamByName('SQLStatement').AsString := 'select * from table2 with data';
ParamByName('TableName').AsString := 'x';
ParamByName('IdxSet').AsString := '';

and ExecScript.

Roy Lambert [Team Elevate]
Mon, Apr 14 2008 4:41 PMPermanent Link

"Jose Eduardo Helminsky"
Roy

I really appreciate your help.
I think it will help me a lot in my DBISAM -> ElevateDB migration.

Eduardo

Image