Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

drop column 1

Status
Not open for further replies.

sqlpro

Programmer
Dec 30, 2003
297
NZ
Hi friends

how to drop a column from a cursor.
Thanks :)

cheers
 
i tried this
ALTER TABLE (tcAlias) drop COLUMN added
but i got following error
Invalid operation for the cursor.

cheers
 
Should work on a cursor.

Maybe somehow the drop column clause is causing an
indirect Pack command on the cursor, but I'm unsure.

Darrell

Code:
Create CURSOR test (fld1 c(10), fld2 c(10))
Brow NOWAIT
Messagebox(TRANSFORM(FCOUNT()))

Alter TABLE test DROP COLUMN fld1
Brow NOWAIT
Messagebox(TRANSFORM(FCOUNT()))
 
SQLPro,
As Darren's example shows, if the cursor is one you create it works. However if it is one VFP creates from an SQL SELECT, without the READWRITE optional clause, you will get an error.

Rick
 
actualy i created like darrell did.this is my stmt

CREATE CURSOR curFinalResult (ParentTab c(8) NULL,Parentfld C(10) NULL, ;
ChildTab C(8) NULL,ChildFld C(10) NULL, ;
OrphanChildKey c(10) NULL,added n(1))



cheers
 
and trying to delete col like following

*!* if the cursor has col "added" (which is used for internal use) delete col
SELECT (tcAlias)
IF TYPE(FIELD("added"))='N' THEN
ALTER TABLE (tcAlias) drop COLUMN added
ENDIF

cheers
 
SQLPro,
Make the field "OrphanChildKey" 10 characters or less (e.g. OrphChdKey), and it should work!
Code:
CREATE CURSOR  curFinalResult (ParentTab c(8) NULL,Parentfld C(10) NULL, ;
ChildTab C(8) NULL,ChildFld C(10) NULL, ;
OrphChdKey c(10) NULL,added n(1))

tcAlias = "curFinalResult"

*!* if the cursor has col "added" (which is used for internal use) delete col
SELECT (tcAlias)
Messagebox(TRANSFORM(FCOUNT()))

IF TYPE(FIELD("added"))='N' THEN 
   ALTER TABLE (tcAlias) drop COLUMN added 
ENDIF  
Messagebox(TRANSFORM(FCOUNT()))
Nothing like a bogus error message to confuse things.

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top