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
 Transact-SQL (2000)
 help with stored procedure, case function

Author  Topic 

mwoolgar
Starting Member

11 Posts

Posted - 2006-02-06 : 11:01:23
Hi

I need help to create a stored procedure. My current asp page uses the code below. I would like to create a stored procedure to handle all of this in a case statement, if possible.

As you can tell there are two conditions that interact with a field to give two warnings.
i.e when date is > 3 write warning text 'a' in field
when date is > 15 write warning text 'b' in filed

Many thanks



if rsDisplayAll("signeddate") <> "" then ' if signed date is available
if isnull(rsDisplayAll("InstallationDate")) and (datediff("d",rsdisplayAll("signeddate"),date) > 3 ) then
Response.write " <font color=#0033ff> Attention! :- 3 days since signed date. Please enter an installation date. </font><br>"
alert=1
end if
end if

if rsDisplayAll("signeddate") <> "" then ' if signed date is available
if isnull(rsDisplayAll("InstallComplete")) and (datediff("d",rsdisplayAll("signeddate"),date) > 15 ) then
Response.write "<br> <font color=red> Warning! :- Installation incomplete 15 days after signed date. </font>"
alert=1
end if
end if




Woolly

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-02-06 : 12:43:23
Here is the Stored Procedure
[U may need to
- put appropriate table / field names
- Learn Datediff function, Using Output parameters,
- accessing the return of the stored procedure etc.]


create procedure sp_Test1  @AnyParameter DataType, @ReturnMsg  Varchar(100) OUTPUT
AS
BEGIN
Declare @i int

Set @i = Select datediff(.....) from .... where signeddate is not null and signeddate <> ""
if @i > 3 and @i < 16
Begin
Set @ReturnMsg = 'Attention! :- 3 days since signed date. Please enter an installation date.'
End
if @i > 15
Begin
Set @ReturnMsg = 'Warning! :- Installation incomplete 15 days after signed date.'
End
End
Go to Top of Page

mwoolgar
Starting Member

11 Posts

Posted - 2006-02-06 : 14:07:24
Many thanks!


Woolly
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2006-02-06 : 14:18:34
This is not a good use of stored procedures ... it has nothing to do with processing data in the database, it has to do with evaluating a condition and deciding which HTML to render.
Go to Top of Page

mwoolgar
Starting Member

11 Posts

Posted - 2006-02-07 : 03:21:24
It might not be the correct use but at least I have learnt something. Now that you have said that I will look at other alternatives to show this data. Many thanks for your input.


quote:
Originally posted by jsmith8858

This is not a good use of stored procedures ... it has nothing to do with processing data in the database, it has to do with evaluating a condition and deciding which HTML to render.



Woolly
Go to Top of Page
   

- Advertisement -