Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Strange Error Message
Message
From
24/03/2011 21:39:35
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Strange Error Message
Environment versions
Visual FoxPro:
VFP 8 SP1
Miscellaneous
Thread ID:
01504918
Message ID:
01504918
Views:
154
I have the following code
*sql_execute
PARAMETERS tnConnection,tcSql,tcOutput

IF EMPTY(tcSql)  && Processing via an SQLPREPARE() statement
	tcSql = " "   && So Error Routine has character value
	lnResult = SQLEXEC(tnConnection)
ELSE
	IF EMPTY(tcOutput)
		lnResult = SQLEXEC(tnConnection,tcSql)
	ELSE
		lnResult = SQLEXEC(tnConnection,tcSql,tcOutput)
	ENDIF
ENDIF

IF lnResult = -1 
	=AERROR(aTmpError)
	lnStack = ASTACKINFO(aTmpStack)

	IF TYPE("app_global") <> "O"
		app_global = CREATEOBJECT('custom')
		app_global.addproperty("app_name","Insert App Name")
		app_global.addproperty("employee","RPUPKO")
	ENDIF
		
	INSERT INTO spotlight_errors(application,sql_statement,error_msg,dt_error,userid,stack) VALUES;
	    (app_global.app_name,tcSql,aTmpError[2],DATETIME(),app_global.employee,this.array_to_char('aTmpStack'))
	USE IN (SELECT('spotlight_errors'))

	IF this.showerror
		=MESSAGEBOX(aTmpError[2],0,PROGRAM(aTmpStack[ALEN(aTmpStack,1)-1,1]))
		SET STEP ON 
	ENDIF
	RETURN .F.
ENDIF
One of the records in the error log has the error message Variable 'LNRESULT' is not found."

I've never been able to reproduce this error and it's quite possible that the environment would actually absorb it and allow processing to continue. So if this error were generated by IF lnResult = -1 the record would actually get written.

What I don't understand is how the variable could not have a value. Can anybody give me a set of circumstances where this variable does not exist when AERROR() is called?

One possibility is that the error was actually generated in some other module and properly handled there. It could have been the last error generated so that's what AERROR() would find. In which case, for this module it really has a value of -1 so I'm supposed to go into the error handling portion of the code. The problem with that is the value is being assigned by the SQLEXEC() statements. If that statement resulted in a value of -1, why doesn't AERROR() return the ODBC errors I'm expecting.

I've checked with the users of the system and nobody has noticed any unexpected results, so it appears that the final processing is correct. But this is driving me crazy(ier). Any and all suggestions gratefully accepted.

..........Rich
Next
Reply
Map
View

Click here to load this message in the networking platform