Add support for Fortran LOGICAL type
I understand that SQLite3 does not have a separate boolean datatype but allows the declaration of columns with boolean type and stores these as integers (1 or 0). I have a Fortran application where I would like to read booleans out of an sqlite table directly into a Fortran LOGICAL
type variable. To support this in a clean way that dosen't involve intrinsic conversion from INTEGER
to LOGICAL
(although this is supported by gfortran), I would like to propose adding the following function to sqliteff.f90
:
function sqliteff_column_bool(statement, col) result(val)
type(SqliteStatement_t), intent(inout) :: statement
integer, intent(in) :: col
integer :: ival
logical :: val
interface
function csqlite3_column_int( &
handle, &
col) &
result(val) &
bind(C, name = "csqlite3_column_int")
import c_int, c_ptr
type(c_ptr), intent(inout) :: handle
integer(kind=c_int), value, intent(in) :: col
integer(kind=c_int) :: ival
end function csqlite3_column_int
end interface
ival = csqlite3_column_int(statement%handle, col)
if (ival == 0) then
val = .false.
else
val = .true.
end if
end function sqliteff_column_bool
I have implemented and tested the function in my own installation and it works as expected.
Thanks for developing this very useful package!