coding for multiple databases

Mark Wieder mwieder at ahsoftware.net
Sat Mar 23 14:08:28 EDT 2013


Richard-

Saturday, March 23, 2013, 10:45:30 AM, you wrote:

> Anyway, to deal with queries where I have to use non-standard syntax, it
> seems that I can have switches:

> switch dbTyp
> case postgres
> put "SELECT * FROM mytable WHERE icare=True" into dcmd
> break
> case mySql
> put "SELECT * FROM mytable WHERE icare=1" into dcmd
> break
> case SQLite
> put "SELECT * FROM mytable WHERE icare='TRUE'" into dcmd
> break
> end switch

If you end up needing to do that, I would code it as

put "SELECT * FROM mytable WHERE icare=" & dbBoolean(dbTyp) into dcmd

function dbBoolean pDbType
  local tBoolean
  
  switch pDbType
    case mySql
      put 1 into tBoolean
      break
    case SQLite
      put "'TRUE'" into tBoolean
      break
    default
      put "True" into tBoolean
  end switch
  return tBoolean
end dbBoolean

-- 
-Mark Wieder
 mwieder at ahsoftware.net





More information about the use-livecode mailing list