[V4RB] Table working with 1.9.7 but not with 1.9.8

Stan Busk maxprog at mac.com
Sat Sep 13 11:50:49 CDT 2003


Hi,

Thanks Ruslan for your response.

> Am I right that you use here BaseObject API in the mix with Cursor API?
> I have warn that this is bad idea.

Yes, I make this all the time with no problems until yesterday with 
1.9.8
I read many times it is better to modify the cursor records. It that 
true? Problem is I don't know how to do this. If you can give me an 
example with my sample code I would appreciate it a lot and I will 
learn with it so I can make all other modifications myself. How should 
I modify this code to use Cursor API only?

Sub Prefs_SetValue(inDatabase As DB_Data, inKey As String, inValue As 
String)
   Dim aCursor as VCursor
   Dim aResult As String
   Dim aErr As Boolean

   aCursor = nil
   aCursor = inDatabase.SQLselect("Select * from Preferences where 
PrefEntry_Name='"+inKey+"'")
   if aCursor<>nil then
      if aCursor.RecordCount>0 then
         
inDatabase.mPrefs.Update(aCursor.ULongField("PrefEntry_Record").Value, 
inValue)
      else
         inDatabase.mPrefs.Add(inKey, inValue)
      end if
   end if
End Sub

> As I see you try inDatabase.mPrefs.Update()
> But in the same time you have made cursor (Select * from Preferences )
> On this table. And cursor have set READ LOCKS on its records.

So how can I modify cursor directly if they are locked?

> You can try resolve problem if kill cursor before 
> inDatabase.mPrefs.Update()
> Todo this at first extract your long value into tmp variable,
> Then kill cursor then do inDatabase.mPrefs.Update()

I can try to do this is this particular function but the problem is I 
use such approach everywhere so it means I am going to run in troubles 
in many places. I would prefer to do it the right way since the 
beginning.

Stan

> on 9/13/03 12:00 PM, Stan Busk at maxprog at mac.com wrote:
>
>> I have a problem with V4RB 1.9.8. My app uses a table to store
>> preferences with name 'Preferences'. This table has always been 
>> working
>> well with 1.9.7 Yesterday I found out that since I upgrade to 1.9.8 
>> the
>> table is no longer working, I store strings to it but when I go 
>> reading
>> it back, they are always empty. I have been checking the whole table
>> during hours but everything is correct. Finally I decided to replace
>> 1.9.8 with 1.9.7 and the table is working again. I have no explanation
>> for this.
>>
>>> The table name is boPrefs of type VBaseObject with following fields:
>>
>> Sub boPrefs()
>>   name = "Preferences"
>>   PrefEntryName    = new VvarChar ("PrefEntry_Name",   64, "ASCII",
>> kV_Unique + kV_Indexed) 'PrefEntry Name
>>   PrefEntryValue   = new VvarChar ("PrefEntry_Value", 256, "ASCII",
>> -1)                     'PrefEntry Value
>>   PrefEntryRecord  = new VULong   ("PrefEntry_Record", kV_Indexed)
>>                     'PrefEntry Record ID
>> End Sub
>>
>>> The funnction that doesnt work on 1.9.8 but work with 1.9.7 is:
>>
>> Sub Update(inRec As Integer, inValue As String)
>>   If GotoRecID(inRec) then
>>      PrefEntryValue.SetString(inValue) 'Set PrefEntry Value
>>      UpdateRecord
>>      Flush
>>   end if
>> End Sub
>>
>>> I call this function thru my code this way:
>>
>> Sub Prefs_SetValue(inDatabase As DB_Data, inKey As String, inValue As
>> String)
>>   Dim aCursor as VCursor
>>   Dim aResult As String
>>   Dim aErr As Boolean
>>
>>   aCursor = nil
>>   aCursor = inDatabase.SQLselect("Select * from Preferences where
>> PrefEntry_Name='"+inKey+"'")
>>   if aCursor<>nil then
>>      if aCursor.RecordCount>0 then
>>
>> inDatabase.mPrefs.Update(aCursor.ULongField("PrefEntry_Record").Value,
>> inValue)
>>      else
>>         inDatabase.mPrefs.Add(inKey, inValue)
>>      end if
>>   end if
>> End Sub
>>
>> I have no idea why this table has stopped working on 1.9.8, my app 
>> uses
>> 22 tables, this one is the only that has stopped working.
>
> Hi Stan,
>
> Am I right that you use here BaseObject API in the mix with Cursor API?
> I have warn that this is bad idea.
>
> As I see you try inDatabase.mPrefs.Update()
> But in the same time you have made cursor (Select * from Preferences )
> On this table. And cursor have set READ LOCKS on its records.
>
> You can try resolve problem if kill cursor before 
> inDatabase.mPrefs.Update()
> Todo this at first extract your long value into tmp variable,
> Then kill cursor then do inDatabase.mPrefs.Update()
>
> -- 
> 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
> -------------------------------------------------------------
>
> _______________________________________________
> Valentina mailing list
> Valentina at lists.macserve.net
> http://lists.macserve.net/mailman/listinfo/valentina



More information about the Valentina mailing list