sqlexec question

This forum is meant for questions about the Visual FoxPro Language support in X#.

Post Reply
User avatar
kevclark64
Posts: 127
Joined: Thu Aug 15, 2019 7:30 pm
Location: USA

sqlexec question

Post by kevclark64 »

I'm getting an error with an SqlExec call. I think it was stated before that rather than using AError as in VFP, the exception would be contained in RuntimeState.LastRddError. However, when I try to get the error it appears to be null. My code is:

Code: Select all

local iReturn as int
iReturn=SQLEXEC(g_sqlhandle,tmpline,"tmpfilPlaceStatus",aCountInfo)
if iReturn>0 then 
...
ELSE
    local lException as exception
    lException=RuntimeState.LastRddError
   // lException is null at this point
ENDIF 
How can I get the error generated from the SQL call?
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

sqlexec question

Post by robert »

Kevin,
The error should indeed be visible in the LastRddError (for now).
What is the value of tmpline ?

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
kevclark64
Posts: 127
Joined: Thu Aug 15, 2019 7:30 pm
Location: USA

sqlexec question

Post by kevclark64 »

The query I am running is:

Code: Select all

select si.*,sr.*,id.*,es.studentnum,sr.datecreated as submitdate from invlinedata id,setonassessmentinstance si,setonassessmentresult sr,  enrollmentstudent es where usertype='invline.uniqueid' and id.invlineid=si.userid::int and si.setonassessmentinstanceid=sr.setonassessmentinstanceid and  es.uniqueid=id.enrollmentstudentid and si.deleted<>'TRUE' and emailsent is null and (sr.status<$$63$$ or sr.status is null) and  (right(si.stocknum,1)=$$1$$ or right(si.stocknum,1)=$$3$$) and sr.datecreated>='09/04/2020'
This is being run against a Postgres database. From within Foxpro using SqlExec it is valid and returns records.
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

sqlexec question

Post by robert »

Kevin,

Well, when this works with FoxPro then it should also work with X#, assuming everything else the same, so you use the same connection string etc.
What we/you could do is link the Sql..() functions and their support classes in sourcecode and run the query through the debugger.
Or you create an example that I can look at over here.
Or we setup a shared session (MsTeams, Zoom or something like that ) and you let me debug your app from a distance.

Just out of curiosity:
Why are there $$ characters in the string. Should these be replaced with a double quote ? And did you do that ? Or does Postgress do that ?
And should there be single quotes around invline.uniqueid ?
And is ::int the syntax for Postgress to cast a value to an int ?

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
lumberjack
Posts: 723
Joined: Fri Sep 25, 2015 3:11 pm

sqlexec question

Post by lumberjack »

Robert,
robert wrote: Why are there $$ characters in the string. Should these be replaced with a double quote ? And did you do that ? Or does Postgress do that ?
PG has what is called Dollar Quotes, the $$ can be replaced by a Single Quote in his example.
And should there be single quotes around invline.uniqueid ?
If usertype is a string then yes single quotes are required.
And is ::int the syntax for Postgress to cast a value to an int ?
Correct, PG uses ::TypeToCastTo, for casting of values to another type.
User avatar
kevclark64
Posts: 127
Joined: Thu Aug 15, 2019 7:30 pm
Location: USA

sqlexec question

Post by kevclark64 »

After doing more research on this, any query I try which includes a cast fails to execute. I tried casting as int, text, and char and they all fail.
Post Reply