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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error On Adding Field To a Cursor 3

Status
Not open for further replies.

progfox

Programmer
Joined
Jun 15, 2003
Messages
43
Location
IN
Dear Sir,
On Writing The Following Code The Error IS Generated "Invalid Operation On cursor". Then When I am Rewriting the code then it workin Perfectly.
IF FILE(DBF('xor'))=.T. then
SELECT xor
USE
endif

Select accesreq.companyname,accesreq.reqno,accesreq.department,accesreq.unit,;
accesreq.dyissparty,accesreq.reqname,accesreq1.itemcode,accesreq1.itemname,;
accesreq1.size, accesreq1.unitofmeas, accesreq1.qty,accesreq1.stylename,;
accesreq1.buordno,accesreq1.buname from accesreq inner join accesreq1;
on accesreq.reqno=accesreq1.reqno into cursor xor1 readwrite;
where accesreq.reqno=thisform.pageframe1.page1.combo1.Value
ALTER TABLE xor ADD COLUMN flag l
REPLACE all flag WITH .t. for !EOF()
thisform.pageframe1.page2.grid1.recordsource="sele flag,stylename,buname,buordno,itemcode,itemname,size,unitofmeas,qty from xor into cursor x"
thisform.pageframe1.page2.Refresh()
thisform.pageframe1.ActivePage=2
WITH thisform.pageframe1.page2
SELECT xor
.text1.value=xor1.reqno
.text2.value=xor1.department
.text3.value=xor1.unit
.text4.value=xor1.dyissparty
.text5.value=xor1.reqname
.text6.value=DATE()
.text7.value=xor1.companyname
ENDWITH

The Error is generated at line "ALTER TABLE xor ADD COLUMN flag l". Now will any one pls suggest me why its happening and what is the solution for it.

Waiting for replies.

Thanx & Regards

Chandan


 
why dont you ,...


select ....,.t. as flag;
from accesreq inner join accesreq1;
on accesreq.reqno=accesreq1.reqno into cursor xor1 readwrite;
where accesreq.reqno=thisform.pageframe1.page1.combo1.Value
that will add a flag field without the alter table

mrF
 
also looking at the code

you say

into cursor xor1 readwrite

then try and alter table

ALTER TABLE xor ADD COLUMN flag l

different - field names Xor1 vs Xor

mrF
 
also..

IF FILE(DBF('xor'))=.T. then
SELECT xor
USE
endif

i see you are looking to see if the dbf file that cursor Xor creates exists, why not simply - although not the cause of the problem it could be simpler to just see if the cursor alias is used rather than looking for the dbf()

IF used('xor')
SELECT xor
USE
endif

mrF
 
HI

1. SELECT .... INTO CURSOR myCursor....
In this.. myCursor is just an illusionary table, some times it is only a filtered alias of a table. The point is that it is not always created as a table. SO

IF FILE(DBF('xor'))=.T. then
SELECT xor
USE
endif

will not work as intended. Instead..
IF ALIAS('xor') .. could work. But this is also not sure, unless the alias name is 'xor'.

However, the entire code can be droped, since SELECT will always create a new cursor.


2. Now..
SELECT .... INTO CURSOR xor READWRITE
will create a readwrite table for modification
Then ALTER TABLE etc will work. :-)


ramani :-)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

 
Thanx All OF U Sir,
Actually I wasted my whole day solving the problem and I was completely annoyed.


Regards

Chandan

 
"However, the entire code can be droped, since SELECT will always create a new cursor. "

Ramani,
You are right that select will always create a new cursor. But the problem comes, if we are using any cursor as readwrite and again want to overright the cursor. So, for that it becomes necessary to close the cursor and then execute select command.
for e.g. if I am using abc cursor as readwrite and again i write select command creating a cursor abc as readwrite, it will give error that cursor is already in use.

thanks n regards
 
Dear Mr. Fancyteeth,
Actually there was a mistake in the select statement that the cursor name was xor not xor1 and I wanted to add a boolean feild in the "xor"cursor that time it was giving the error message "Invalid Operation On Cursor". So If U can rectify the problem Please do.

Thanx & Regards

Chandan

 
profox

Actually there was a mistake in the select statement that the cursor name was xor not xor1 and I wanted to add a boolean feild in the "xor"cursor that time it was giving the error message "Invalid Operation On Cursor". So If U can rectify the problem Please do.

If ouy need to add a boolean field to a cursor and make it true, do it right into the SQL.

Select accesreq.companyname,accesreq.reqno,accesreq.department,accesreq.unit,;
accesreq.dyissparty,accesreq.reqname,accesreq1.itemcode,accesreq1.itemname,;
accesreq1.size, accesreq1.unitofmeas, accesreq1.qty,accesreq1.stylename,;
accesreq1.buordno,accesreq1.buname,.T. as FLAG from accesreq inner join accesreq1;
on accesreq.reqno=accesreq1.reqno into cursor xor1 readwrite;
where accesreq.reqno=thisform.pageframe1.page1.combo1.Value


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top