Thread: rsmd.getPrecision(i) + rsmd.isNullable(i)

rsmd.getPrecision(i) + rsmd.isNullable(i)

From
Jens Haberer
Date:
Hello,

i have follwing table:

"s1" bpchar(12)
"s23" numeric(5,2)
"s12" varchar(12)
"s93" timestamptz

when i export the stucture of this table with a java program i get following
results:

name type precision scale nullable (from the resultsetmetadata object)
s1 1 0 0 2
s23 2 5 2 2
s12 12 0 0 2
s93 93 0 0 2

why is precision of "s1" 0?
why is precision of "s12" 0?
why ist nullable always 2? Other databases have 0 or 1!

i tried lot of jdbc driver from http://jdbc.postgresql.org/download/

greetings

jens haberer

--
+++ GMX - Mail, Messaging & more  http://www.gmx.net +++
Bitte lächeln! Fotogalerie online mit GMX ohne eigene Homepage!


Re: rsmd.getPrecision(i) + rsmd.isNullable(i)

From
Barry Lind
Date:
Jens,

 From the javadoc for ResultSetMetadata:

getPrecision:  Get the designated column's number of decimal digits.

The javadoc implies that getPrecision is only for numeric datatypes.
What does 'number of decimal digits' mean for a text column?

As for the isNullable() return value, the driver has no way to determine
if the underlying column in the query is nullable or not, so it returns
the proper value in this case which is: 2 (columnNullableUnknown).

thanks,
--Barry


Jens Haberer wrote:
> Hello,
>
> i have follwing table:
>
> "s1" bpchar(12)
> "s23" numeric(5,2)
> "s12" varchar(12)
> "s93" timestamptz
>
> when i export the stucture of this table with a java program i get following
> results:
>
> name type precision scale nullable (from the resultsetmetadata object)
> s1 1 0 0 2
> s23 2 5 2 2
> s12 12 0 0 2
> s93 93 0 0 2
>
> why is precision of "s1" 0?
> why is precision of "s12" 0?
> why ist nullable always 2? Other databases have 0 or 1!
>
> i tried lot of jdbc driver from http://jdbc.postgresql.org/download/
>
> greetings
>
> jens haberer
>




Re: rsmd.getPrecision(i) + rsmd.isNullable(i)

From
"Jens Haberer"
Date:
when you create a table with a alphanumeric column you specify a length for
this column
every other database return this length when you perform the
"getPrecision()" method for this column.
what would you do if you'd like to make a java program which copies a table
from database XXX into YYY
and you don't know how long this alphanumeric column is???

----- Original Message -----
From: "Barry Lind" <blind@xythos.com>
To: "Jens Haberer" <gock@gmx.de>
Cc: <pgsql-jdbc@postgresql.org>
Sent: Monday, June 09, 2003 5:52 PM
Subject: Re: [JDBC] rsmd.getPrecision(i) + rsmd.isNullable(i)


> Jens,
>
>  From the javadoc for ResultSetMetadata:
>
> getPrecision:  Get the designated column's number of decimal digits.
>
> The javadoc implies that getPrecision is only for numeric datatypes.
> What does 'number of decimal digits' mean for a text column?
>
> As for the isNullable() return value, the driver has no way to determine
> if the underlying column in the query is nullable or not, so it returns
> the proper value in this case which is: 2 (columnNullableUnknown).
>
> thanks,
> --Barry
>
>
> Jens Haberer wrote:
> > Hello,
> >
> > i have follwing table:
> >
> > "s1" bpchar(12)
> > "s23" numeric(5,2)
> > "s12" varchar(12)
> > "s93" timestamptz
> >
> > when i export the stucture of this table with a java program i get
following
> > results:
> >
> > name type precision scale nullable (from the resultsetmetadata object)
> > s1 1 0 0 2
> > s23 2 5 2 2
> > s12 12 0 0 2
> > s93 93 0 0 2
> >
> > why is precision of "s1" 0?
> > why is precision of "s12" 0?
> > why ist nullable always 2? Other databases have 0 or 1!
> >
> > i tried lot of jdbc driver from http://jdbc.postgresql.org/download/
> >
> > greetings
> >
> > jens haberer
> >
>
>
>


Re: rsmd.getPrecision(i) + rsmd.isNullable(i)

From
Fernando Nasser
Date:
I think you want getColumnDisplaySize().

As Barry said, getPrecision is just for numeric fields.

Fernando


Jens Haberer wrote:
> when you create a table with a alphanumeric column you specify a length for
> this column
> every other database return this length when you perform the
> "getPrecision()" method for this column.
> what would you do if you'd like to make a java program which copies a table
> from database XXX into YYY
> and you don't know how long this alphanumeric column is???
>
> ----- Original Message -----
> From: "Barry Lind" <blind@xythos.com>
> To: "Jens Haberer" <gock@gmx.de>
> Cc: <pgsql-jdbc@postgresql.org>
> Sent: Monday, June 09, 2003 5:52 PM
> Subject: Re: [JDBC] rsmd.getPrecision(i) + rsmd.isNullable(i)
>
>
>
>>Jens,
>>
>> From the javadoc for ResultSetMetadata:
>>
>>getPrecision:  Get the designated column's number of decimal digits.
>>
>>The javadoc implies that getPrecision is only for numeric datatypes.
>>What does 'number of decimal digits' mean for a text column?
>>
>>As for the isNullable() return value, the driver has no way to determine
>>if the underlying column in the query is nullable or not, so it returns
>>the proper value in this case which is: 2 (columnNullableUnknown).
>>
>>thanks,
>>--Barry
>>
>>
>>Jens Haberer wrote:
>>
>>>Hello,
>>>
>>>i have follwing table:
>>>
>>>"s1" bpchar(12)
>>>"s23" numeric(5,2)
>>>"s12" varchar(12)
>>>"s93" timestamptz
>>>
>>>when i export the stucture of this table with a java program i get
>>
> following
>
>>>results:
>>>
>>>name type precision scale nullable (from the resultsetmetadata object)
>>>s1 1 0 0 2
>>>s23 2 5 2 2
>>>s12 12 0 0 2
>>>s93 93 0 0 2
>>>
>>>why is precision of "s1" 0?
>>>why is precision of "s12" 0?
>>>why ist nullable always 2? Other databases have 0 or 1!
>>>
>>>i tried lot of jdbc driver from http://jdbc.postgresql.org/download/
>>>
>>>greetings
>>>
>>>jens haberer
>>>
>>
>>
>>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>


--
Fernando Nasser
Red Hat Canada Ltd.                     E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9