You are here: Re: Stored Procedures « PHP Programming Language « IT news, forums, messages
Re: Stored Procedures

Posted by NC on 05/02/07 02:00

On May 1, 12:36 pm, "Bruce A. Julseth" <bruceaj_nosp...@bellsouth.net>
wrote:
>
> What I am doing now is straight SQL!!

Unfortunately, there is no such thing as "straight SQL". Every
implementation is different in details...

> I have Table A that has a link field in it pointing to
> Table B. So, I first "INSERT" into table B, then do
> a SELECT on MAX(Key) where Key is an auto
> incremented field. I then include the value of "Key"
> in the data when I do the INSERT into Table A.
> Make sense??

This is a dangerous approach that can backfire in case of concurrent
updates. Instead of SELECT MAX(key), you should be using
LAST_INSERT_ID() (assuming you are running MySQL, of course...)

> - Does this make for writing a stored procedure?

If you want to do it as a stored procedure, you can.

> - Is there a better way to do it in SQL?

Better in terms of what? Execution time, portability,
maintainability, something else?

Cheers,
NC

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация