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
>