Home » Developer & Programmer » Application Express, ORDS & MOD_PLSQL » Passing varrays to external procedures (Oracle 9i and 10G, Win 200K)
Passing varrays to external procedures [message #402048] Thu, 07 May 2009 07:26 Go to next message
amit_thombre
Messages: 6
Registered: May 2009
Junior Member
I am passing varrays to external procedures which is a C++ dll. The code gets compiled but the C++ function does not return the arrays elements. I would like to know if someone has tried this so that I can post my code for review and get help. Also I want to know which version of oracle database supports this. I am working on Oracle 9i and I have a doubt if it is completely supported on it or not. Help is reuired urgently.

Regards
Amit

The code is as follows

--------------------------------------------------------------------------------
the ext procedure is
CREATE OR REPLACE FUNCTION PL(
x IN VA)
RETURN FLOAT AS
EXTERNAL LIBRARY CLDLL
NAME "fnClusteringDLL"
LANGUAGE C
WITH CONTEXT
PARAMETERS (
CONTEXT,
x BY REFERENCE);
/

--------------------------------------------------------------------------------

Teh call to the function is

CREATE OR REPLACE PROCEDURE CL AS
a integer;
b integer;
c number;
--TYPE VA IS VARRAY(10) OF NUMBER;
xvarray VA;
zvarray VA:=VA(10,11);
-- yvarray VA:=varray_type(1,2,2,34,5, 7, 8,9,10 );
yvarray VA:=VA(1,2,2,34,5, 7, 8,9,10 );
BEGIN

DBMS_OUTPUT.ENABLE(1000000);
SELECT y, x
BULK COLLECT INTO yvarray, xvarray
FROM INPUT;

for element in 1..yvarray.COUNT
LOOP
DBMS_OUTPUT.PUT_LINE ('varray.FIRST='||yvarray(element));
DBMS_OUTPUT.PUT_LINE ('varray.FIRST='||xvarray(element));

END LOOP;
a := 1;
c := PL(yvarray);
--c:= CH(yvarray);
dbms_output.put_line('The maximum of '||c);

END;
/



--------------------------------------------------------------------------------

The C++ function iin the dll is

extern "C" CLUSTERINGDLL_API float fnClusteringDLL(float dxm[])
//extern "C" CLUSTERINGDLL_API float fnClusteringDLL(float (&dxm)10)
{
std::cout<<"Members in the array are "<<dxm[1]<<std::endl;
std::cout<<"2 Member in the array are "<<dxm[0]<<std::endl;
printf("Is this printed %f", dxm[0]);
return dxm[1];
}

--------------------------------------------------------------------------------

Also I have written printf and cout in the function but they do not seem to come as out put any clues as to how to printe these statements and values.
Re: Passing varrays to external procedures [message #402311 is a reply to message #402048] Fri, 08 May 2009 11:50 Go to previous message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
This sounds line a PL/SQL specific issue rather than Apex. asktom.oracle.com is probably the best place to search.
Previous Topic: Scheduling Reports
Next Topic: object browser - selecting bigger font
Goto Forum:
  


Current Time: Wed Dec 04 19:40:05 CST 2024