Home » Developer & Programmer » Precompilers, OCI & OCCI » Getting blank character when executing ESQL/C program
Getting blank character when executing ESQL/C program [message #94414] Sun, 17 October 2004 01:52
Fahad
Messages: 8
Registered: May 2004
Junior Member
Please help me with this issue.

I am executing a simple query using ESQL/C the result is blank character

please find the source below:

#include <stdio.h>
#include <string.h>

#define UNAME_LEN 20
#define PWD_LEN   40

EXEC SQL BEGIN DECLARE SECTION;
 
 char *username = "SCOTT";
 char *password = "TIGER";
 char *dptname;
 varchar deptname[[14]];
 int deptno;
EXEC SQL END DECLARE SECTION;
EXEC SQL INCLUDE SQLCA.H;

void main()
{
    int i;
      
    deptno = 40;
    dptname = "";

    printf("n***************START OF PROGRAM***************");
    printf("n-CONNECTING TO THE DATABASE-");
    EXEC SQL WHENEVER SQLERROR GOTO sql_error;
    EXEC SQL CONNECT :username IDENTIFIED BY :password;
    printf("nConnected to ORACLE as user: %s", username);

    EXEC SQL WHENEVER SQLERROR GOTO sql_error;
    EXEC SQL SELECT DNAME
             INTO :deptname
             FROM DEPT
             WHERE DEPTNO = 10;
    printf("n SQL : select dname from dept where deptno = 10");
    strncpy((char *) dptname, deptname.arr, deptname.len);
    printf("n Dept name : [[%s]] - ",dptname, deptname);
  
    EXEC SQL WHENEVER SQLERROR GOTO sql_error;
    EXEC SQL COMMIT WORK RELEASE;
    exit(0);

    sql_error:
 EXEC SQL WHENEVER SQLERROR CONTINUE;
 
 printf("Processing errorn");
 exit(1);
}

the result is the following :

***************START OF PROGRAM***************
-CONNECTING TO THE DATABASE-
Connected to ORACLE as user: SCOTT
 SQL : select dname from dept where deptno = 10
 Dept name : [[]] -

 
Previous Topic: pro*c/c++ free download sites
Next Topic: Thread-c+
Goto Forum:
  


Current Time: Fri Apr 19 10:43:04 CDT 2024