Form the client I need to pass a SYSDATE argument to PL/SQL. In the server it need to be converted to date, for which iam using TO_DATE(in_timestamp, 'DD-MON-YYYY HH24:MI:SS'); What should be the data type of in_timestamp?
2 Answers
As far as TO_DATE is concerned you can have CHAR, VARCHAR or VARCHAR2(recommended) basically it should be of String type as following examples suggest:-
to_date('2003/07/09', 'yyyy/mm/dd') would return a date value of July 9, 2003.
to_date('070903', 'MMDDYY') would return a date value of July 9, 2003.
to_date('20020315', 'yyyymmdd') would return a date value of Mar 15, 2002.
You can find more information related to TO_DATE at this link,
EDIT
*"However, if you are passing sysdate you dont't need to use TO_DATE again because it is already a Date value..."*as mentioned by @Gaurav and Hence the dataType of in_timestamp should be DATE..
1 Comment
Gaurav Soni
:If he's passing sysdate then why he should be recommmended to store that in varchar*?,
SYSDATEtoin_timestampthen datatype will be ofDATEtype .Are you returnig the same variable after converting it ?dateas mentioned byErkan Haspulatin his answertimestampinstead of adate.