B4J Question Resultset "GetBoolean" equivalent of "GetString" method

j_o_h_n

Active Member
Licensed User
For Postgresql (not tried it with any other database), the GetString method of a Resultset object returns a "t" for a True value and "f" for a False value.

These give an error if you try to assign them directly to a Boolean variable, so you have stick in
an If clause to test and assign appropriately

Is this just the way it is or is there a better way?

Thanks
 

udg

Expert
Licensed User
Longtime User
Dim myboolvar as boolean =("t" =myresultset.getstring("field4"))
Sorry I'm using a very small device and typing is difficult.
 
Upvote 0

j_o_h_n

Active Member
Licensed User
B4X:
Dim myboolvar as boolean = ("t" = myresultset.getstring("field4"))

That's neat, thanks!

EDIT:
Because I have repeat it for quite a few columns I'm actually going to mix agraham's suggestion with yours with yours.
ie putting your code into a function, it's really succinct.
B4X:
Dim myboolvar as boolean = bReturn(myresultset.getstring("field4"))

Private Sub bReturn(s As String) As Boolean
        Return  ("t" = s)
End Sub
 
Last edited:
Upvote 0
Top