I usually always do a selection of records with an object (Where Obj) or at least where rowID > 0 to avoid the deleted records before doing the update.

The later versions of Mapinfo seem to select deleted records if you just select * from table, and give you errors if you update the object.

r


On Wed, 27 Apr 2005 08:43:52 +0200, Peter Horsb�ll M�ller <[EMAIL PROTECTED]> wrote:


Robert,

I agree that this is the absolute best way of doing an update. Have you any experience with the error handling if you try to change the styles on a not-existing object ? By this I mean what will happen if you use the function you here mention and a single row in the table doesn't have an object in the "obj column" ?

Or do you always avoid this by selecting only the records with an object ?

Peter Horsb�ll M�ller
GIS Developer
Geographical Information & IT
COWI A/S
Odensevej 95
DK-5260 Odense S.
Denmark
Tel     +45 6311 4900
Direct  +45 6311 4908
Mob     +45 5156 1045
Fax     +45 6311 4949
E-mail  [EMAIL PROTECTED]
http://www.cowi.dk/gis


-----Original Message----- From: Robert Crossley [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 27, 2005 8:25 AM To: Christophe Brabant Cc: MapInfo List Subject: Re: MI-L Update statement


This is an old question that has a happy ending. Its not the update
command that is CPU intensive, it is the fetching each record in the loop.


If you put your object changes into a sub routine such as this one to
change the colour:

Function fChangeRegionColour(ByVal CurrObj As Object, ByVal NewBrush As
Brush, ByVal NewPen As Pen) As Object
'-----------------------
'Function : > fChangeRegionColour
'Called by: >
'Description: >This Function returns an object with a nwe colour and black
outline
'-----------------------
'Set up general error handler
ONERROR GOTO ErrorHandler
Alter Object CurrObj Info OBJ_INFO_BRUSH, NewBrush
Alter Object CurrObj Info OBJ_INFO_PEN, NewPen
fChangeRegionColour = CurrObj
EXIT FUNCTION
ErrorHandler:
CALL ErrorMessage("fChangeRegionColour")
End Function



Then use the update table without any row reference.

Update Table Set Obj = fChangeRegionColour(Obj, BrushStyle, PenStyle)

If you only want to do a selection, then do the selection and update the
selection rather than the whole table.


I am now using this technique for a lot of updates, jsut to take advantage
of the speed of the update fucntion to run through the table. I even use
a dummy field to update, but pass the parameters to a function that
performs functions on other tables based on the row data from the table.
The returned value can be the same as the original value, so you don't get
any changes.


r

On Wed, 27 Apr 2005 08:24:16 +0200, Christophe Brabant
<[EMAIL PROTECTED]> wrote:

Hi
I have to display some hundred of Region objects into on Layer. Thus I
must
use the Update statement for each object into a loop.
Update table Set Obj=my_object where Rowid=my_rowid
Is there any way to optimize these updates ? because the Update
statement is
very penalizing for CPU.
Thank you






-- ________________________________________________

Robert Crossley

Agtrix P/L
9 Short St
PO Box 63
New Brighton 2483
Far Southern Queensland
AUSTRALIA

153.549004 E 28.517344 S

P: 02 6680 1309
F: 02 6680 5214
M: 0419 718 642
E: [EMAIL PROTECTED]
W: www.agtrix.com
W: www.wotzhere.com
skype: robertcrossley

---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 16250



Reply via email to