I have an output parameter in oracle called outTime of type DATE. The format for this is set as yyyy-mm-dd and I need to be able to include the time from a table when I select into it.
I keep getting an error : date format picture ends before converting entire input string.
here is the insert into statement.
SELECT TO_CHAR(Table_Time, 'YYYY-MM-DD HH24:MI:SS') into outTime
FROM Table_One;
the out parameter is declared as
outTime OUT DATE;
within a stored procedure in a package of other procedures.
I keep finding ways to set the format globally but I only need to set the format for this instance.
Thanks for any insight.
A DATE
does not have a format. A string representation of a date has a format but a DATE
does not.
If Table_Time
is a VARCHAR2
(a string representation of a date) in the format yyyy-mm-dd hh24:mi:ss
, then you would want to use TO_DATE
to convert the string into a DATE
(I assume that there is a single row in table_one
in this example, otherwise the SELECT ... INTO
will raise a no_data_found
or a too_many_rows
exception.
SELECT TO_DATE(Table_Time, 'YYYY-MM-DD HH24:MI:SS')
into outTime
FROM Table_One;
If Table_Time
is a DATE
, you would simply assign it to outTime
SELECT Table_Time
into outTime
FROM Table_One;
When you want to display outTime
, you'll need to convert the DATE
to a string representation of a date (a VARCHAR2
). At that point, you can use the TO_CHAR
function.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.