I want to achieve the following behaviour NULL AS (Oracle database):
CREATE OR REPLACE VIEW cuentaahorroview AS
SELECT IBAN as CCC, Interes, Ultimo_devengo
FROM De_Ahorro
UNION
SELECT CCC, TIPOINTERES as Interes, null as Ultimo_devengo
FROM CUENTAAHORRO@SCHEMA2BD2;
in a PostgreSQL database:
CREATE VIEW EditorialView AS
SELECT *
FROM dblink('hostaddr=127.0.0.1 port=5432 dbname=bdp3e1 user=postgres password=1234', 'SELECT * FROM Editorial')
AS t1(nombre VARCHAR(100), CIF integer, ubicacion VARCHAR(50))
UNION
SELECT *
FROM dblink('hostaddr=127.0.0.1 port=5432 dbname=bdp3e2 user=postgres password=1234', 'SELECT * FROM Editorial')
AS t2(nombre VARCHAR(100), CIF integer, NULL);
so as the union to work. How can I do it?
This is the error I'm getting:
psql:PR3_Vistas.sql:10: ERROR: syntax error at or near "NULL"
LINE 8: AS t2(nombre VARCHAR(100), CIF integer, NULL);
select *withselect field1, field2, ...and useNULL as fieldxin second part of union.select *is always bad in unions - you can't be sure that both tables have identical structure.