Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing in Multiple complex PKs to Stored Procedure
Message
De
28/12/2015 14:53:46
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Titre:
Passing in Multiple complex PKs to Stored Procedure
Versions des environnements
SQL Server:
SQL Server 2012
Application:
Desktop
Divers
Thread ID:
01629332
Message ID:
01629332
Vues:
48
Hi,

I have inherited a VFP system with a SQL Server 2012 backend.

In the system a user can select multiple transactions that are to be assigned to a document. The IDs of the selected transactions are passed to a SQL Server stored procedure as a comma separated string. So a sample call might be like this:
DocumentID = "123"
TransactionIDs = "1,2,3,4,5"

SQLEXEC("myStoredProc " + m.DocumentID + ", " + m.TransactionIDs)
The stored procedure:
ALTER procedure [dbo].[uspAssignTransactions] 
	@DepositVoucherID int = null, 
	@TransactionIDs varchar(4000) = null
as

select ID 
into #IDs2Assign 
from CaseTransactions 
where charindex(',' + ltrim(rtrim(cast(ID as varchar(10)))) + ',', @TransactionIDs) > 0 and 
	DepositVoucherID is null and ClearedForDeposit = 1

update CaseTransactions set DepositVoucherID = @DepositVoucherID where ID in (select ID from #IDs2Assign)
Now, comes the complication. They have multiple branches or locations each with its own database but they want to merge the databases, hence we'll end up with multiple transactions with the same ID. They do have a location code for each branch so each transaction can be identified by the location code and transaction ID.

So, how do I adjust this to include the location code of the selected transaction as part of the call to the stored procedure and then adjust the stored procedure to use this location code and ID to uniquely identify the transactions?
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform