From: | Medhavi Mahansaria <medhavi(dot)mahansaria(at)tcs(dot)com> |
---|---|
To: | Kevin Grittner <kgrittn(at)ymail(dot)com> |
Cc: | Bill Moran <wmoran(at)potentialtech(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: #PERSONAL# Reg: date going as 01/01/0001 |
Date: | 2015-03-12 07:10:05 |
Message-ID: | OF1B64763B.99B76CB9-ON65257E06.0027430F-65257E06.002760A7@tcs.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Dear Kevin,
Thanks! it worked :)
Medhavi Mahansaria
Tata Consultancy Services Limited
Unit-VI, No.78, 79& 83,
L-Centre, EPIP Industrial Estate,
Whitefield
Bangalore - 560066,Karnataka
India
Ph:- +91 80 67253769
Cell:- +91 9620053040
Mailto: medhavi(dot)mahansaria(at)tcs(dot)com
Website: http://www.tcs.com
____________________________________________
Experience certainty. IT Services
Business Solutions
Consulting
____________________________________________
From: Kevin Grittner <kgrittn(at)ymail(dot)com>
To: Medhavi Mahansaria <medhavi(dot)mahansaria(at)tcs(dot)com>, Bill Moran
<wmoran(at)potentialtech(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Date: 03/06/2015 07:32 PM
Subject: Re: [GENERAL] #PERSONAL# Reg: date going as 01/01/0001
Medhavi Mahansaria <medhavi(dot)mahansaria(at)tcs(dot)com> wrote:
> Now my problem is that my bind variables are of string type and
> when the get a NULL value is converts it into an empty string in
> C++ programming.
> Example:
> insert into check_date values
> (to_date(:h1,'yyyymmddhh24miss'),
> 1,
> to_date(:h2,'yyyymmddhh24miss'));
>
> now h1 and h2 are of string datatype in my c++ program.
>
> If no value is there, it is passed on as a empty string into my
> query.
>
> How can I handle this to enter NULL values?
Well, arguably the best solution is to use a tool chain that
doesn't conflate any particular "magic value" with NULL. Where
that can't be done, you might want to look at the SQL standard's
NULLIF() construct.
insert into check_date values
(to_date(nullif(:h1, ''),'yyyymmddhh24miss'),
1,
to_date(nullif(:h2, ''),'yyyymmddhh24miss'));
If the two arguments to nullif() are equal, it returns NULL;
otherwise it returns the first argument.
--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Inder | 2015-03-12 11:15:51 | Re: Basic Question on Point In Time Recovery |
Previous Message | Tim Uckun | 2015-03-12 03:57:20 | Re: Benchmarking partitioning triggers and rules |