Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Newbie Question about ProC/C++ v2.2
The problem is that I have a function that has a parameter,
and I would like that parameter value to be used in a SELECT
statement to my ORACLE table so that I can retrieve multiple
records.
I want to be able to pass to the GetChildrenNodes an integer and get all of those out of my database.
Below is my sample pre-compiled source code (I deleted all of the header files I included, but basically this is the source code I want to Pre-Compile) See below the test code for the errors I am getting....
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR sqlstmt[STMT_LEN];
VARCHAR name[NAME_LEN];
int idx; int parent;
EXEC SQL CONNECT "foobar_at_foobar" IDENTIFIED BY "foobar"; strcpy((char *)sqlstmt.arr, "SELECT name, idx, parent FROM
my_tree WHERE parent = :v1");
sqlstmt.len = (short) strlen((char *)sqlstmt.arr);
EXEC SQL PREPARE S FROM :sqlstmt;
EXEC SQL DECLARE C CURSOR FOR S;
EXEC SQL OPEN C USING :parentnode;
EXEC SQL WHENEVER NOT FOUND DO break;
while (1)
{
EXEC SQL FETCH C INTO :name, :idx, :parent; name.arr[name.len] = '\0'; cout << (char *)name.arr << idx << parent <<endl;}
void main()
{
GetChildrenNodes(0); GetChildrenNodes(1); GetChildrenNodes(2);
1st) This will not pre-compile
2nd) When I declare a new variable in the declare section
called tempparentnode and then set tempparentnode=parentnode and subsitute the line: EXEC SQL OPEN C USING :parentnode; with EXEC SQL OPEN C USING :tempparentnode; STILL DOESN'T WORK, I get an oracle error of: ORA-01405: fetched column value is NULL
Any ideas as to what I am missing or a better way to do things.
Tim
tim_at_trilogy-tech.com
Received on Fri Jul 31 1998 - 09:48:18 CDT
![]() |
![]() |