Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread TEDBQuery - multiple statements
Mon, Jul 7 2008 11:17 AMPermanent Link

Marcin
Hi

In DBISAM 4 I was able to execute query:

   INSERT INTO sources (source_name) VALUES ('test');
   SELECT MAX(source_id) FROM sources;

It allowed me to insert new row and return value of newly inserted column (source_id
column is autoincremented).
From documentation "The TEDBQuery component encapsulates a single SQL statement in
ElevateDB" and I cannot execute above query. Instead I have to execute 2 queries or use
TEDBStoreProc. With approach is more effective (it has to be speed optimized) or maybe
there is another better one?

Marcin
Mon, Jul 7 2008 11:36 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Marcin


You could use a TEDBScript. But it would help us give advice if we knew what it was you were trying to achieve.

Roy Lambert [Team Elevate]
Mon, Jul 7 2008 12:00 PMPermanent Link

Marcin
Roy,

I have really simple dictionary table:

CREATE TABLE sources (
        source_id INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 0, INCREMENT BY 1),
        source_name varchar(200),
          PRIMARY KEY (source_id)
  )

I want to insert a row into this table (just name of new source) and get value of
source_id column for this new row.
Mon, Jul 7 2008 12:10 PMPermanent Link

"Uli Becker"
Marcin,

if you use a script or a stored procdure you can use a param to get the new
ID returned.

Have a look here:
http://www.elevatesoft.com/newsgrp?action=openmsg&group=17&msg=1433&page=2#msg1433

Uli

Mon, Jul 7 2008 12:28 PMPermanent Link

Marcin
Thank you Uli

This is what I was looking for.

Marcin.
Mon, Jul 7 2008 1:50 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Marcin,

<< With approach is more effective (it has to be speed optimized) or maybe
there is another better one? >>

A script is most likely what you want.  However, a good tip to remember is
that you can load your old DBISAM-style scripts into a new script in the
ElevateDB Manager, and then select Script from the main menu, and then
Convert into Script from the Script menu, and it will automatically convert
your DBISAM-style script into an ElevateDB script.

Of course, in this case it is much more efficient to use an input/output
parameter as Uli indicated in the link he included, as opposed to a SELECT
MAX() query.  DBISAM didn't have output parameters, so this wasn't an
option.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image