×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

To make an UPDATE automatically

To make an UPDATE automatically

To make an UPDATE automatically

(OP)
Hi
I have a table with seven entries. They are pictures, each one of them for a day of the week. Now I have an application in jsp to be able to change the picture.
But what I want to do it is an automatic process so that they change without my intervention.
I have a SQLServer 7.0
I have begun to read on triggers and stored processes and am taking ideas.
The code is easy, some like that:

SELECT idfoto AS idactual FROM FOTOPORTADA WHERE visible=1 AND seccion = 1
IF (idactual=41) // Mon
UPDATE FOTOPORTADA SET visibleweb = 0 WHERE idfoto = 41
UPDATE FOTOPORTADA SET visibleweb = 1 WHERE idfoto = 42
IF (idactual=42) // Tue
...

What I do not know is how to use the parameter that I obtain from the first SELECT (idactual) in the rest of code, to pass it to it to the IF. Some idea?
Thank you very much

RE: To make an UPDATE automatically

If I understand you correctly you just want to select a different picture each day of the week. If that is the case try setting the idphoto to 1 through 7. You can then use a simple SELECT using the DATEPART function in SQL:
Select idphoto FROM FOTOPORTADA
WHERE idphoto = DATEPART(dw, GETDATE())

GetDate returns the current date, and DatePart uses dw to produce the day of the week

Good Luck
johnwm
________________________________________________________
To get the best from these forums read FAQ731-376 before posting

Steam Engine enthusiasts: www.essexsteam.co.uk

RE: To make an UPDATE automatically

I don't know if you already solved this problem, but if the others will have the same problem:

If you are using a stored procedure, first you can declare a variable and than use set command to set the value of that variable and then use it in the following code:

DECLARE @idactual int

SET @idactual = SELECT idfoto FROM FOTOPORTADA WHERE visible=1 AND seccion = 1
IF (@idactual=41) // Mon
.
.
.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources