You do not need to convert i_birthday
to a DATE
using TO_DATE
as it is already a DATE
data type. Just use:
PROCEDURE update_affiliate (
pid NUMBER,
i_username VARCHAR2,
i_first_name VARCHAR2,
i_birthday DATE)
IS
BEGIN
UPDATE affiliate_v
SET username = UPPER (i_username),
first_name = i_first_name,
birthday = i_birthday,
WHERE party_id = pid;
END update_affiliate;
How to update it in wanted format?
This is a common misconception that dates in the database have a format.
A date does not have a format - it is stored internally to the database as 7-bytes (representing year, month, day, hour, minute and second) and it is not until whatever user interface you are using (i.e. SQL/Plus, SQL Developer, Java, etc) tries to display it to you, the user, and converts it into something you would find meaningful (usually a string) that the date is given a format so that you, the user, find it meaningful on the client software.
Since you are passing in a DATE
you don't need to do anything.
What you probably want to ask is:
Now I have updated the date, how can I get the user interface to display the date in the format I want when I query the table?
If you are using SQL/Plus or SQL Developer then it will use the NLS_DATE_FORMAT
session parameter to format the date. You can change this using:
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY';
Note: This is a session parameter and will only change the format for the current session (not for any other users or any subsequent sessions).
You can also change the preferences in the SQL Developer GUI as described here.
Or you can just use TO_CHAR
and set the format you want:
SELECT party_id,
username,
first_name,
TO_CHAR( birthday, 'DD-MON-YYYY' ) AS birthday
FROM affiliate_v