Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Novice > data type of st...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 3013 of 3322
Post > Topic >>

data type of string literal

by nobs@[EMAIL PROTECTED] (Emil Obermayr) Feb 26, 2008 at 09:42 AM

Hi List,

I just joined because I found a behaviour of implicit casts I don't
understand. I am quite new to Postgre, trying out things and 
tried this sql-code:

select cast('8.000' as text) = 8.00 as test, 1 as case
union 
select cast('8.000' as text) = 8.000, 2
union  
select '8.00' = 8.000, 3

This gives me the following result:

test => f	case => 1
test => t	case => 2
test => t	case => 3

Why is the string literal in case 3 parsed as float so the 
comparision is true. While in the other cases the 
float literal is auto-casted to a string, so the 
comparision is only true if the number of zeros is equal?

Is there a exact column type that fits a string literal? Explicit
casts to char or varchar instead of text gives the same results.

Yours,

Emil 'nobs' Obermayr

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




 2 Posts in Topic:
data type of string literal
nobs@[EMAIL PROTECTED] (  2008-02-26 09:42:05 
Re: data type of string literal
tgl@[EMAIL PROTECTED] (T  2008-02-26 10:24:37 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Dec 5 4:06:52 CST 2008.