cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From (Michael Raffenberg)
Subject Re: Help with esql results for 'insert' query
Date Thu, 11 Jan 2001 20:25:51 GMT
Hello eliza,

Tuesday, January 09, 2001, 2:10:52 AM, you wrote:

ekTc> Hello,

ekTc> I am using MS SQL database and the tables are set up in a way that the
ekTc> primary keys get generated automatically when inserting entries.
ekTc> Is it feasible to get the generated id after 'insert' query in esql?

ekTc> Example:  I have a table called 'owners' with three columns: name, address,
ekTc> owner_id where owner_id is the primary key.

ekTc> After I insert as follows:
ekTc> <eql:execute-query>
ekTc>    <esql:query>insert into owners values('john smith')</esql:query>

ekTc> would query return the generated id for the entry that I just inserted? If
ekTc> so, what is the esql tags?  I don't seem to find it when looking at the
ekTc> esql logicsheet.  Please note that querying based on 'name' or 'address'
ekTc> will not help me because they are not necessarily unique, i.e. I could have
ekTc> entries with same names or address.

ekTc> Any help or suggestion is greatly appreciated.
ekTc> Eliza

ekTc> ---------------------------------------------------------------------
ekTc> To unsubscribe, e-mail:
ekTc> For additional commands, e-mail:

What about stored procedures?

I do it like this one:
CREATE PROCEDURE [dbo].[sp_InsertPersonalstamm]
        @Nachname               varchar (100),
        @Vorname                varchar (50), 
        @Username               varchar (50)  = NULL,
        @Anrede                 varchar (50),
        @Titel                  varchar (50) = NULL
  DECLARE       @PersonID       int

  if ( (@NACHNAME is null or @NACHNAME ='') or (@VORNAME is NULL or @VORNAME ='') or (@ANREDE
is NULL or @Anrede ='') )
    Return -99

  /*create new record */

  /* return the identity value from PersonID */
  set @PersonID = @@IDENTITY
  return @PersonID

Best regards,

View raw message