Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calculated Field
Message
From
14/07/2011 15:30:54
 
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Environment versions
SQL Server:
SQL Server 2008
Miscellaneous
Thread ID:
01518145
Message ID:
01518173
Views:
40
>>>So, I recommend to lean towards stored procedures for complex logic and not try to abuse functions (although, of course, they do have their place).
>>
>>so are you saying the code I wrote would work in an SP?
>
>I haven't studied your code in details, but generally, yes.

:)

I hope that someone can look at my code, because I'm stuck
CREATE PROCEDURE GetClaimStatus 
	-- Add the parameters for the stored procedure here
	@Clm_PK UNIQUEIDENTIFIER,
	@Status INT OUTPUT
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	DECLARE @DayLimit INT
	DECLARE @Cli_PK UNIQUEIDENTIFIER
	
	SET @Status = 1 /* Pending */
	SET @Cli_PK = (SELECT clm_clifk FROM Claims WHERE clm_pk = @Cli_PK)
	
	SET @DayLimit = (SELECT com_OverDueDays 
					FROM Companies 
						INNER JOIN Clients ON com_pk = cli_comfk
							WHERE cli_comfk = @Cli_PK)

/* I don't know how to implement the logic:						
1. If any Claim Items are Overdue, then Claim is Overdue
2. Else If all Claim Items are Settled, then Claim is Settled
3. Otherwise Status is Pending */
			
    RETURN @Status 
END
GO
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform