MT wrote:
> Hi,
>
> }
> else if (param["new_unitcnt"] != param["old_unitcnt"])
> {
> sql += "unitcnt = '" + param["new_unitcnt"] + "',";
> }
> else if (param["new_wprice"] != param["old_wprice"])
> {
> sql += "wprice = " + param["new_wprice"];
> }
>
> sql += "WHERE prodid = '" + param["prodid"] + "'";
>
> int res = conn.Exec (sql.c_str()); //sql exec
>
> Now the problem occurs when a user only wants to update certain columns,
> which creates a syntax problem due to the comma (","). In other words
> you cannot end a multiple column UPDATE statement with a comma
> followed by:
Before you process the WHERE clause....you need to backtrack and delete any
dangling ','. I'm not sure how you'd do it in pure C++ but in perl you'd say
$SQL =~ s/,$//
ie remove the last comma....
You'll also run into this problem when constructing WHERE clause items
where you
have have a 'AND' or similar operators at the end....
> er the program will run.
>
> Thanks,
>
> Mark Tessier
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)