Page 1 of 1

Obtaining a RecordSet when INSERTING

Posted: Thu Aug 22, 2002 7:39 pm
by EvanClark
Hey Guys ...

Is it possible to make MySQL return a RecordSet when INSERTing data into a table.

For example:

2 data fields - ID (autoincrement int), name (varchar)

Lets say, I execute "INSERT INTO TABLE (name) VALUES ('Evan');"

However, now I must say "SELECT ID FROM TABLE WHERE name='Evan';" in order to find out what ID value was assigned to the new name entry. And if another 'Evan' has been entered into the table, it gets even more complex.

Does anyone know of a way to get MySQL to return a RecordSet based on what was just inserted into the table?

Posted: Thu Aug 22, 2002 8:10 pm
by jason
Use the function mysql_insert_id() for something like that.

Posted: Thu Aug 22, 2002 8:36 pm
by EvanClark
Thanks Jason.

I've been programming PHP for 2.5 years now and I'd never heard of that function before. :D

Posted: Thu Aug 22, 2002 8:41 pm
by EvanClark
I know I'll probably get black-listed :twisted: for this question but here goes ...


Does anyone know the ASP/MS-SQL equivalent to mysql_insert_id()?

Posted: Thu Aug 22, 2002 10:48 pm
by jason
I honestly don't think ASP/MS-SQL has that same thing? I am not surprised though. Show me ASP's mail() function, or how I can do uploads in ASP. :D

Posted: Fri Aug 23, 2002 2:41 am
by volka
MSDN provides sample code for file-upload in ASP/VBscript.
You can't imagine how slow it is :(
But mail support is available. You have to use some COM-Objects but they are quite charming - a little bit overkill for a simple "Done." mail but handy if you have to create more complex mails

Posted: Fri Aug 23, 2002 2:51 am
by EvanClark
To be fair to the ASP/MS-SQL combination ... atleast they have got Stored Procedures.

I'd sell my first born child for MySQL to have Stored Procedures. :twisted:

Posted: Fri Aug 23, 2002 3:24 am
by hob_goblin
How much would you be selling this child for? :)

Posted: Fri Aug 23, 2002 5:43 am
by 9902468
ditch mysql and use postgresql, it takes a while but pgsql has a lot more to offer than mysql

(including stored procedures, functions and types + transactions...)

check http://www3.us.postgresql.org/ for more info

-9902468

Posted: Fri Aug 23, 2002 6:43 am
by jason
And yet, PostgreSQL lacks some serious things also needed in a business environment.

I tried doing a search for replication, and found nothing. I couldn't keep looking. MySQL has it, and PostgreSQL doesn't, and we need it.

Posted: Fri Aug 23, 2002 2:34 pm
by 9902468
I guess it is not perfect, but in my case (No replication needed) I value transactions over mysql speed.


-VV