dBLib

Terence Heaford t.heaford at btinternet.com
Thu Sep 11 05:26:33 EDT 2014


May have found the answer in the following handler in dbLib.

I have commented out an “if” test that seems to overwrite the contents of the column dbWhere when you try and add another condition.

Why the author did this, I am not sure, would anyone care to hazard a guess?

Thanks

Terry
 

command dbWhere pColumn, pValue, pConcatenationOperator
   if the number of words in pColumn > 1 then
      put word 2 of pColumn into tOperator
      put word 1 of pColumn into pColumn
   else
      put "=" into tOperator
   end if
   
   if pValue is "null" then
      put "IS" into tOperator
      put "NULL" into pValue
   end if
   
   if pValue is "not null" then
      put "IS NOT" into tOperator
      put "NULL" into pValue
   end if
   
   if pConcatenationOperator is empty then
      put "AND" into pConcatenationOperator
   end if
   
   
   
   --if dbA["where columns"][pColumn] is empty then
      if dbA["where"] is empty then
         put "WHERE" && pColumn && tOperator && placeholder(pValue) before dbA["where"]
      else
         put " " & pConcatenationOperator  && pColumn && tOperator && placeholder(pValue) after dbA["where"]
      end if
   --else 
      --replace dbA["where columns"][pColumn] with (pColumn && tOperator && placeholder(pValue)) in dbA["where"]
   --end if
   
   set the itemdel to space
   put item -3 to -1 of dbA["where"]  into dbA["where columns"][pColumn]
end dbWhere





On 11 Sep 2014, at 10:03, Terence Heaford <t.heaford at btinternet.com> wrote:

> Thought I’d give this plugin a try:
> 
> convert tStartDate from short system date to seconds
> convert tEndDate from short system date to seconds
> 
> dbResetQuery
> 
> dbWhere "category", pItemName
> 
> dbWhere "date >=", tStartDate
> 
> dbWhere "date <=", tEndDate
> 
> dbOrderBy “date"
> 
> put dbGet(sq(tTableName)) into tTranData
> 
> tStartDate and tEndDate are in seconds.
> 
> The SQL generated is 
> 
> SELECT * FROM ‘my table' WHERE category = :1 AND date <= :3  ORDER BY date
> 
> Why is it not including tStartDate?
> 
> Can anyone help?
> 
> Thanks
> 
> Terry
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




More information about the use-livecode mailing list