logo       

RE: Re: NewB: Return New Record ID...: msg#00649

Subject: RE: Re: NewB: Return New Record ID...
The problem is I have hundreds of tables each with a different column list and 
syntax, I don't want to have to create a SP for each table. There really has to 
be an easy way to do this. Now my sql server is saying this:

Connection is busy with results for another hstmt, SQL state S1000

..... it looks like I'll have to take my chances with select max() 

<>< Ryan

-----Original Message-----
From: Bernain, Fernando G. [mailto:fbernain@xxxxxxxxxxx]
Sent: Thursday, December 26, 2002 10:43 AM
To: Ryan Jameson (USA)
Cc: php-db@xxxxxxxxxxxxx
Subject: RE: [PHP-DB] Re: NewB: Return New Record ID...


You can use this inside an stored procedure, for instance:

CREATE PROCEDURE SP_INSERT_TRANSACCION
@transacfecha datetime,
@observacion char(100)
 AS
INSERT INTO Transaccion(transacfecha, observacion)
VALUES(
@transacfecha,
@observacion
)
SELECT @@IDENTITY AS 'nrotrans'
END

In this example, I insert two values with this sp in a table with and
Identity column. So, the SP return the value of the transaccion generated...
You've got the idea???


Fernando Bernain
Senior A
Business Process Outsourcing

KPMG Argentina
Tel: 54 11 4316 5754
Fax: 54 11 4316 5734
fbernain@xxxxxxxxxxx




-----Original Message-----
From: Ryan Jameson (USA) [mailto:RJameson@xxxxxxxxxxx]
Sent: Thursday, December 26, 2002 2:36 PM
To: php-db@xxxxxxxxxxxxx
Subject: RE: [PHP-DB] Re: NewB: Return New Record ID...


This doesn't work as expected through ODBC... it does not seem to return any
value...

<>< Ryan

-----Original Message-----
From: Bernain, Fernando G. [mailto:fbernain@xxxxxxxxxxx]
Sent: Thursday, December 26, 2002 10:09 AM
To: Ryan Jameson (USA)
Cc: php-db@xxxxxxxxxxxxx
Subject: RE: [PHP-DB] Re: NewB: Return New Record ID...


This is from de books online (MSSQL).

@@IDENTITY (T-SQL)
Returns the last-inserted identity value. 

Syntax
@@IDENTITY

Return Types
numeric

Remarks
After an INSERT, SELECT INTO, or bulk copy statement completes, @@IDENTITY
contains the last identity value generated by the statement. If the
statement did not affect any tables with identity columns, @@IDENTITY
returns NULL. If multiple rows are inserted, generating multiple identity
values, @@IDENTITY returns the last identity value generated. If the
statement fires one or more triggers that perform inserts that generate
identity values, calling @@IDENTITY immediately after the statement returns
the last identity value generated by the triggers. The @@IDENTITY value does
not revert to a previous setting if the INSERT or SELECT INTO statement or
bulk copy fails, or if the transaction is rolled back.

Examples
This example inserts a row into a table with an identity column and uses
@@IDENTITY to display the identity value used in the new row.

INSERT INTO jobs (job_desc,min_lvl,max_lvl)

VALUES ('Accountant',12,125)

SELECT @@IDENTITY AS 'Identity'

  

Fernando Bernain
Senior A
Business Process Outsourcing

KPMG Argentina
Tel: 54 11 4316 5754
Fax: 54 11 4316 5734
fbernain@xxxxxxxxxxx




-----Original Message-----
From: Ryan Jameson (USA) [mailto:RJameson@xxxxxxxxxxx]
Sent: Thursday, December 26, 2002 2:06 PM
To: php-db@xxxxxxxxxxxxx
Subject: RE: [PHP-DB] Re: NewB: Return New Record ID...


for MS SQL and Oracle does anyone know a more reliable way to do this than
select max(ID) immediately after the insert? It seems silly that I'd have to
take my chances that another has been inserted in between.

<>< Ryan

-----Original Message-----
From: J.Veenhuijsen [mailto:info@xxxxxxxxxxxxxxxx]
Sent: Friday, December 06, 2002 1:52 AM
To: php-db@xxxxxxxxxxxxx
Subject: [PHP-DB] Re: NewB: Return New Record ID...


Try $last=mysql_insert_id();

Jochem

Doug Coning wrote:
> Hi all,
> 
> How do I do this:
> 
> I need a PHP page that simply creates a "blank" record so that I have the
> record's ID (which is automatically generated).  That same page then needs
> to return the record ID back so that I know what the ID is.  I will later
> allow that record's information to be populated based on the ID it first
> returned.
> 
> How would I do this?
> 
> Thank you, thank you!
> 
> Doug Coning
> 
> 
> 


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Email Disclaimer

The information in this email is confidential and may be
legally privileged.
It is intended solely for the addressee.
Access to this email by anyone else is unauthorised.
If you are not the intended recipient, any disclosure,
copying, distribution
or any action taken or omitted to be taken in reliance
on it, is prohibited and may be unlawful.
When addressed to our clients any opinions or advice
contained in this email are subject to the terms and
conditions expressed in the governing KPMG client engagement
letter.


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
science.linguis...    culture.sf.lite...    video.mplayer.c...    yellowdog.gener...    ietf.rfc822/199...    emacs.help/2002...    redhat.release....    kernel.speakup/...    java.openejb.de...    debian.devel.gt...    xfree86.newbie/...    bug-tracking.ma...    pam/2003-05/msg...    games.devel.ope...    user-groups.lin...    music.pancham/2...    network.mq.deve...    web.html.genera...    arklinux.bugs/2...    linux.ecasound/...    qnx.openqnx.dev...    org.user-groups...    file-systems.sf...    trustix.contrib...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe