PostgreSQL

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

PostgreSQL

Post by srod »

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! :wink:

Thanks.
I may look like a mule, but I'm not a complete ass.