It is all about the business of Stored Procedures which I am trying to perfect. The SPs are called by my .NET C# app. A lot of the stuff I've had difficulaties initialy appears to be working now. Still there are numerous limitations and one has to get used to them. It is a new style of programming. Very austere. If you want to DELETE a record in a table and you have 15 of them and want to determine at runtime which one to choose, you cannot use DO CASE. It won't work, although it is listed neither in supported nor unsupported Ole DB keywords. You cannot even use a stack of IF/ELSE/ENDIF statements to make a selection inside one SP. You have to write 15 SPs separately.
Anyhow, I want to investigate (with very little hope for a positive resolution) a possibility of returning more than a single variable from a SP. A signle variable does come bacx. But I want to get an array back.
PROCEDURE
testing DIMENSION words (5,2)words[1,1] = "a1"
words[1,2] = "a2"
words[2,1] = "b1"
words[2,2] = "b2"
words[3,1] = "c1"
words[3,2] = "c2"
words[4,1] = "d1"
words[4,2] = "d2"
words[5,1] = "f1"
words[5,2] = "f2"
RETURN (words)ENDPROC
The rusult: only the first element ("a1") came back. That was it. I am wonderng if a pointer to the location of this array can be determined inside such code and passed back Is it possible I checked SYS ( ) functions but could not see anything remotely related to it.
Of ocurse, there are workarounds. I can send this array into an XML file with CURSORTOXML and I have done it but it will slow things down. Does anybody know how I can get either the whole array or a pointer to the memory location where it is positioned That might be a dead end, however. After the SP finished all memory is supposed to be cleared, isn't it
Another thing is to get a CURSOR out of a SP. This is the code that actually works:
PROCEDURE
selectFromCrossRefByPointOne LPARAMETERS p_one SET PATH TO "C:\VFP_Projects\Data\ComeAndGetDatBase\" OPEN DATABASE comeAndGet EXCLUSIVE m.retValue = "" SELECT * FROM crossRefTable WHERE pointer_one = p_one INTO CURSOR qTemp READWRITE ORDER BY pointer_two SELECT qTemp GO TOP cou = 0 DO WHILE NOT EOF () IF (cou = 0)m.retValue = pointer_two
ELSE m.retValue = m.retValue + "-" + pointer_two ENDIF cou = cou + 1 SKIPENDDO
USE
CLOSE DATABASES ALL
RETURN
(m.retValue)ENDPROC
It returns a string of ANY LENGTH but when I tried to return a CURSOR qTmp I got an error: variable qTmp not found. I enclosed it in brackets [qTmp] - it gave me another error.
Anybody has any idea how I can return a cursor from a SP
Thanks.
PS. I want to expand on that ANY LENGTH issue in the next bill.