proC and DML returning...

From: Volker Hetzer <volker.hetzer_at_ieee.org>
Date: Tue, 9 Mar 2004 18:48:26 +0100
Message-ID: <c2l01a$75s$1_at_nntp.fujitsu-siemens.com>



Hi!
We are having our first go at the dml returning clause in embedded sql and somehow we can't get our program to figure out the number of returned columns. Here's our test case:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#if defined(_WIN32)
#include <malloc.h>
#endif
#include <sqlcpr.h>
#include <assert.h>

int main(int argc, char**argv)
 {
 int i;
 EXEC SQL BEGIN DECLARE SECTION;
  char *dyn_statement="insert into emp(ename) values (:hv1) returning eno into :hv2";   const unsigned char *bind_array[1]={"volker"};   int type = 12;
  int len = 255;
  int input_occurs,input_count,out_count;  EXEC SQL END DECLARE SECTION;  EXEC SQL CONNECT :"spielplatz/spielplatz_at_ecadbib" ;

 EXEC SQL ALLOCATE DESCRIPTOR 'input_descriptor';

 EXEC SQL PREPARE S FROM :dyn_statement;  EXEC SQL DESCRIBE INPUT S USING DESCRIPTOR 'input_descriptor';  EXEC SQL GET DESCRIPTOR 'input_descriptor':input_count = COUNT;

 fprintf(stderr,"COUNT OF INPUT HOST VARIABLES HERE IS: %d\n",input_count);

 for (i = 0; i < input_count; i++)
  {
  input_occurs = i + 1;
  EXEC SQL SET DESCRIPTOR 'input_descriptor' VALUE :input_occurs TYPE = :type, LENGTH = :len, REF DATA = :bind_array[i];   }

 EXEC SQL DECLARE C CURSOR FOR S;
 EXEC SQL ALLOCATE DESCRIPTOR 'returning_descriptor';

 EXEC SQL OPEN C USING DESCRIPTOR 'input_descriptor' INTO DESCRIPTOR 'returning_descriptor' ;  EXEC SQL DESCRIBE OUTPUT S USING DESCRIPTOR 'returning_descriptor';  EXEC SQL GET DESCRIPTOR 'returning_descriptor' :out_count=COUNT;

 fprintf(stderr,"COUNT OF OUTPUT HOST VARIABLES IS: %d\n",out_count);

 /*Is the Cursor stuff impossible and only the EXECUTE can be made to work?*/  /* EXEC SQL EXECUTE S USING SQL DESCRIPTOR 'input_descriptor' INTO DESCRIPTOR 'returning_descriptor';*/  return 0;
 }

This program tells me that my statement has two input host variables and no output host variables. Does anyone know what we are doing wrong?

Lots of Greetings and Thanks!
Volker Received on Tue Mar 09 2004 - 18:48:26 CET

Original text of this message