2 u011490211 u011490211 于 2014.01.15 17:01 提问

ESQL的函数使用传入的参数总报未定义
请教各位大神,本人写C代码的,本来链接数据库一直用公司的平台封装的函数。今天自己研究了下esql封装几个最简单的函数,但是传给esql函数的参数,总说未定义,是什么问题。
#include <stdio.h>

EXEC SQL INCLUDE sqlca;
EXEC SQL INCLUDE sqlda;
EXEC SQL INCLUDE sqlhdr;
EXEC SQL INCLUDE decimal;
EXEC SQL INCLUDE locator;
EXEC SQL INCLUDE varchar;
EXEC SQL INCLUDE datetime;
EXEC SQL INCLUDE sqlstype;
EXEC SQL INCLUDE sqltypes;
EXEC SQL INCLUDE sqlstype;

EXEC SQL BEGIN DECLARE SECTION;
typedef struct
{
    char usrname[64];   /* 用户名 */
    char dbname[64];    /* 数据库名 */
    char passwd[64];    /* 密码 */
}db_conn_info;

EXEC SQL END DECLARE SECTION;

/* 连接至INFORMIX数据库 */
int db_ifx_open(db_conn_info *source)
{
    EXEC SQL CONNECT TO :source->dbname;

    return sqlca.sqlcode;
}

/* 断开与INFORMIX数据库的连接 */
int db_ifx_close(db_conn_info *source)
{  
    EXEC SQL DISCONNECT :source->dbname;

    return sqlca.sqlcode;
}`

用esql编译总报错:
`esqlc: "demo_fun.ec", line 25: Error -33040: Object 'source' was not declared.

esqlc: "demo_fun.ec", line 33: Error -33040: Object 'source' was not declared.`

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!