I am curious why PL/SQL does not let me declare a var as datetime and what my alternatives are. I am using Oracle 11.
VARIABLE some_date date;
And I get the following error message indicating legal types for a var, date not being included:
Usage: VAR[IABLE] [ <variable> [ NUMBER | CHAR | CHAR
(n [CHAR|BYTE]) |
VARCHAR2 (n [CHAR|BYTE]) | NCHAR | NCHAR (n) |
NVARCHAR2 (n) | CLOB | NCLOB | REFCURSOR |
BINARY_FLOAT | BINARY_DOUBLE ] ]
I can probably work around this issue by simulating the date as a string or long representation but I’m really curious why this is the case.
Thanks
In PL/SQL, The KeyWord
VARIABLEis out of your context. It used to create bind variablesBind variables are created in the environment and not in the declarative section of a PL/SQL block. Variables declared in a PL/SQL block are available only when you execute the block. After the block is executed, the memory used by the variable is freed. However, bind variables are accessible even after the block is executed. Therefore, when created, bind variables can be used and manipulated by multiple subprograms. They can be used in SQL statements and PL/SQL blocks just like any other variable. These variables can be passed as run-time values into or out of PL/SQL subprograms.
eg for VARIABLE:
I feel for you, the blow will serve the purpose