NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: broche on July 30, 2014, 03:56:27 PM
-
NT 8.21
CL 9.0
Starting to use PROP:SQL a lot more for speed. For the GURU's out there.
\I can contruct and run the SUM statement I need and get the deired results. I can't figure out how to get the result out and into a varible that I can then use?
In Postgres This works
SELECT SUM(docvalue) as "totalvalue" FROM custvf where readyforbilling='N';
SQLFile{PROP:SQL}='SELECT SUM(filecount) FROM custvf where readyforbilling=<39>Y<39> AND invoice=0 AND cussysid=' & cus:cussysid;
How do I get the result out? I have a file called SQLFile in the dictionay acting as the 'Dummy' SQL file with a first field as type real.
Brian.
-
Brian,
This is really not a NT question and you may get better answers in the Clarion ng's.
But since you asked <g>:
After issuing the prop:sql stmt you must actually read the result. So something like this:
SQLFile{PROP:SQL}='SELECT SUM(filecount) FROM custvf where readyforbilling=<39>Y<39> AND invoice=0 AND cussysid=' & cus:cussysid
if error()
! Always do some error checking here
else
loop ! Read one row at a time from the result set (= the structure of your sqlfile)
next(SQLFile)
if error() then break.
! Now you've got some data so use it:
YourFileCountVar = sqlfile.NameOfTheFirstField
end
end
Each next() in the loop retrieves the next row from the result set. In this case there's only one row but now you've got a generic way of doing it. Also, inside the loop do an error check as shown (it may be more advanced but in the example above it catches EOF).
HTH
Peter
-
You may also want to check out UltimateSQL from ClarionLive - it's free - and encapsulates a lot of this sort of code.
cheers
Bruce
-
@Bruce,
Is this thread safe?
And how do i treat the resultset when there are more than one ocurrences in the resultset?
Or do I have to use a memory file with the sessionid in every record to "park the result?
Rene
-
Sorry Rene - is _what_ ThreadSafe? UltimateSQL? Or Peter's suggestion?
>> And how do i treat the resultset when there are more than one ocurrences in the resultset? Or do I have to use a memory file with the sessionid in every record to "park the result?
It all depends on the context, but typicallyyes, if you have a multi-record reply you want to cache then that's done via a Mem table with a session ID.
cheers
Bruce
-
FWIW: My SQLFile is threaded.
Peter
-
Thanks Peter - you arfe correct, sorry will post there in future on non- NT.
-
@Bruce,
Yes I ment UltimateSQL. Sorry if I wasn't clear on that.
René
-
I haven't looked at the code Rene
cheers
Bruce
-
Ok,
I'll ask the Clarionlive crew then.
René