Need Help with an Expression [message #364286] |
Sun, 07 December 2008 19:47 |
janders
Messages: 1 Registered: December 2008
|
Junior Member |
|
|
Hello,
can you help me with the following problem?
Update the due date in table book_trans:
Write one UPDATE statement using an expression with the Decode function and the to_Char function?
ERD diagramm:
Table books:
ISBN (Primary KEY)
Title
No_of_copies
Author
Table Book_Trans:
Book_Trans_ID (Primary KEY)
ISBN (Foreign KEY)
employee_id (Foreign_key)
checkout_dte
due_dte
return_date
pastdue_fees
Table employees:
employee_id (PK)
last_name
first_name...
Business Rule for due date: The due date is 30 days from the checkout_dte. If due_dte falls on a saturday or sunday then the loan period is 32 days. To test for a weekday, use the to_char function with the format of 'D'. For example to_char ('12-NOV-2007', 'D'). This function returns a number between 1 and 7 (1=Sunday, 2=Monday,...)
Thanks
|
|
|
|
Re: Need Help with an Expression [message #364313 is a reply to message #364286] |
Sun, 07 December 2008 23:29 |
|
Michel Cadot
Messages: 68728 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
Tell your teacher the examples he gave are not correct:
Quote: | To test for a weekday, use the to_char function with the format of 'D'. For example to_char ('12-NOV-2007', 'D').
|
SQL> select to_char ('12-NOV-2007', 'D') from dual;
select to_char ('12-NOV-2007', 'D') from dual
*
ERROR at line 1:
ORA-01722: invalid number
Quote: | This function returns a number between 1 and 7 (1=Sunday, 2=Monday,...)
|
SQL> select to_char(sysdate-1,'Day') "Day", to_char(sysdate-1,'D') "Num" from dual;
Day N
--------- -
Sunday 7
1 row selected.
See TO_CHAR function.
Regards
Michel
[Updated on: Sun, 07 December 2008 23:35] Report message to a moderator
|
|
|