On Fri, 6 Mar 2015 15:24:28 +0530
Medhavi Mahansaria <medhavi.mahansaria@tcs.com> wrote:
> Hi Bill,
>
> Here are the details of the table and the query i want to insert.
>
>
> aml_db=> \d+ check_date
> Table "public.check_date"
> Column | Type | Modifiers | Storage | Stats
> target | Description
> -----------+-----------------------------+-----------+---------+--------------+-------------
> some_date | date | | plain | |
> sno | integer | | plain | |
> new_date | timestamp without time zone | | plain | |
> Has OIDs: no
>
>
> aml_db=> select * from check_date;
> some_date | sno | new_date
> -----------+-----+----------
> (0 rows)
>
>
> aml_db=> insert into check_date values
> (to_date('','yyyymmddhh24miss'),1,to_date('','yyyymmddhh24miss'));
> INSERT 0 1
> aml_db=> select * from check_date;
> some_date | sno | new_date
> ---------------+-----+------------------------
> 01/01/0001 BC | 1 | 01/01/0001 00:00:00 BC
> (1 row)
>
>
> I need to enter NULL as my date. but since I am getting these variables
> into the bind variables as empty string that is this issue is happening.
You're not inserting null, so it's hard to expect null to be the
result. Try:
INSERT INTO check_date VALUES (null, 1, null);
or even:
INSERT INTO check_date
VALUES (to_date(null, 'yyyymmddhh24miss'), 1, to_date(null, 'yyyymmddhh24miss'));
both of which result in what you desire.
null and the empty string are not the same thing.
--
Bill Moran