Subject Re: DBF level 4 to 7 Problem
From Ken Mayer <dbase@nospam.goldenstag.net>
Date Tue, 14 Mar 2017 11:12:08 -0700
Newsgroups dbase.getting-started

On 3/14/2017 10:28 AM, Akshat Kapoor wrote:
> On 14/03/2017 21:58, Peter wrote:
>> Akshat Kapoor Wrote:
>>
>>>> As you have understood right from the start (and is noted in
>>>> language reference when changing level), the change from Level 4 to
>>>> 7 has changed any field that is empty to null.
>>>> Mervyn Bick's program is:
>>>>
>>>>
>>>>  q = new query()
>>>>  q.sql = "select * from 'c:\pat\data\patient.dbf'"
>>>>  q.active = true
>>>>  q.rowset.first()
>>>>  do while not q.rowset.endofset
>>>>      for n = 1 to q.rowset.fields.size
>>>>         if q.rowset.fields[n].type = "C"   // or "N"
>>>>            if q.rowset.fields[n].value = null
>>>>               q.rowset.fields[n].value = ""   // 0 for "N"
>>>>           endif
>>>>           ? q.rowset.fields[n].value
>>>>         endif
>>>>      next
>>>>      q.rowset.next()
>>>>  enddo
>>>>  q.active = false
>>>>
>>>> There are no empty number fields to mess with. Hopefully Logical
>>>> fields are not affected.  But I do have some date fields that are
>>>> empty, and are changed to null.  What string do I use to change
>>>> these null date fields to empty strings?  Same as for Character
>>>> fields, ie ""?  {} does not work, nor {  /  /    }, nor ctod(  /
>>>> /    ).
>>>> Peter
>>>
>>> Be very careful with logical fields also
>>> if the field is null then field = true and filed = false
>>> both will return false.
>>>
>>> in the above program replace
>>> if q.rowset.fields[n].type = "C"
>>> with a do case
>>> do case
>>> case q.rowset.fields[n].type = "C"
>>>     temp = " "
>>> case q.rowset.fields[n].type = "N"
>>>     temp = 0
>>> //repeat for all field types
>>> endcase
>>> if q.rowset.fields[n].value = null
>>>      q.rowset.fields[n].value = temp // the default value selected above
>>> endif
>>>
>>> Regards
>>> Akshat
>>
>> But if field type is "D", what default value should be used?  "" as
>> for Character field?  What value is in an empty date field?
>> As you wrote above:
>>> if the field is null then field = true and filed = false
>>> both will return false.
>> did you mean to type field for filed?  Not sure I understand.
>> Peter
>
> for date type fields you can use ctod("  .  .    ") // for date format
> dd.mm.yyyy
> adjust the spaces according to your date format.
>

Why not simply:

{}

Which is a blank date, and I believe is not null?

Ken


--
*Ken Mayer*
Ken's dBASE Page: http://www.goldenstag.net/dbase
The dUFLP: http://www.goldenstag.net/dbase/index.htm#duflp
dBASE Books: http://www.goldenstag.net/dbase/Books/dBASEBooks.htm