Insert Record With Identity ASP

This is a modified Insert Record Server Behaviour.
It does everything that the standaard Insert Record SB does but adds functionality to return the IDENTITY value of the new inserted record.

(works on MS SQL Server/Access 2000 with "Jet OLEDB Provider 4.0" only)

Overview


The behaviour defines a new variable LastIdent that contains the value of the last identity.
Normally you shouln't specify a redirect file and put more code after this server behaviour.

  • Read the FAQ's about this extension

Requirements

Type: Server Behavior
Product: UltraDev 4
Server Model: ASP VBScript
Platform: Win XP/2000/2003/2008/7, Mac OS 8.6 or higher

George Petrov

George PetrovGeorge Petrov is a renowned software writer and developer whose extensive skills brought numerous extensions, articles and knowledge to the DMXzone- the online community for professional Adobe Dreamweaver users. The most popular for its over high-quality Dreamweaver extensions and templates.

George is also the founder of Wappler.io - the most Advanced Web & App Builder

See All Postings From George Petrov >>

Reviews

Does this work?

February 7, 2001 by Bill wpmurphy88

So far not so good - Usual hassles you get with the insert behaviour (error 503 don't try this request at home), but this time there is an error in the SQL at this point:

    MM_editCmd.CommandText = "SET NOCOUNT ON;" & MM_editQuery & ";SELECT@" & "@IDENTITY AS Ident"
    Set rsLastIdent = MM_editCmd.Execute

Got to admit I don't know what is happening - the insert statement I can follow the rest passes me by.

I'm using MySQL- the latest(ish) release does this explain it?

How do you make use of the ident? compound keys and others

February 7, 2001 by Bill wpmurphy88

I am assuming that I can pass the id to another page and use this in data operations - for instance - I insert a record in a master table, say ORDER, then I use the key, say OrderID (auto-increment integer) when I come to insert a record in a detail table, say ORDER_LINE - The PK for order line consists of  OrderID & LineID (auto-increment) together -

a) how do I pass the id or ORDER, and

b) will it return OrderID, LineID following the insert in ORDER_LINE?

RE: Does this work?

February 8, 2001 by George Petrov
Hi, currenly the this works only for MS SQL Server 2000 and Access 2000. There you gave the system variable @@IDENTITY that contains the last inserted id.
There should be the same construction for MySQL, but I couldn't found - maybe you can help me with this. Then I will build it into the extension.

RE: How do you make use of the ident? compound keys and others

February 8, 2001 by George Petrov

Well you have a variable LastIdent, it is set in the script. You just have to switch off the redirect and put your own code that uses this variable just after the the insert script.

Maybe it will be better if I make a Session variable from this one in the next version of this extension ...

See all 60 Reviews

You must me logged in to write a review.