c# - Stored Procedure that handles 1 or 2 or 3 value -


I am using a stored procedure to run some queries in my database. The value is taken from a query string, which was then passed to the stored procedure. The thing is, the user can select more than 1 option which generates 3 or more query strings.

For example,

I know how to take value from the query, but I do that, stored procedures overload the values ​​1 or 2 or 3, like the way it accepts

Like

  set value {this.value = val; } SetValue (double val) {this.value = (int) val} setValue (String val) {try {this.value = Integer.parseInt (val)} catch (Exception e) {println (e.getMessage ()); Return 0; }}  

This is a copy of the stored procedure ..

  Go to the ALTER process [dbo]. [GetSealRecordID] as set ANSI_NULLS QUOTED_IDENTIFIER set (@TRANSFER_ID integer) - Select declare variables specific "FGFSTRANSFERS" "consider", "FGFSTRANSFERS" "AMOUNT_TRANSFER", "FGFSTRANSFERS" "DATE", "FGFSTRANSFERS" "TRANSFER_ID", Kur = Case "FGFSTransferDetails" ..... "Total" when "USD" and "US $" when "JMD" then "Jamaican dollars 'when' CAD 'again when' Canadian Dollar 'when' GBP 'and' pound 'euro' and 'euro' end , "". "FGFSCUSTOMERS CMF_NAME_1", "FGFSCUSTOMERS CMF_NAME_2", "FGFSTransferDetails amount", Cons_Curr = case "FGFSTransferDetails Co" "." "." "." - Cons_Curr, when "USD" as the "US Dollar" 'JMD' then 'Jamaican Dollar' when 'CAD' then 'Canadian Dollar' then 'GBP' then 'Pound' when 'Euro' then 'Euro' end, "FGFSTransferDetails". "Details", "FGFSTransferDetails". "FGFSTransferDetails" "FGFSTransferDetails" "FGFSTransferDetails" Inner JOIN "FGFSInvestment". "DBO". "FGFSTRANSFERS" "FGFSTRANSFERS" on "FGFSTransferDetails". "TRANSFER_ID" = "FGFSTRANSFERS". "TRANSFER_ID" "FGFSINASTERMENT". "DGO" "FGFSCOTOmers" on "FGFSCOTOmRear" on "FGFSCATMARs". "Custodian" = "FGFSCOTOMERs". "CMF_ACCIACC" where "FGFstroners". "TransFare IDID" = @TRANSFER_ID and "FGFStashScher Dip Apartments "." TRANSFER_ID "= @ TRANSFER_ID  

If you default parameters in your stored procedure you can use:

  CREATE PROCEDURE [dbo]. [GetSealRecordID] (@PARAM int = -1, PARAM2 int = -1, PARAM3 int = -1) AS ...  

Definitely you have to handle those sections where clause:

  ... WHERE (@PARAM = -1 OR (condition @PARAM)) and (@ PARAM1 = -1 OR (PARAM1 @ condition)) and (@ PARAM2 = -1 OR (PARAM2 @ position))  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -