Pro*C and character to-string conversion....

From: Volker Hetzer <volker.hetzer_at_ieee.org>
Date: Mon, 21 Jun 2004 22:28:41 +0200
Message-ID: <cb7gdp$40e$1_at_nntp.fujitsu-siemens.com>



Hi!
I'm trying to do a generic library using reference semantics which expects a statement and returns the results.
Only, I have trouble getting the true returned length out of Pro*C. This is a small testcase:
#include <stdio.h>
EXEC SQL INCLUDE SQLCA;
EXEC SQL WHENEVER SQLERROR stop;
int main(int argc,char*argv[])
 {
 EXEC SQL BEGIN DECLARE SECTION;
 int outcolcount=-1;
 char OutVal[100];
 int outlength=0;
 int Type=1;
 int Length=100;
 EXEC SQL END DECLARE SECTION;  EXEC SQL CONNECT :"test/test_at_test";
 EXEC SQL PREPARE S FROM "select sysdate from dual";  EXEC SQL DECLARE C CURSOR FOR S;
 EXEC SQL OPEN C;
 EXEC SQL ALLOCATE DESCRIPTOR 'output_descriptor';  EXEC SQL DESCRIBE OUTPUT S USING DESCRIPTOR 'output_descriptor';  EXEC SQL SET DESCRIPTOR 'output_descriptor' VALUE 1

    TYPE=:Type,
    LENGTH=:Length,
    REF DATA=:OutVal,
    REF RETURNED_LENGTH=:outlength;
 EXEC SQL FETCH C into descriptor 'output_descriptor';  printf("%i,%.100s\n",outlength,OutVal);  EXEC SQL ROLLBACK WORK RELEASE;
 return 0;
 }
Now, what I get is the correct date (21-JUN-04) but 0 as length. What I had hoped to get was 9.
Any ideas what I'm doing wrong?

Lots of Greetings!
Volker Received on Mon Jun 21 2004 - 22:28:41 CEST

Original text of this message