List:MySQL++« Previous MessageNext Message »
From:Ken Smith Date:April 6 2009 12:06pm
Subject:RE: Conditional insert of NULL
View as plain text  
P.S.  Apologies for the bad formatting in the example below...  Seems that something has
garbled it.  

----------------------------------------
> From: kenwsmith@stripped
> To: plusplus@stripped
> Subject: Conditional insert of NULL
> Date: Mon, 6 Apr 2009 13:03:45 +0100
>
>
> Hi
> Sorry if this sounds like my previous NaN question, but it's not quite the same...
> I want to conditionally insert null values into a table, but I'm getting zeros
> inserted, not nulls.
> I mistakenly thought I could initialise my variable to your defined mysqlpp::null
> value and then set it based on my threshold value.
> SSQLS looked like a nice solution until I discovered that I can't have more than 25
> columns (feel free to correct me if I'm wrong - which is highly possible!). Many of my
> tables have much more than 25 columns.
>
>
> Here's a piece of code with my simplistic approach...
>
> mysqlpp::Null myfloatfield(mysqlpp::null);
> if (condition) myfloatfield = 10.0;
> try { Connection conn(false); conn.connect("db", "localhost", "user", "password");
> Query query = conn.query();
> query << "INSERT INTO test_float " << "VALUES (" << "\"" <<
> myfloatfield << "\"" << ");";
>
> query.execute();...etc
> mysql> select * from test_float;+------+| id |+------+| 0 |
> +------+
> 1 row in set (0.00 sec)
>
> I know I can insert "null" as part of the query, but I need to do this conditionally
> without having to construct multiple queries.
> Thanks in advance,
> Ken
>
>
>
> _________________________________________________________________
> Beyond Hotmail — see what else you can do with Windows Live.
> http://clk.atdmt.com/UKM/go/134665375/direct/01/
> --
> MySQL++ Mailing List
> For list archives: http://lists.mysql.com/plusplus
> To unsubscribe: http://lists.mysql.com/plusplus?unsub=1
>

_________________________________________________________________
View your Twitter and Flickr updates from one place – Learn more!
http://clk.atdmt.com/UKM/go/137984870/direct/01/
Thread
Conditional insert of NULLKen Smith6 Apr
  • RE: Conditional insert of NULLKen Smith6 Apr
    • RE: Conditional insert of NULLKen Smith6 Apr
      • RE: Conditional insert of NULLKen Smith6 Apr
  • Re: Conditional insert of NULLWarren Young6 Apr