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

error 1734 on Update - SQL 1

Status
Not open for further replies.

Koen Piller

Programmer
Jun 30, 2005
841
NL
Hi,

The following routine errors "Structuralindex not found"

Code:
Parameters  tcAlias, tiID

Update declaraties ;
	SET ;
	declaraties.datumvan = curdeclaraties.datumvan  ;
		from curdeclaraties ;
	where declaraties.Id = curdeclaraties.ID AND declaraties.id = tiID
ln=aerror(myerror)

The crazy thing is that when I copy this method to a test.prg and excute it outside of my form, it works without error.
Checked my Datasessions and only one dbf Declaraties and only one cursor curDeclaraties exsist.
How do I check for the presence of the Structuralindex?

Regards,
Koen
 
structural index would point out some CDX problem,

but error 1734 is about properties, it says property named "structuralindex" is not found.

Set step on before the update and look into what the debugger goes through in update trigger code, table and field ruiles and index expressions.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Hi Keon,

The short answer to your question is the CDX() function. That's how you check for the presence of a structural index. Alternatively, given that by definition the structural index has the same name as the associated DBF, you could check for FILE(FORCEEXT(JUSTFNAME(ALIAS()), "CDX")).

However, that doesn't explain the behaviour your are seeing. The only thing that comes to mind is that the form has a data environment, and the instance of the table in the dataenvironment is pointing to a database that contains another copy of the table. To check that, open the form, then open its data environment, then select the relevant table and go to its properties. If the Database property is pointing to the wrong database, that would explain it.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi,

Olaf,
Opening the debugger: Right after the Set instruction it jumps to the ln=aerror(myError)
no clue for me, why this error occurred.

Mike,
The dataenvironment of the form is empty.

Remember if I run the method in a .prg file it updates fine. So this makes me believe there is something in the form which is bothering, however I don't know
where to look for what.
For your info I have also included a statement
Index on ID TAG PUK after creating the cursor.
No effect.

Regards,

Koen
 
Well, then actually no error occured due to the SQL, you just fetch an old error information.

If you do AERROR() without ON ERROR occurring, you get the last not yet fetched error information about something, that happened earlier. If there is no jump to an error handler, there was no error weith the update.

Bye, Olaf.

Olaf Doschke Software Engineering
 
For your info I have also included a statement
Index on ID TAG PUK after creating the cursor.

That will create an index on the cursor (assuming that the cursor was currently selected when you issued the above command). But if we are talking about a missing structural index, that's more likely to be from the physical table. In fact the message indicates that you are trying to open a table which has a structural index flag (as contained in its header), but no matching CDX is present.

That in turn suggests that the table is damaged in some way. But that wouldn't explain why the error doesn't arise when you run the code from a PRG. That would tempt me to believe that there is another copy of the table somewhere, but you say you have checked for that.

Just out of interest, what happens if you execute the following (from the command window):

[tt]USE Declaraties INDEX Declaraties[/tt]

Mike




__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike,

I issued the by you advised test
vfp said:
USE Declaraties INDEX Declaraties

and nothing happens visualy.
Rerunned the form with error 1734.

I suppose I will give up and execute the update via an separate function and not method.

Regards,
Koen
 
If you do a search for "structuralindex" in your porject, does that turn up any property of that name?

I still think I'm right about the mislead of that error information. That error is not related to the SQL.

For a simple test, do the ln=aerror(myerror) right before the UPDATE and check, whether you have that same error.

And then what is in the Error method of the same object with that method code and what happend if you establish a simplified general error handler like this?

Code:
Parameters  tcAlias, tiID

Private All Except goApp
plError = .F.
On Error plError = .T.

Update declaraties ;
	SET ;
	declaraties.datumvan = curdeclaraties.datumvan  ;
		from curdeclaraties ;
	where declaraties.Id = curdeclaraties.ID AND declaraties.id = tiID

If plError
   ln=aerror(myerror) 
Else
   ln=0 && there is no error from this update sql.
Endif

And even simpler do the SQL-Update within Try Catch using Catch To loExcpetion.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Just a short demo about misleading aerror information:

We establish an error suppression, do some error, then do something correct and then look into aerror:
Code:
Create Cursor test (id int)
Append Blank 

Set TablePrompt off
On Error *
Use fkljsdflfjkl

On Error
Update test set id=2

ln=AError(myerror)
Set Step On

You'll have "File fkljsdflfjkl.dbf not found" error in AERROR.

Simply notice AERROR is not giving you error info about the last command executed but about the last error, which occurred at any time beforehand. And executing commands not erroring does not clear the info AERROR has in store, so you do get some error related to another thing done beforehand. As you can reproduce the error, that could be somewhere in load, activate, data environment code, anywhere.

Aerror could even repeatedly return info about something you did wrong in the command window. and all tests you run will show that error, you start a new VFP session, use the same SQL and get no error. Well, because there is no error in the SQL. For example do something wrong in the command window, then get that error with AERROR(laError), then RELEASE laError and call AERROR(laError) once more, you repeatedly get the same error info back from it.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Olaf!

You hit the nail. The Property "StructuralIndex" used to be a method in this ancient class, it was never ever called before today after I implented the SQL-Update.
Have now changed the code and will concentrate on a correct Update-statement.
Thanks a lot.
Regards,
Koen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top