Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SP with multiple tables and databases (insert & delete)
Message
 
 
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
00758108
Message ID:
00758236
Views:
16
>it will probably be simplier if you just made another call to the proper database from your application, instead of trying to deal with calling outside the database from your stored procedure.
>
>

Not exactly sure, how should I do it. The tables in both CTCredit and MACredit are identical and I can open connection to them in my ASP page depending on the state used. But I want to have just one database Shopping Cart and this SP should do manipulations from Shopping Cart database point of view. Could you please elaborate more?

Did you see Bob's reply?


>>Hi everybody,
>>
>>May be you can help me with writing complicated stored procedure, which involves several tables and one from another database.
>>
>>This SP would accept 3 parameters:
>>UserID, list of CredID (comma-delimited) and State.
>>
>>The tables structures are in Re: How they got to your page??? Thread #756846 Message #757928 message
>>
>>Here is a pseudo code:
>>parameters tnUserID, tcListOfCodes, tcState
>>Look for tnUserID in Cart table.
>>begin transaction
>>1)
>>If exists, grab CartID and update LastModified field
>>otherwise
>> insert a record and grab generated CartID
>>endif
>>
>>2) From another database (either CTCredit or MACredit - depending on passed 3rd parameter)
>>
>> for every CredID in the list insert into CreditContent records and in the CreditDetail (child of CreditContent) based on the info from CreditInfo table from either CTCredit or MACredit database.
>>
>>Here is a sample of retriving info from CreditInfo corresponding to passed list of codes:
>>
>>strSQL = "select CredID, CreditCat, ccode, town, Address from " & _
>>         "CreditInfo where ccode+town+address in (select ccode+town+address from CreditInfo where CredID in (" & request.form("Selection") &_
>>		  ")) order by CreditCat, ccode, town, Address"
>>
>>end transaction.
>>
>>So, my question is: is this SP doable? Can you please give me examples of SP (triggers) updating (inserting/deleting) multiple tables?
>>
>>Thanks a lot in advance.
>>
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform