Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How Do I Create This Procedure?
Message
From
27/04/2006 15:36:59
Mike Yearwood
Toronto, Ontario, Canada
 
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
01116731
Message ID:
01117256
Views:
32
Hi Kevin

When you try to build an app which has a parent-child-grand child relationships, the grandchildren need to know which child they belong to. So beyond a single table or parent-child relation, you must generate some kind of key, in your app.

I say generate keys all the time so you have a consistent practice. Don't make them sequential as they don't have to be. Don't tie them to a single table. Don't ask the back end for them - cause that gives the backend more to do, both in generating and sending the key(s) back to you.

Consider this article: http://www.informit.com/articles/article.asp?p=25862&seqNum=9&rl=1.

Each PC can generate a key without involving the backend. The backend only has to confirm uniqueness, which should help it handle more requests and process more transactions.

>How do I convert this VFP code to a SQL stored procedure:
>
>
>PROCEDURE GetNextId(cKeyName)
>
>LOCAL nRetVal
>nRetVal = 0
>
>SELECT 0
>USE SysKeys
>
>LOCATE FOR KeyName = cKeyName
>
>IF FOUND()
>  nRetVal = SysKeys.Id + 1
>  REPLACE IN SysKeys Id WITH nRetVal NEXT 1
>ENDIF
>
>RETURN nRetVal
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform