Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Problems with passing Arrays from c++ to stored procedures

Problems with passing Arrays from c++ to stored procedures

From: <dennis.alund_at_gmail.com>
Date: 26 Apr 2006 08:13:56 -0700
Message-ID: <1146064436.358230.90290@e56g2000cwe.googlegroups.com>


I've got some problems with passing an Array as parameter to a PL/SQL stored procedure in C++. The usage below allows me to pass the array as a parameter and inserts records... although the fraction part of all numbers have been truncated. Anyone who can give me a hint of what's wrong or maybe give me a tip of another way of doing the same thing?



My C++ code looks more or less like this:

OParamArray latitudes( params.AddTable( "latitudes", OPARAMETER_INVAR, OTYPE_NUMBER, numPoints ) );
OParamArray longitudes( params.AddTable( "longitudes", OPARAMETER_INVAR, OTYPE_NUMBER, numPoints ) );

for ( unsigned int point( 0 ); point < numPoints; ++point ) {

	latitudes.SetValue( vectorOfPoints[ point ].latitude, point );
	longitudes.SetValue( vectorOfPoints[ point ].longitude, point );
}

m_database.ExecuteSQL( "Begin PRC$InsertInCoords( :msg_id, :latitudes, :longitudes ); End;" );



And the PL/SQL code:

TYPE latitudeArray IS TABLE OF NUMBER INDEX BY PLS_INTEGER; TYPE longitudeArray IS TABLE OF NUMBER INDEX BY PLS_INTEGER;

PROCEDURE PRC$InsertInCoords

         (
         msg_id     IN   NUMBER,
         latitudes  IN   latitudeArray,
         longitudes IN   longitudeArray,
         )

IS
BEGIN   FOR i IN latitudes.FIRST .. latitudes.LAST   LOOP
    INSERT INTO PolygonCoordinate ( MSG_ID, LATITUDE, LONGITUDE )     VALUES ( msg_id, latitudes( i ), longitudes( i ) );   END LOOP; END PRC$InsertInCoords;

/d Received on Wed Apr 26 2006 - 10:13:56 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US