my comeback to this forums(s) starts with a little problem I have regarding dealing with cursors in PRO/C.
Here it is:
I have to make a SELECT which returns a number of rows (more than 1 actually, and not much larger then 1 either -- around 10-20 each time, but this not the issue). The fields extracted are of (VAR)CHAR, NUMBER and FLOAT type (this either, I don't think it matters).
For some reason I have to deal with those values returned by the SELECT into some "host" variables in PRO/C (these host variables should match the type of the fields extracted, thus they should be of the following tyes correspondly : char, long, double).
From what I've read so far in Oracle's documents (those PDF named with numbers like A89861.PDF, but which are the "PRO C/C++ Precompiler Programmer's Guide" a.s.o.) I come to a conclusion that these "host" variables should be vectors (ex. : VV_NUMBER long; VV_FLOAT double; VV_CHAR char a.s.o.).
OK now, my problem is this:
given the fact that the only way I should select my values are by means of a cursor (is it really so ???), how can I fill my "host vectors" with each value returned at each FETCH inside my PL/SQL block ?
Here is some ex. with the code I'm trying and which gives my a compile error:
EXEC SQL BEGIN DECLARE SECTION;
long v_valuta; long vv_valuta;
long v_cantitate; long vv_cantitate;
long v_reducere; long vv_reducere;
long v_codtermen; long vv_codtermen;
double v_pretunit; double vv_pretunit;
double v_pretunitval; double vv_pretunitval;
VARCHAR V_DENMAT; VARCHAR VV_DENMAT;
VARCHAR V_UMORA; VARCHAR VV_UMORA;
VARCHAR V_CODPOZ; VARCHAR VV_CODPOZ;
double temp_cant; double vv_temp_cant;
double temp_pretu; double vv_temp_pretu;
double temp_reducere; double vv_temp_reducere;
int i, j;
[......... I hope I'm not cutting anything useful here, for this example]
EXEC SQL END DECLARE SECTION;
Here, v_cursval is already filled with a long value somewhere before, and IDCOM likewise (in fact this last is passed as a parameter to my PRO/C function !).
Actually, that exact piece of code doesn't give an compile error, but if I uncomment the part which is surrounded by comments, it's OK from the compiller point of view, but all those vectors contains rubbish (I can't tell why !!!), and if I try something like
:vv_pretunit[:i] := :v_pretunit; (which, BTW, looks more inteligible to me !!) the compiller gives me the error PLS-S-00103 which says something about wrong symbol "[" beeing present there.
That's it !
Anyone have o clue (no matter what) ?
P.S. With those comments beeing there, the last row of data gets filled OK (as it should be !) and those values are exactly what I want (I've written them to a log file); more : that table AAA contains correct values form the FETCHed line !
Unfortunattely, I can't put them together in those vectors, so that I can manipulate them later in some way (namely, gather them together in a string) !