Hi Jim just write this Select * from MyTab Where _Col2 < 15 into MySelection NoSelect Set table MyTable Fastedit on Update MySelection set _col2 = _col3 * _col1 ' this line do the update Commit table MyTab Close table MySelection Set table MyTAble fastedit off The Set table mytabel Fastedit on speed up the proces with a factor 5 or more, but remember you can not roolback the table again Med venlig hilsen Peter Laulund ************************************************************* Kort & Matrikelstyrelsen · www.kms.dk National Survey and Cadastre - Denmark Rentemestervej 8 · DK 2400 København NV E-mail: [EMAIL PROTECTED] · Home: [EMAIL PROTECTED] Phone: +45 3587 5050 · Direct: +45 3587 5173 ************************************************************* "Jim Wilson" <[EMAIL PROTECTED]> - 2000 09 07 21:18:31 Til: [EMAIL PROTECTED] cc: (bcc: Peter Laulund/MI/KMS) Vedrørende: MI Updating columns in Mapbasic
Hi all, I'm (slowly) learning mapbasic and I'm trying to update the value of _col2 based on the number in _col3 * _col1. To this end I have tried 2 different ways of achieving this. 1. Select all the records in Tablename that fall within certain parameters and then update Tablename from that selection. (the batch approach) i.e. Select * From Tablename Where _col1< 15 Fetch First From Selection Do While Not EOT(Selection) Update Selection Set _col1 = _col2 Loop This doesn't work 2. so I tried to loop through all the records in the table updating _col2 based on the value in Tablename._col1 ie Fetch First from Tablename Do While Not EOT(Tablename) If (Tablename._col1<=15) Then Update Tablename Set _col2=_col3 ElseIf Tablename._col1>15 and Tablename._col1<=16 Then Update Tablename Set _col2=(_col3-((_col3/100)*1.2)) ElseIf Tablename._col1>16 Then Update Tablename Set _col2=(_col3-((_col3_col2/100)*17)) End If Fetch Next From Tablename Loop This doesn't work either! I know this must be a very simple thing to try and do - so could anyone please point me in the right direction? Thanks, Jim Wilson
Hi all,
I'm (slowly)
learning mapbasic and I'm trying to update the value of _col2 based on the
number in _col3 * _col1. To this end I have tried 2 different ways of achieving
this.
1. Select all the
records in Tablename that fall within certain parameters and then update
Tablename from that selection. (the batch approach)
i.e.
Select * From Tablename Where _col1< 15
Fetch First From Selection
Do While Not EOT(Selection)
Update Selection Set _col1 = _col2
Loop
This doesn't
work
2. so I tried
to loop through all the records in the table updating _col2 based on the value
in Tablename._col1
ie
Fetch First from Tablename
Do While Not EOT(Tablename)
If (Tablename._col1<=15) Then
Update Tablename Set _col2=_col3
ElseIf Tablename._col1>15 and Tablename._col1<=16 Then
Update Tablename Set _col2=(_col3-((_col3/100)*1.2))
ElseIf Tablename._col1>16 Then
Update Tablename Set _col2=(_col3-((_col3_col2/100)*17))
End
If
Fetch Next From Tablename
Loop
This doesn't work
either!
I know this must be
a very simple thing to try and do - so could anyone please point me in the right
direction?
Thanks,
Jim Wilson