I don't now ich language you are using to perform this query.
But as mysql does not know any stored procedures, you will have to do it in
code with different call's.

the value of the id (seed in mssql) can be obtained with the SQL function
LAST_INSERT_ID()

a little hint.  in your stored procedure in case of non existance of a
personid, personid has a value of null on mssql.
so it is better to cheque on mssql personid IS NULL.





----- Original Message -----
From: "Pure Krome" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, November 17, 2001 9:02 AM
Subject: [QUERY] Problem with Syntax/Query. Need Help Please.


> G'Day All.
>
> I'm trying to do the following in a query, in mySQL.
> All my previous years of SQL has been on MS-SQL, and i'm having some
little
> problems with tricky sql statements.
>
> *****
> i'm trying to insert a new record if the name doesn't exist in the table.
If
> i insert, return ID, else return 0
> *****
>
> <pseduo -sql syntax>
>
> SET NOCOUNT ON
>
> DECLARE @intPersonID   INTEGER
>
> SELECT PersonID from tbl_PERSON WHERE Name = @strName
> SELECT @intPersonID = @@IDENTITY
>
> IF @intPersonID < 1
>    BEGIN
>       INSERT tbl_PERSON (Name, Surname) VALUES ('TestName', 'TestSurname')
>       SELECT @intPersonID = @@IDENTITY
>    END
> ELSE
>    SET @intPERSONID = 0
>
> <end psedu untested code>
>
> I have NO idea how i can do this on MYSQL..
>
> Any help would be extreamly appreciated.
>
> -Regards : Pure Krome-
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
>


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to