Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > DB Tools

Lost Password?

Closed Thread
 
Thread Tools Display Modes
  #1  
Old 08-09-2016, 06:07 AM
rmt rmt is offline
Senior Member
 
Join Date: Jun 2013
Posts: 299
Default Called Function with varied Parameters from a Stored Procedure

Dear Expert,

I am calling a Function say TestFunc from a Stored procedure. The function named TestFunc in one Database might have one parameter while in other Database the Function Named TestFunc might have two parameters. So, i have tried to call the function TestFunc in a Stored procedure as below so as to make the common Stored Procedure for all database.

HTML Code:
Declare @Version NUMERIC(2)
DECLARE @SQL NVARCHAR(MAX)

SELECT @Version=LEFT(REPLACE (MAX(SCMBVERSION) , '.' , ''),2) FROM YSYNC

SET @SQL='IF @Version>50 '+
'SELECT DBO.GetBalAmt(''00001004'',0) '+
' ELSE '+
'SELECT DBO.GetBalAmt(''00001004'') '

EXEC SP_EXECUTESQL @SQL, N'@Version NUMERIC(2) OUT', @Version OUT
But while executing this, I got an error Procedure or function DBO.GetAvailBalAmt has too many arguments specified. Please suggest how can I achieve this. Thanks in advance.
__________________
Rmt
  #2  
Old 08-09-2016, 06:28 AM
rmt rmt is offline
Senior Member
 
Join Date: Jun 2013
Posts: 299
Default

It worked ..thanks.

I did other way round like this:

SET @SQL=
'SELECT DBO.GetAvailBalAmt(''00001004''' + CASE WHEN @Version>50 THEN ',0' ELSE '' END+ ') '
EXEC SP_EXECUTESQL @SQL
__________________
Rmt
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:58 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.