By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,358 Members | 1,292 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,358 IT Pros & Developers. It's quick & easy.

Casting int to bool with join...

P: n/a
I am trying to update rows in a new table and re-cast to boolean at the
same time. I am absolutely certain that the integers are 0 or 1. Is
there a one line way to do this?

UPDATE app_id_800 SET cal_byte_w_err = cal_byte_w_err.value::boolean
FROM cal_byte_w_err
WHERE app_id_800.timestamp BETWEEN '2004-01-01 00:00:00' AND
'2004-01-01 00:00:05'
AND app_id_800.timestamp = cal_byte_w_err.timestamp;

Many thanks... I've spent way too long trying to figure this out :(

Cheers,
Randall
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #1
Share this Question
Share on Google+
2 Replies

P: n/a
Got it.

UPDATE app_id_800 SET cal_byte_w_err = (CASE WHEN
cal_byte_w_err.value=1 THEN 't'::boolean ELSE 'f'::boolean END)
FROM cal_byte_w_err
WHERE app_id_800.timestamp BETWEEN '2004-01-01 00:00:00' AND
'2004-01-01 00:00:05'
AND app_id_800.timestamp = cal_byte_w_err.timestamp;

Have a good weekend all.
Randall

On 2 Apr 2004, at 18:05, Randall Skelton wrote:
I am trying to update rows in a new table and re-cast to boolean at
the same time. I am absolutely certain that the integers are 0 or 1.
Is there a one line way to do this?

UPDATE app_id_800 SET cal_byte_w_err = cal_byte_w_err.value::boolean
FROM cal_byte_w_err
WHERE app_id_800.timestamp BETWEEN '2004-01-01 00:00:00' AND
'2004-01-01 00:00:05'
AND app_id_800.timestamp = cal_byte_w_err.timestamp;

Many thanks... I've spent way too long trying to figure this out :(

Cheers,
Randall

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 23 '05 #2

P: n/a
On Fri, 2 Apr 2004 18:21:34 -0500, Randall Skelton
<sk*****@brutus.uwaterloo.ca> wrote:
UPDATE app_id_800 SET cal_byte_w_err = (CASE WHEN
cal_byte_w_err.value=1 THEN 't'::boolean ELSE 'f'::boolean END)


or simply

UPDATE app_id_800
SET cal_byte_w_err = (cal_byte_w_err.value=1)

Servus
Manfred

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.