2012-11-21 8 views
5

Sto tentando di eseguire una semplice query di aggiornamento su postgresql. Non capisco l'errore in quanto non esiste alcun valore booleano o tipo di colonna. Ecco il log:postgresql UPDATE errore "ERRORE: sintassi di input non valida per tipo booleano:"

cat=> UPDATE categories SET epekcategoryid='27af8b1e-c0c9-4084-8304-256b2ae0c8b2' and epekparentcategoryid='root' WHERE categoryId='281' and siteid='0' and categoryparentid='-1'; 
ERROR: invalid input syntax for type boolean: "27af8b1e-c0c9-4084-8304-256b2ae0c8b2" 
LINE 1: UPDATE categories SET epekcategoryid='27af8b1e-c0c9-4084-830... 

La tabella di configurazione:

cat=> \d categories; 
       Table "public.categories" 
     Column  |   Type   | Modifiers 
----------------------+-----------------------+----------- 
categoryid   | character varying(32) | 
categoryname   | text     | 
siteid    | integer    | 
categoryparentid  | character varying(32) | 
status    | integer    | default 0 
epekcategoryid  | text     | 
epekparentcategoryid | text     | 
categorylevel  | character varying(37) | 
categoryidpath  | character varying(37) |
+0

'WHERE categoryId = '281' e siteid = 0 e categoryp arentid = '- 1'; ' – wildplasser

+0

categorie UPDATE SET epekcategoryid = '27af8b' ed epekparentcategoryid = 'root' WHERE categoryId = '281' e siteid = 0 e categoryparentid = '- 1'; non funziona neanche – themihai

risposta

21

Prova:

UPDATE categories 
SET epekcategoryid='27af8b1e-c0c9-4084-8304-256b2ae0c8b2', 
    epekparentcategoryid='root' 
WHERE categoryId='281' 
    and siteid='0' 
    and categoryparentid='-1'; 

È necessario separare i campi in SET parte con ",", non con "AND"

+2

errore comune in effetti; usando 'AND' nella parte' SET' di una query 'UPDATE'. Dà errori insoliti come questo. – pyrocumulus

+0

mysql era il cattivo insegnante :) anche se è un po 'strano che non usiamo "AND" dopo SET ma usiamo dopo "WHERE" – themihai

+4

@mihai Non è strano, se ci pensate. 'AND' è un operatore. Come '+', '-' o' * '. Nella clausola 'WHERE' è' true AND false' come '3 + 5', ma in' SET' diventa strano 'var1 = true AND var2 = 3'. –

Problemi correlati