I have been trying to get the OUT to work in a procedure, but I can't get that to work. Do you have an example?
What I found with creating functions is that 1 or -1 is still returned via SQLExec(). You have to call the function using a SELECT SQL command. Whatever you have in the PL/SQL RETURN command is returned to a VFP in a cursor.
For example:
-- Both FnCount1 and FnCount2 work exactly the same way.
-- The result is 1 record returned to a VFP cursor.
CREATE OR REPLACE FUNCTION FnCount1
RETURN numeric IS
CURSOR curKount IS
SELECT COUNT(*) FROM SomeTable;
nKount number;
BEGIN
OPEN curKount;
FETCH curKount INTO nKount;
CLOSE curKount;
RETURN nKount;
END;
/
show error
--
CREATE OR REPLACE FUNCTION FnCount2
RETURN numeric IS
nKount number;
BEGIN
SELECT COUNT(*) INTO nKount FROM SomeTable;
RETURN nKount;
END;
/
show error
--
In VFP you issue:
SQLExec(lnHandle, 'select FnCount1() from dual')
SQLExec(lnHandle, 'select FnCount2() from dual')
If you do not specify a cursor name, VFP will use its default cursor name.
>Mark,
>I haven't been able to get function to work properly from VFP so I use procedures for everything. You can get the new PK by also incuding an OUT param in the call and fill it with the new PK.
>
>HTH.
Mark McCasland
Midlothian, TX USA