If you were trying to do that operation using the "modify structure" menu
command, you will find that you cannot remove all the columns. MI requires
that at least one column remains in the structure. I do not know if that
constraint would exist programmatically but if you get in trouble with the
suggested code, I would simply start by adding the first new column (or any
dummy column) before deleting all the old ones (and deleting the dummy after
having added the new ones)

Jacques Paris
e-mail  [EMAIL PROTECTED]
MapBasic-MapInfo support  http://www.paris-pc-gis.com

-----Original Message-----
From: Terry McDonnell [mailto:[EMAIL PROTECTED]
Sent: June 21, 2005 04:45
To: mapinfo-l@lists.directionsmag.com
Subject: RE: MI-L Drop and replace all columns?

Ross,

I've not done this programmatically before but, if I did, below is how
I'd do it.  Not sure whether the Obj column is protected in a "drop" so
I've put the test in for it.

Of coursre, you'd well back up your table before trying it!!!!!

HTH

Terry
___________________________________
Dim     lnNumCols, lnColNum As SmallInt
        lcColName, lcCol as String

Open Table "YourTable"
lnNumCols = TableInfo( "YourTable", TAB_INFO_NCOLS)
For lnColNum = 1 to lnNumCols
  lcCol = "Col" + Rtrim$( Str$( lnColNum))
  If Ucase$( lcColName) <> "OBJ" then
        lcColName = ColumnInfo( "YourTable", lcColName, COL_INFO_NAME)
        Alter Table YourTable Drop lcColName
  End If
Next
Alter table YourTable Add NewCol ... Etc.


-----Original Message-----
From: Ross Nixon [mailto:[EMAIL PROTECTED]
Sent: 21 June 2005 04:01
To: Terry McDonnell
Subject: MI-L Drop and replace all columns?

I want to Alter a table by dropping all existing columns (without losing
the objects) and add several new columns.
Can I do this in one or two mapbasic "Alter Table" statements?

Thanks,
Ross Nixon

Manawatu Aerial Photo Services
P.O. Box 75
Palmerston North
www.forestrymaps.co.nz
Ph/Fax.  06 355 1431

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




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

Reply via email to