Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> help: how to use bind value in date type?
i am learning how to use bind value. I have a test table with with
only two rows
Name Null? Type
------ -------- ------
COL1 NUMBER COL2 DATE
SQL> variable x number
SQL> begin
2 :x:=1;
3 end;
4 /
PL/SQL procedure successfully completed. SQL> select * from test where col1 = :x;
COL1 COL2
---------- ---------
1 24-JAN-02 1 row selected.
But I do not know how to use bind value with date type
SQL> variable x date
Usage: VAR[IABLE] [ <variable> [ NUMBER | CHAR | CHAR (n) | VARCHAR2(n) |
NCHAR | NCHAR (n) | NVARCHAR2 (n) | CLOB | NCLOB | REFCURSOR ] ]
SQL> variable x varchar2(60);
SQL> begin
2 :x:=to_date('2002/01/24 23:59:59','yyyy/mm/dd hh24:mi:ss');
3 end;
4 /
PL/SQL procedure successfully completed.
SQL> select * from test where col2=:x;
no rows selected
but there are two rows in the table
SQL> select col1,to_char(col2,'yyyy/mm/dd hh24:mi:ss') from test;
COL1 TO_CHAR(COL2,'YYYY/
---------- ------------------- 1 2002/01/24 23:59:59 2 2002/01/25 23:59:59
2 rows selected.
What i did was wrong?
Thanks for you help
-- Sent by dbadba62 from hotmail subdomain of com This is a spam protected message. Please answer with reference header. Posted via http://www.usenet-replayer.com/cgi/content/newReceived on Fri Jan 25 2002 - 10:07:02 CST