Forum > Databases

[Solved] Error on update to PGSQL 9

(1/2) > >>

MOVNet:
Hi.

I'm facing an issue when I'm trying to update a table.

The database connection is OK, I can successfully select the database but when I try to do an update I got the error shown at Error.png (attached).

Here the code:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---        QDB_SHOT.Close;        sql:='';        sql:=sql+'UPDATE  config ';        sql:=sql+'set keyaddress = ' + #39 + nkey + #39 + ' ';        sql:=sql+'where ';        sql:=sql+'keyaddress =' + #39 + key + #39 + ' ';        QDB_Shot.Clear;        QDB_Shot.SQL.Add(sql);        QDB_Shot.ExecSQL;        TDB_Shot.Commit;        TDB_Shot.EndTransaction;        QDB_Shot.Close;                                             
The code stops at ExecSQL line.

I have no clue of what is happening. I can update the table using PGADMIN software with the same credentials (role/user).

Can anyone help me?

Best Regards,

Marcelo

MarkMLl:
What happens when you use psql to enter the *exact* text that the debugger shows is in your sql variable?

MarkMLl

dsiders:

--- Quote from: MarkMLl on August 16, 2024, 09:49:07 pm ---What happens when you use psql to enter the *exact* text that the debugger shows is in your sql variable?

MarkMLl

--- End quote ---

It's the unbalanced quoting inside the sql string.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---sql := 'update config set keyaddress=''' + nkey + ''' where keyaddress=''' + nkey + '''';

MarkMLl:
Well spotted.

MarkMLl

MOVNet:
Hi

Thank you for the answers.

The sql variable value is correct as bellow:


--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---update config set keyaddress = '2024081601' where keyaddress ='2128781475' ; 
The quoting are done with #39 (Char code) as you can see in the code.
I get the sql value and put at PGADMIN: the update was done as expect.

I have another software with the same procedure type, and it works fine. The difference is that the other software connect to a Postgres 14 and this one connect to a Postgres 9 database.

Regards,

Marcelo
 

Navigation

[0] Message Index

[#] Next page

Go to full version