PostgreSQL
Posted: Sat Jul 31, 2010 12:47 pm
Hi,
the types 'numeric' and 'decimal' can be used in PostgreSQL for numbers of arbitrary precision; perfect for currencies etc.
The only problem (a problem for me anyhow!) is that Purebasic reports such columns as being of type #PB_Database_Long, which is clearly incorrect. Would it be possible to instead return 0 (unknown type) for such fields? I hesitate to request an addition to PB's list of #PB_Database... enumeration (such as #PB_Database_PreciseReal for example) because PB would then be left with the impossible task of retrieving such fields and making sense of them! Do we return them as floats, quads, strings... Such fields will be stored in different ways depending on the provider.
With a 'unknown type' return I would simply use GetDatabaseString() to retrieve the data (and indeed it works fine with PostgreSQL in these circumstances).
I ask because one of my apps works with databases which contain any kind of field and deals with arbitrary SQL strings. The program, for individual fields retrieved, first analyses the DatabaseColumnType() and acts accordingly. With unknown field types I retrieve the field with GetDatabaseString() and then undertake some additional processing in an attempt to identify the nature of the data therein etc. I compare with the user's locale settings and so on. You will quickly see, however, that my program is being caught out with PostgreSQL's numeric and decimal fields since they are reported as being of integer type!
Report them as 'unknown' and I'm back in business!
Thanks.
the types 'numeric' and 'decimal' can be used in PostgreSQL for numbers of arbitrary precision; perfect for currencies etc.
The only problem (a problem for me anyhow!) is that Purebasic reports such columns as being of type #PB_Database_Long, which is clearly incorrect. Would it be possible to instead return 0 (unknown type) for such fields? I hesitate to request an addition to PB's list of #PB_Database... enumeration (such as #PB_Database_PreciseReal for example) because PB would then be left with the impossible task of retrieving such fields and making sense of them! Do we return them as floats, quads, strings... Such fields will be stored in different ways depending on the provider.
With a 'unknown type' return I would simply use GetDatabaseString() to retrieve the data (and indeed it works fine with PostgreSQL in these circumstances).
I ask because one of my apps works with databases which contain any kind of field and deals with arbitrary SQL strings. The program, for individual fields retrieved, first analyses the DatabaseColumnType() and acts accordingly. With unknown field types I retrieve the field with GetDatabaseString() and then undertake some additional processing in an attempt to identify the nature of the data therein etc. I compare with the user's locale settings and so on. You will quickly see, however, that my program is being caught out with PostgreSQL's numeric and decimal fields since they are reported as being of integer type!


Thanks.