Related Link:
Here is my error:
ERROR: type \"e\" does not exist
Try replacing \'inactive\'
with ''inactive''
-- caution: two single quotes
SELECT *
FROM dblink('host=theHostName port=1234 dbname=theDBName user=theUser password=thePassword',
'SELECT field_1,
CASE WHEN field_2 IS NOT NULL
THEN ''inactive'' ELSE ''active''
END AS field_status
FROM the_table
')
AS linkresults(field_1 varchar(20),field_2 varchar(8))
Alternative (previous) solution
SELECT *
FROM dblink('host=theHostName port=1234 dbname=theDBName user=theUser password=thePassword',
'SELECT field_1,
CASE WHEN field_2 IS NOT NULL
THEN E\'inactive\' ELSE E\'active\'
END AS field_status
FROM the_table
')
AS linkresults(field_1 varchar(20),field_2 varchar(8))
Try this query:
SELECT *
FROM dblink('host=theHostName port=1234 dbname=theDBName user=theUser password=thePassword',
'SELECT field_1,
CASE WHEN field_2 IS NOT NULL
THEN $$inactive$$ ELSE $$active$$
END AS field_status
FROM the_table')
AS linkresults(field_1 varchar(20),field_2 varchar(8))