473,396 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to set a session id to a value after using a case-when statement?

Hi I want to set the session id to a value after evaluating the request_time using a case when statement.

here 's the table
Expand|Select|Wrap|Line Numbers
  1. userinput_id         session_id          request_time               keyword
  2.      1                                   2011-03-04 08:23:45        free    
  3.      2                                   2011-03-04 08:25:50        free
  4.  
  5.  
when the keyword is entered request_time ( TIMESTAMP) is stored automatically , I also want to set the session id automatically after evaluating the request_time in a case when statement:

Expand|Select|Wrap|Line Numbers
  1. create procedure upd_userinput(in request_time TIMESTAMP,out time TIME, out user_session_id INT)     
  2. begin      
  3. set time = time(request_time);    
  4. case  
  5. when time < '09:15:00' && time > '08:15:00' then      
  6. set user_session_id = 1; 
  7.  
  8. when time < '10:15:00' && time > '09:15:00' then
  9. set user_session_id = 2;  
  10.  
  11. when time < '11:15:00' && time > '10:15:00' then
  12. set user_session_id = 3;
  13.  
  14. when time < '12:15:00' && time > '11:15:00' then
  15. set user_session_id = 4;
  16.  
  17. when time < '13:15:00' && time > '12:15:00' then
  18. set user_session_id = 5;
  19.  
  20. when time < '14:15:00' && time > '13:15:00' then
  21. set user_session_id = 6;
  22.  
  23. when time < '15:15:00' && time > '14:15:00' then
  24. set user_session_id = 7;
  25.  
  26. when time < '16:15:00' && time > '15:15:00' then
  27. set user_session_id = 8;
  28.  
  29. when time < '17:15:00' && time > '16:15:00' then
  30. set user_session_id = 9;
  31.  
  32. when time < '18:15:00' && time > '17:15:00' then
  33. set user_session_id = 10;
  34.  
  35. when time < '19:15:00' && time > '18:15:00' then
  36. set user_session_id = 11;
  37.  
  38. when time < '20:15:00' && time > '19:15:00' then
  39. set user_session_id = 12;
  40.  
  41. else set user_session_id = 0;
  42.  
  43. end case;  
  44. end //
  45.  
The procedure executes.(it returns OK, 0 rows affected) on mysql terminal. but when i call it (it calls fine again) and check the table nothing has changed, is it because i use set rather than insert or what could be the problem? Is there an easier way?

Thanks. Please help.
Mar 3 '11 #1
1 1640
Rabbit
12,516 Expert Mod 8TB
An update SQL is of the form:
Expand|Select|Wrap|Line Numbers
  1. UPDATE TableName SET FieldName1 = Value, FieldName2=Value
Mar 3 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: BlueFrog | last post by:
Hi, I am having a problem accessing a session value from an include file - I echoed out session_id() from the include and it changes each time I navigate from one page which includes the include...
1
by: selen | last post by:
I am using belove code.I want to send session's value a variable in another page. How can I take session value. script="<Language=VBScript> session(\"Id\")= ";
3
by: Alan Wang | last post by:
Hi there, Once my application gets complicated and complicated. I found it's really hard to keep track of Session value I am using in my asp.net application. I am just wondering if anyone have...
0
by: Managed Code | last post by:
Hi all, I've got a DropDownList for the connection string in a master page. Transitioning between content pages causes it to reset to the first value. Under what conditions and where should I...
1
by: tofu.captain | last post by:
I have a bunch of administrative ASPX pages that requires me to check for a Session value. I have a Masterpage.master file that all these ASPX pages use, that checks this. The problem is that the...
3
abdoelmasry
by: abdoelmasry | last post by:
Hi Friends i need help in sessions im passing variables between pages using sessions this is the main page thats mean the home page the main page have table to show messages for users , it have...
3
by: Robert Dufour | last post by:
In vb I can retrieve a session variable in a web site as follows. Dim myvar as string MyVar = Session.Item("VarName").ToString But In C# there is no item property to use. How do you retrieve...
8
by: Fareast Adam | last post by:
how to change session value without need to produce a new session? I want to initialize session value on the display.php base on id on menu chosen as the following situation. PAGE menu.php: <a...
4
by: Spoogledrummer | last post by:
Hi, I'm attempting to limit access to a page without creating a whole load of session values and there for re-writing the page. So I've come up with the following code on a test page<%@...
1
by: Limno | last post by:
Hi, Suggest me, how to get the value using Session in C#.net. if i enter the value in one webform, it must display in another webform while i open that 2nd webform. But i dont want to redirect...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.