0

I've got a Postgres DB with a table named "precipitazione". What I want to do is update its column "quantita" when it shows a value of -9999. My statement :

 UPDATE precipitazione SET quantita = 0 WHERE quantita = -9999;

is not working(It is not working in the sense that the query won't be executed. It gives me a syntax error "near SET") I also tried to set "quantita" to DEFAULT (which is zero),but it's still not working.

SELECT * FROM precipitazione WHERE quantita = -9999;

is working.

Postgres VERSION: PostgreSQL 9.3.10

smart548
  • 41
  • 7
  • 2
    Not working is very vague. – Mihai Dec 09 '15 at 16:29
  • It is not working in the sense that the query won't be executed. It gives me a syntax error. – smart548 Dec 09 '15 at 16:46
  • There doesn't seem to be anything wrong with your update statement. Is this the only statement in the batch that you are trying to execute? – jpw Dec 09 '15 at 17:06
  • And what **is** the (exact) error? –  Dec 09 '15 at 17:06
  • It is in italian but I believe it is comprehensible. A rough translation would be: SQL ERROR: ERROR: syntax error in or near "SET" LINE 1: ...ECT COUNT(*) AS total FROM (UPDATE precipitazione SET quanti... The original error below: "Errore SQL: ERRORE: errore di sintassi a o presso "SET" LINE 1: ...ECT COUNT(*) AS total FROM (UPDATE precipitazione SET quanti..." – smart548 Dec 09 '15 at 17:09
  • You cannot wrap an update in a select like that. If you want to get a count of rows affected by the update take a look at the answer here: http://stackoverflow.com/a/25941849/1175077 – jpw Dec 09 '15 at 17:18
  • The error message doesn't match the statement you have shown us. How and with which tool are you running this update? If you are _really_ running the update as shown, then your SQL tool messes with the statement. –  Dec 09 '15 at 19:27
  • 1
    If you are using **phppgadmin** this is a known bug. Your query is ok, try it in psql. – klin Dec 09 '15 at 20:21
  • klin, you nailed it! ;) That was it. Can you post a link to a list of this "known bugs" sir/lady? – smart548 Dec 09 '15 at 22:37

0 Answers0