PostgreSQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesPostgreSQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old April 18th, 2008, 10:02 AM
hdhruv hdhruv is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 2 hdhruv User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 14 sec
Reputation Power: 0
Question Bit to text

Hello,

I am trying to convert bits to text.
query -
select 127::bit(6)
returns: 111111

I tried select 127::bit(6)::text but that returns -
ERROR: cannot cast type bit to text

This I want to convert to string/text so that I can display this.

Thanks in advance
-Hrishi

Reply With Quote
  #2  
Old April 18th, 2008, 10:21 AM
pgFrank's Avatar
pgFrank pgFrank is offline
So help me Codd
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Location: Brazil
Posts: 129 pgFrank User rank is Sergeant (500 - 2000 Reputation Level)pgFrank User rank is Sergeant (500 - 2000 Reputation Level)pgFrank User rank is Sergeant (500 - 2000 Reputation Level)pgFrank User rank is Sergeant (500 - 2000 Reputation Level)pgFrank User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 17 h 45 m 53 sec
Reputation Power: 18
Use some extra (): SELECT (127::bit(6))::text;

The result of 127::bit(6) will be cast to text.

Edit: Looks like version 8.2 and 8.3 behave differently. 8.2 gives an error while 8.3 works fine.
__________________
PostgreSQL-manual

Last edited by pgFrank : April 18th, 2008 at 10:24 AM.

Reply With Quote
  #3  
Old April 21st, 2008, 06:50 PM
hdhruv hdhruv is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 2 hdhruv User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 14 sec
Reputation Power: 0
Thanks a lot for this.
I am currently using 8.2 but I can consider moving to 8.3.

Thanks again
-Hrishi

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesPostgreSQL Help > Bit to text


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway