PDA

View Full Version : Pro*C and character to-string conversion....


Volker Hetzer
06-21-2004, 12:28 PM
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@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


MyLounge.com Site Map
Forum: Cars, Cell Phone, Database, Games, Home Improvement, IT, Music, School, Sports, Web Design, Web Server, Weight Loss

The MyLounge.com forum is intended for informational use only and should not be relied upon and is not a substitute for any advice. The information contained on MyLounge.com are opinions and suggestions of members and is not a representation of the opinions of MyLounge.com. MyLounge.com does not warrant or vouch for the accuracy, completeness or usefulness of any postings or the qualifications of any person responding. Please consult a expert or seek the services of an attorney in your area for more accuracy on your specific situation. Please note that our forums also serve as mirrors to Usenet newsgroups. Many posts you see on our forums are made by newsgroup users who may not be members of MyLounge.com Term of Service