Delete Problem

Ruslan Zasukhin sunshine at public.kherson.ua
Wed May 26 14:38:01 CDT 2004


On 5/26/04 2:27 PM, "Sandeep Rao" <sandeep.rao at hurix.com> wrote:

> Hi ruslan,
> 
> I am using valentine database with macromedia director.
> I am calling this handler to delete the records which as field wordcount
> = 0
> 
> on finalSaveDb
> set tempcursor = new (xtra "VCursor", GetRef(gDB1.pDataBase),"select *
> from ChapterSet")
> set RecCount = GetRecordCount( tempcursor )
>   if RecCount <> 0 then
>   FirstRecord(tempcursor)
>   repeat with i =1 to RecCount
>     wordcount = GetField(tempcursor,"WordCount")
>     if wordcount = 0 then
>       DeleteRecord(tempcursor)
>     end if
>     if i <> RecCount then
>       NextRecord(tempcursor)
>     end if
>   end repeat
>   tempcursor=void
> end if
> end
> 
> 
> It works fine when the record count is greater then 2. If the record
> count is equal to 2 then it delete the records, but changes the values
> of the other record to 11039220 ... of ktypelong field when the table is
> querried again.
> 
> Can you help me in this why is it happening?

I don't know what happens (may be loop condition is wrong)

but this task can be better made with single SQL command

    db.Sqlexecute(
        "DELETE FROM ChapterSet WHERE WordCount = 0" )


----
Even in case of usage of cursor, it is better SELECT only one field

  set tempcursor = new (xtra "VCursor", GetRef(gDB1.pDataBase),
                        "select WordCount from ChapterSet")
    
Such cursor will work much faster.

-- 
Best regards,
Ruslan Zasukhin      [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com

To subscribe to the Valentina mail list go to:
http://lists.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------



More information about the Valentina mailing list