PDA

View Full Version : How to get the correct type for PSQL "time" and "timestamp" colomns



Bernhard Mandl
1-Sep-2005, 10:22 AM
get_attribute DF_FIELD_TYPE returns DF_BCD for PSQL "time" and "timestamp"
columns. In some way this is correct because the values of these colunns are
returned as numbers, but it is not very helpful when I need information how
to format the value for display.

Is there any way to get the correct type from the driver?

Thanks
Bernhard

Bernhard Mandl
1-Sep-2005, 11:14 AM
This workaround seems to work:

if (fieldLength = 8 and fieldNativeLength = 4 and fieldPrecision =
0) // TIME
else if (fieldLength = 18 and fieldNativeLength = 8 and fieldPrecision = 7)
// TIMESTAMP
else // number

is this safe or can other datatypes produce the same combination?

Anders Öhrt
2-Sep-2005, 01:30 AM
> if (fieldLength = 8 and fieldNativeLength = 4 and fieldPrecision =
> 0) // TIME
> else if (fieldLength = 18 and fieldNativeLength = 8 and fieldPrecision =
> 7) // TIMESTAMP
> else // number
>
> is this safe or can other datatypes produce the same combination?

That is most likely unsafe. Any Num 8 should match the first and there
should be something similar matching the second (Num 9,7?). Try it and see
if that conflicts.

// Anders

Bernhard Mandl
2-Sep-2005, 09:19 AM
I was not able to figure out any other column definition that produces the
same result.

Would you mind to give me an example which num 8 column definition matches
the first?

"Anders Öhrt" <Anders.Ohrt@capslock.se> schrieb im Newsbeitrag
news:2P7r8e4rFHA.3960@dacmail.dataaccess.com...
>
>> if (fieldLength = 8 and fieldNativeLength = 4 and fieldPrecision
>> =
>> 0) // TIME
>> else if (fieldLength = 18 and fieldNativeLength = 8 and fieldPrecision =
>> 7) // TIMESTAMP
>> else // number
>>
>> is this safe or can other datatypes produce the same combination?
>
> That is most likely unsafe. Any Num 8 should match the first and there
> should be something similar matching the second (Num 9,7?). Try it and see
> if that conflicts.
>
> // Anders
>

Anders Öhrt
2-Sep-2005, 03:20 PM
>I was not able to figure out any other column definition that produces the
> same result.

A Num 8,0 has field length 8 and precision 0, and should fit nice in 4 byte.
Don't you get the same info from a sure field?

// Anders

Bernhard Mandl
5-Sep-2005, 07:57 AM
Length of PSQL Decimal columns is always an odd number because a half byte
is reserved for the sign.


"Anders Öhrt" <Anders.Ohrt@capslock.se> schrieb im Newsbeitrag
news:boJT5u$rFHA.1896@dacmail.dataaccess.com...
>
>>I was not able to figure out any other column definition that produces the
>> same result.
>
> A Num 8,0 has field length 8 and precision 0, and should fit nice in 4
> byte. Don't you get the same info from a sure field?
>
> // Anders
>