Opa salve galera!
Deparei-me com uma dúvida, estamos adaptando mais um módulo (que funciona em
Oracle) no PostgreSQL e tentei sem sucesso o uso de aliases em comandos
update, relendo a documentação vi que é possivel, mas na prática devo estar
errando em algo, será que podem me ajudar?
Cenário:
PostgreSQL 8.3.7 on x86_64-pc-linux-gnu, compiled by GCC gcc-4.3.real
(Ubuntu 4.3.2-1ubuntu11) 4.3.2
Base > 1T em UTF8.
Manual 8.3 [1]
UPDATE -- update rows of a table
Synopsis
UPDATE [ ONLY ] table [ [ AS ] alias ]
SET { column = { expression | DEFAULT } |
( column [, ...] ) = ( { expression | DEFAULT } [, ...] ) } [,
...]
[ FROM fromlist ]
[ WHERE condition | WHERE CURRENT OF cursor_name ]
[ RETURNING * | output_expression [ AS output_name ] [, ...] ]
Parameters
Table
The name (optionally schema-qualified) of the table to update.
Alias
A substitute name for the target table. When an alias is provided, it
completely hides the actual name of the table. For example, given UPDATE foo
AS f, the remainder of the UPDATEstatement must refer to this table as f not
foo.
Tentativa:
Update foo a set a.coluna = (select count(1) from outratabela where
codfoo=a.codfoo);
Erro:
Error: "ERROR: column "a" of relation "foo" does not exist
LINE 1: update foo a set a.coluna=(select count(1) from...
1 - <http://www.postgresql.org/docs/8.3/interactive/sql-update.html>
http://www.postgresql.org/docs/8.3/interactive/sql-update.html
" Falta de tempo é desculpa daqueles que perdem tempo por falta de métodos"
Att.
----------------------------------------------------------------------------
Rubens José Rodrigues
T.I, Analista de Suporte
Tel: (27)3399-6419 / (27)9969-8081
[email protected]
----------------------------------------------------------------------------
Broker Nestlé do Brasil S/A
Rua José Ramos de Oliveira, 91, 29111-280
Nossa Senhora da Penha, Vila Velha, ES
(27)3399-6400 / (27)9975-0140
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral