Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Calling functions or stored procedures from another function

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-06-19 : 12:21:24
Prakash writes "When we try to call a function or stored procedure from another function, the system says 'Only functions and extended stored procedures can be executed from within a function'.

Pls help us for executing a function from another function.


Regards
Prakash"

smccreadie
Aged Yak Warrior

505 Posts

Posted - 2002-06-21 : 19:49:38
Can you supply us with some of your code so we can see what the issue is?

Go to Top of Page

VyasKN
SQL Server MVP & SQLTeam MVY

313 Posts

Posted - 2002-06-22 : 04:12:10
That is one of the many limitations of User Defined Functions. For more information, see SQL Server Books Online.

--
HTH,
Vyas
http://vyaskn.tripod.com
Go to Top of Page

prakash
Starting Member

2 Posts

Posted - 2002-06-25 : 03:01:23
quote:

Can you supply us with some of your code so we can see what the issue is?





Tx for the reply.

Sample code:

CREATE FUNCTION Gettaxforthismonth(@mSettlement VARCHAR)
RETURNS NUMERIC
AS
BEGIN
DECLARE @mTaxPeriodFrom DATETIME;
DECLARE @mTaxPeriodTo DATETIME;


SELECT
@mEmployeeID = N_EMPLOYEE_ID,
@mPayDate = D_PAY_DATE,
@mPayGroupID = N_PAY_GROUP_ID
FROM
PA_CURRENT_VALUES

SELECT @mTaxPeriodFrom = CONVERT(DATETIME,DBO.Getvaluefromsystem('TAX_PERIOD_FROM'),103)
SELECT @mTaxPeriodTo = CONVERT(DATETIME,DBO.Getvaluefromsystem('TAX_PERIOD_TO'),103)

EXEC Getwageperiod @mPayGroupID, @mWagePeriodFrom, @mWageTo

SET @mNetTax = DBO.Calculatetaxvalue ('NET_TAX', @mEmployeeID, @mTaxPeriodFrom, @mTaxPeriodTo, @mPayDate)

SET @mTaxForThisMonth = (@mNetTax / ROUND(DATEDIFF(MM,@mWagePeriodFrom, @mTaxPeriodTo),0))

RETURN @mTaxForThisMonth
END

Unable to call the procedure Getwageperiod from parent function gettaxforthismonth

-- The content for getwageperiod can be filled with some simple statements.









Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-06-25 : 08:04:22
Just include all of the code for Getwageperiod and Calculatetaxvalue in the body of your Gettaxforthismonth function. That will alleviate the problem.

Go to Top of Page
   

- Advertisement -