Getting recordset column type

Hi,
Just want to check if anyone encountered problems checking for column types using the function recordset.ColumnType(idx).

I get weird results with PostgreSQL. Boolean become unknown, Int become strings…

Any clue?

I believe idx is 1-based there, like IdxField, not zero-based, i.e., the first column is idx=1, not idx=0.

Yes, that’s one of the few places in the global framework where it is 1-based.

Fun stuff, the new iOSSQLiteRecordset.idxField is 0-based. That will screw all of us old-timers over for sure. :slight_smile:

String indexes are 1-based too.

I support the decision to standardize on zero-based in the new framework though. Remembering which is which is a bear.

Thanks! That must be the problem… I’ll get that right. Thanks!!!

Zero or One based: I do not care if the same value is used everywhere.

[quote=320250:@Roger St-Arneault]Hi,
Just want to check if anyone encountered problems checking for column types using the function recordset.ColumnType(idx).

I get weird results with PostgreSQL. Boolean become unknown, Int become strings…

Any clue?[/quote]

I am getting strange Results in SQLite even…

		For i=1 To resultsRecordSet.FieldCount
				colType.append resultsRecordSet.ColumnType(i)
		Next i

Most BOOLEAN fieldtypes come back as 12 (which jives with the LR for RecordSet.Columntype)
but I have some places where it comes back as 41
Is this a BUG in Xojo? or is the LR not up to date?
I need to be able to classify the field datatypes, regardless of the source of the data

Bizarre… SQLite doesn’t have a boolean type. 12 shouldn’t be returned since It uses integer to store boolean… I think you should get 3 for a boolean coming from a SQLite database field… Someone else should confirm that since my knowledge is limited… :slight_smile:

No it does return 12 as expected… (and yes I know SQLite is rather data ambigious… it has data stores, not datatypes)

But I found my mistake. It seems that Xojo is not consistent in what is a 1-based array of values, and what is a zero based.

I was using IDXFIELD which is 1-based combined with rs.ColumnType which is ZERO based…

So the ColumnType was being returned for an undefined database column (1 beyond the upper bound)… Funny that it did not return an OUT OF BOUNDS error

I made the same mistake… Glad not to be the only one… :slight_smile: