List:MySQL++« Previous MessageNext Message »
From:Alex Luya Date:March 13 2009 4:38am
Subject:How to construct a SQLQueryParms?
View as plain text  
> I have asked this,but can no understand your answer.
> Here,My goal is coping or updating records from a table to another.So 
> I want to push values to a "SQLQueryParms sqp",and then pass "sqp" to 
> query.excute(sqp).As you can  see,two questions  arise:
> 1,some value is NULL,how to handle these NULL values?
>    Should I do as following first:(assume the field type is char)
> ---------------------------
> Null<sql_char>  tempValue= res[1][i];
> sqp <<tempValue;
> ----------------------------------------
>
> 2,FieldType vary from one to another,some is Datetime,some is 
> float.....,Can I just put them into "SQLQueryParms sqp",then pass  
> "sqp" to query?Or I should do following first?
> Or I can not do this at all.
> ---------------------------------------
> if(type==Date) {//pseudo-code
>    sql_date tempValue= res[1][i];
>    sqp <<tempValue;
> }else if(type==int){
>    Null<sql_int>  tempValue= res[1][i];
>    sqp <<tempValue;
> }
>
> The last question is how to see what query sql has been built and 
> executed?I mean I want to see this:
> ---------------------------
> UPDATE calls SET date_entered=2008-12-23 03:26:04  and date_modified= 
> 2008-12-23 03:26:04.....
> ---------------------------------------
>> My code is like this:
>> ----------------------------------------------------------------------------- 
>>
>> try
>>    {
>>       query = clientConn.query(usql);
>>       query.parse();
>>
>>        SQLQueryParms sqp;
>>
>>        for (size_t i = 1; i <20; i++)
>>        {
>>            sqp << res[1][i];
>>        }
>>        //    put id into sqp for "where id=%q"
>>        sqp << res[1][0];
>>              query.execute(sqp);
>>        cout<<query.str()<endl;
>>     } catch (Exception& er)
>>    {
>>        cerr << "update: " << er.what() << endl;
>>    }
>> -------------------------------------------------------------------------- 
>>
>
>
>> result:
>> table has not been updated,no exception,no error.no output,So what is 
>> the problem here?
>
>
>>
>> usql is:
>> ----------------
>> UPDATE calls SET date_entered=%0 and date_modified=%1 and 
>> assigned_user_id=%2q and modified_user_id=%3q and created_by=%4q and 
>> name=%5q and duration_hours=%6 and duration_minutes=%7 and 
>> date_start=%8 and time_start=%9 and date_end=%10 and parent_type=%11q 
>> and status=%12q and direction=%13q and parent_id=%14q and 
>> description=%15 and deleted=%16 and reminder_time=%17 and 
>> outlook_id=%18q WHERE id=%19q
>> -----------------------
>>
>
>> the values of res[1] is
>> ----------------------------------------
>> fsfjl058230dfksdfk
>> 2008-12-23 03:26:04
>> 2008-12-23 03:26:04
>> 1
>> 1
>> 1
>> Get More information on the proposed deal
>> 0
>> 30
>> 2009-05-03
>> 09:00:00
>> 2009-05-03
>> Accounts
>> Planned
>> Outbound
>> 6b4f8eed-df99-d5bf-bc25-49505a8ce81f
>> NULL
>> 0
>> -1
>> NULL
>>
>
>
>
>   

Thread
How to push NULL into template query?Alex Luya11 Mar
  • Re: How to push NULL into template query?Warren Young11 Mar
  • Re: How to push NULL into template query?Alex Luya13 Mar
    • How to construct a SQLQueryParms?Alex Luya13 Mar
    • Re: How to push NULL into template query?Warren Young13 Mar
      • How to ?Alex Luya17 Mar
        • How to build from svn r2483?Alex Luya17 Mar
        • Re: How to ?Warren Young17 Mar
          • Re: How to ?Many files does not exist or is incomplete or subfixedwith .inAlex Luya18 Mar
            • Re: How to ?Many files does not exist or is incomplete or subfixedwith .inWarren Young18 Mar
              • got another errorAlex Luya18 Mar
                • Re: got another errorWarren Young19 Mar
                  • got another error after got another errorAlex Luya20 Mar
                    • Re: got another error after got another errorWarren Young20 Mar
                      • Re: got another error after got another errorWarren Young21 Mar
              • Got all files from running ./bootstracp,but compile errorAlex Luya19 Mar