Re: [SQL] dblinks

2008-05-19 Thread Dave Page
On Mon, May 19, 2008 at 4:06 AM, Ramasubramanian G
<[EMAIL PROTECTED]> wrote:
> HI Sumaya,
>
> This is the way you have to use dblink. And one more think. To
> excute this query you nedd to have dblink functions installed in your
> database schema.
>
> select * from dblink('YOUR_DB_LINK_NAME','select * from mytable')as
> tmp(column1 datatype,column2 datatype.)

The OP was using EnterpriseDB's Postgres Plus Advanced Server, which
has Oracle-style dblinks built in. They are not used in the same way
as the PostgreSQL dblink module.

-- 
Dave Page
EnterpriseDB UK: http://www.enterprisedb.com

-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


[SQL] Supplying a default on read, if a column does not exist in DB

2008-05-19 Thread Bryce Nesbitt
Is there a clean way in Postgres to specify a default return value, if a 
column does not exist in a database?  In pseudocode:


select p_email,
CASE WHEN EXISTS("p_email_alt") THEN p_email_alt ELSE 'none' END
from eg_application;

I can kind of almost get there with:

select p_email,
CASE WHEN EXISTS(SELECT * FROM information_schema.columns
WHERE table_schema='public' and table_catalog='stage' and 
table_name='eg_application' and column_name='p_email_alt')

THEN p_email_alt ELSE 'none' END
from eg_application;

Except that Postgres evaluates the non-existent column name in the 
"THEN", and errors out, even though the test will be false.


Note that use of stored procedures won't work for my particular use case.

-Bryce

Google Keywords: "if column exists", "if column defined", test for 
existence of column, default column value, defaults, information schema, 
existence, definition, missing column.


--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql