Update SQL statement doesn't work

Login to reply to this topic.
Tue, 2005-04-26 06:09
Joined: 2004-10-21
Forum posts: 58
Hi All,

I`m trying to update a table in my database using the following code


     _LIT(KSQLUpdate," UPDATE ConfigSettings SET Source=%S, Target=%S,
Audi=%d" );
     TBuf< 100> * tmpText=new(ELeave) TBuf< 100> ();
    CleanupStack::PushL(tmpText);
    tmpText-> Format(KSQLUpdate,& (iModel-> Source()),& (iModel->
Target()),iModel-> Audi);
   iEngineDB.Execute(*tmpText);
  CleanupStack::PopAndDestroy(tmpText);

Whenever I run this code I get an error saying Bad request.
I have gone through several other posts and all of them have used a SELECT
SQL query within a view in order
to update data within the table.

Is the usage of Update SQL Statement wrong here or do I have to use the
Update statement differently?
Is the updation of table only allowed through SELECT SQL query? Can`t I use
the update statement directly similar
to the INSERT statement?

Any help in this regard will be greatly appreciated.

Thanks & regards,
Asheesh

Tue, 2005-04-26 06:27
Joined: 2004-08-26
Forum posts: 34
Update SQL statement doesn't work
Don't know about Symbian DBMS, but generally, when inserting string values to an SQL table, shouldn't you put the string between apostrophes.
Code:
UPDATE table SET str='String here' WHERE id=1

For quality Symbian idling, join #symbian at irc.freenode.net

Tue, 2005-04-26 07:24
Joined: 2004-10-21
Forum posts: 58
Update SQL statement doesn't work
Hi,

I was able to solve the problem. Yes, it was due to the missing quotes for the characters and also a unwanted parentheses.
Also it isn't necessary to have a where clause in the update statement,
but the single quote clause did help.
Thanks for your help, marsten.

Regards,
Asheesh
  • Login to reply to this topic.