Reputation: 5384
Am a Oracle PL/SQL newbie. Basically, I have a table created as follows:
CREATE TABLE MYTABLE (
ID VARCHAR2(3 CHAR) NOT NULL PRIMARY KEY,
LAST_UPDATE DATE
);
Am trying to write a script which will run through SQL*Plus command:
insert into MYTABLE (
id,
last_update)
values (
sys_guid,
--- Date call - what is placed here?
);
What can I do to insure that the date inserted is the correct date (at time of insertion) with this format (what function to call):
27-Oct-11
Will need this script to be executable from within SQL*Plus (read that there's numerous amounts of incompatibilities between ANSI SQL & PL/SQL running from SQL Developer vs. SQL*Plus).
Thanks for taking the time to read this!
Upvotes: 0
Views: 3820
Reputation: 182850
Date fields don't have a format. You apply a format when you select them by using the to_char function. So what you want to do is
insert into mytable
(id, last_update)
values
(sys_guid, SYSDATE);
And you select from it using
select id, to_char(last_update, 'DD-Mon-YY')
from mytable;
Upvotes: 4