<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi everyone,<br>
<br>
I am currently working on an app that is split into several databases
with the same table but a column with differing data type.<br>
<br>
eg. Database 1 <br>
tablename: gp<br>
column: available - data type boolean<br>
<br>
Database 2<br>
tablename: gp<br>
column: available - data type character(1)<br>
<br>
I would like to be able to create a query that returns 'T' or 'F' using
the same code & query.<br>
<br>
I have tried a few different cast() options without success - and then
tried:<br>
<br>
<font color="#000066"><small>SELECT<br>
CASE<br>
WHEN ((SELECT data_type FROM information_schema.columns WHERE
table_name = 'gp' and column_name = 'available') = 'boolean') THEN <br>
CASE<br>
WHEN (available) THEN 'T'<br>
ELSE 'F'<br>
END <br>
ELSE <br>
CASE<br>
WHEN (available='T' OR available='t') then 'T'<br>
ELSE 'F'<br>
END<br>
END as available<br>
FROM<br>
gp<br>
</small></font><br>
<br>
When I run this query on the boolean data type database it works
correctly - however on the character field I get the error <font
color="#ff0000"><small>'ERROR: argument of CASE/WHEN must be type
boolean, not type character'</small></font><br>
<br>
I really don't want to go through and change data types just at the
moment - can anyone advise any way around this?<br>
<br>
Many thanks,<br>
Gus<br>
<br>
</body>
</html>