proc oracle sqlcxt-proc 嵌入sql 数据库为oracle,忙帮看看程序有问题吗?

问题描述

proc 嵌入sql 数据库为oracle,忙帮看看程序有问题吗?

proc预编译通过生成相应的c文件,然后通过c编译器编译提示D:workspacetestmain.c|327|undefined reference to `sqlcxt'|
我初步判断不是因为库函数没有引用,因为我把sqlcxt函数中的参数改变的时候提示参数数目不对,所以是有这个函数的,我怀疑是我写的程序有问题现在程序贴出来。系统用的win764位,oracle11g64位,客户端什么的完全安装,编译器用的codeblock

#include
#include

EXEC SQL INCLUDE SQLCA;
EXEC SQL BEGIN DECLARE SECTION;
int userid;
int thisno;
VARCHAR username[20];
VARCHAR password[20];
VARCHAR serv[20];
EXEC SQL END DECLARE SECTION;

main()
{
thisno=1;
strcpy(username.arr,"scott");

username.len=(unsigned short)strlen((char *)username.arr);

strcpy(password.arr,"tiger");

password.len=(unsigned short)strlen((char *)password.arr);
strcpy(serv.arr,"JASON");

serv.len=(unsigned short)strlen((char *)serv.arr);

 EXEC SQL CONNECT :username IDENTIFIED BY :password USING :serv;
printf("Connect!n");

 EXEC SQL SELECT no INTO :userid FROM liuyazheng WHERE no =:thisno;
 printf( "First name = %dn",userid);
EXEC SQL COMMIT WORK RELEASE;
printf("Disconnect!n");
 return 1;
}

下面是预编译生成的代码:

/* Result Sets Interface */
#ifndef SQL_CRSR

define SQL_CRSR

struct sql_cursor
{
unsigned int curocn;
void ptr1;
void *ptr2;
unsigned int magic;
};
typedef struct sql_cursor sql_cursor;
typedef struct sql_cursor SQL_CURSOR;
#endif /
SQL_CRSR */

/* Thread Safety */
typedef void * sql_context;
typedef void * SQL_CONTEXT;

/* Object support */
struct sqltvn
{
unsigned char *tvnvsn;
unsigned short tvnvsnl;
unsigned char *tvnnm;
unsigned short tvnnml;
unsigned char *tvnsnm;
unsigned short tvnsnml;
};
typedef struct sqltvn sqltvn;

struct sqladts
{
unsigned int adtvsn;
unsigned short adtmode;
unsigned short adtnum;
sqltvn adttvn[1];
};
typedef struct sqladts sqladts;

static struct sqladts sqladt = {
1,1,0,
};

/* Binding to PL/SQL Records */
struct sqltdss
{
unsigned int tdsvsn;
unsigned short tdsnum;
unsigned char *tdsval[1];
};
typedef struct sqltdss sqltdss;
static struct sqltdss sqltds =
{
1,
0,
};

/* File name & Package Name */
struct sqlcxp
{
unsigned short fillen;
char filnam[8];
};
static const struct sqlcxp sqlfpn =
{
7,
"main.pc"
};

static unsigned int sqlctx = 9211;

static struct sqlexd {
unsigned int sqlvsn;
unsigned int arrsiz;
unsigned int iters;
unsigned int offset;
unsigned short selerr;
unsigned short sqlety;
unsigned int occurs;
const short *cud;
unsigned char *sqlest;
const char *stmt;
sqladts *sqladtp;
sqltdss *sqltdsp;
void **sqphsv;
unsigned int *sqphsl;
int *sqphss;
void **sqpind;
int *sqpins;
unsigned int *sqparm;
unsigned int **sqparc;
unsigned short *sqpadto;
unsigned short *sqptdso;
unsigned int sqlcmax;
unsigned int sqlcmin;
unsigned int sqlcincr;
unsigned int sqlctimeout;
unsigned int sqlcnowait;
int sqfoff;
unsigned int sqcmod;
unsigned int sqfmod;
void *sqhstv[4];
unsigned int sqhstl[4];
int sqhsts[4];
void *sqindv[4];
int sqinds[4];
unsigned int sqharm[4];
unsigned int *sqharc[4];
unsigned short sqadto[4];
unsigned short sqtdso[4];
} sqlstm = {12,4};

/* SQLLIB Prototypes /
extern void sqlcxt (void *
, unsigned int ,
struct sqlexd *, const struct sqlcxp *);
extern void sqlcx2t(void *
, unsigned int ,
struct sqlexd *, const struct sqlcxp *);
extern void sqlbuft(void *
, char );
extern void sqlgs2t(void *
, char );
extern void sqlorat(void *
, unsigned int *, void *);

/* Forms Interface */
static const int IAPSUCC = 0;
static const int IAPFAIL = 1403;
static const int IAPFTL = 535;
extern void sqliem(unsigned char *, signed int *);

typedef struct { unsigned short len; unsigned char arr[1]; } VARCHAR;
typedef struct { unsigned short len; unsigned char arr[1]; } varchar;

/* cud (compilation unit data) array */
static const short sqlcud0[] =
{12,4130,852,0,0,
5,0,0,0,0,0,27,24,0,0,4,4,0,1,0,1,9,0,0,1,9,0,0,1,9,0,0,1,10,0,0,
36,0,0,2,48,0,4,26,0,0,2,1,0,1,0,2,3,0,0,1,3,0,0,
59,0,0,3,0,0,30,28,0,0,0,0,0,1,0,
};

#include
#include

/* EXEC SQL INCLUDE SQLCA;
/
/

  • $Header: sqlca.h 24-apr-2003.12:50:58 mkandarp Exp $ sqlca.h
    */

/* Copyright (c) 1985, 2003, Oracle Corporation. All rights reserved. */

/*
NAME
SQLCA : SQL Communications Area.
FUNCTION
Contains no code. Oracle fills in the SQLCA with status info
during the execution of a SQL stmt.
NOTES



*** This file is SOSD. Porters must change the data types ***
*** appropriately on their platform. See notes/pcport.doc ***
*** for more information. ***



If the symbol SQLCA_STORAGE_CLASS is defined, then the SQLCA
will be defined to have this storage class. For example:

#define SQLCA_STORAGE_CLASS extern

will define the SQLCA as an extern.

If the symbol SQLCA_INIT is defined, then the SQLCA will be
statically initialized. Although this is not necessary in order
to use the SQLCA, it is a good pgming practice not to have
unitialized variables. However, some C compilers/OS's don't
allow automatic variables to be init'd in this manner. Therefore,
if you are INCLUDE'ing the SQLCA in a place where it would be
an automatic AND your C compiler/OS doesn't allow this style
of initialization, then SQLCA_INIT should be left undefined --
all others can define SQLCA_INIT if they wish.

If the symbol SQLCA_NONE is defined, then the SQLCA variable will
not be defined at all. The symbol SQLCA_NONE should not be defined
in source modules that have embedded SQL. However, source modules
that have no embedded SQL, but need to manipulate a sqlca struct
passed in as a parameter, can set the SQLCA_NONE symbol to avoid
creation of an extraneous sqlca variable.

MODIFIED
lvbcheng 07/31/98 - long to int
jbasu 12/12/94 - Bug 217878: note this is an SOSD file
losborne 08/11/92 - No sqlca var if SQLCA_NONE macro set
Clare 12/06/84 - Ch SQLCA to not be an extern.
Clare 10/21/85 - Add initialization.
Bradbury 01/05/86 - Only initialize when SQLCA_INIT set
Clare 06/12/86 - Add SQLCA_STORAGE_CLASS option.
*/

#ifndef SQLCA
#define SQLCA 1

struct sqlca
{
/* ub1 / char sqlcaid[8];
/
b4 / int sqlabc;
/
b4 / int sqlcode;
struct
{
/
ub2 / unsigned short sqlerrml;
/
ub1 / char sqlerrmc[70];
} sqlerrm;
/
ub1 / char sqlerrp[8];
/
b4 / int sqlerrd[6];
/
ub1 / char sqlwarn[8];
/
ub1 */ char sqlext[8];
};

#ifndef SQLCA_NONE
#ifdef SQLCA_STORAGE_CLASS
SQLCA_STORAGE_CLASS struct sqlca sqlca
#else
struct sqlca sqlca
#endif

#ifdef SQLCA_INIT
= {
{'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' '},
sizeof(struct sqlca),
0,
{ 0, {0}},
{'N', 'O', 'T', ' ', 'S', 'E', 'T', ' '},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0}
}
#endif
;
#endif

#endif

/* end SQLCA */

/* EXEC SQL BEGIN DECLARE SECTION; */

int userid;
int thisno;
/* VARCHAR username[20]; */
struct { unsigned short len; unsigned char arr[20]; } username;

/* VARCHAR password[20]; */
struct { unsigned short len; unsigned char arr[20]; } password;

/* VARCHAR serv[20]; */
struct { unsigned short len; unsigned char arr[20]; } serv;

/* EXEC SQL END DECLARE SECTION; */

main()
{
thisno=1;
strcpy(username.arr,"scott");
username.len=(unsigned short)strlen((char )username.arr);
strcpy(password.arr,"tiger");
password.len=(unsigned short)strlen((char *)password.arr);
strcpy(serv.arr,"JASON");
serv.len=(unsigned short)strlen((char *)serv.arr);
/
EXEC SQL CONNECT :username IDENTIFIED BY :password USING :serv; */

{
struct sqlexd sqlstm;
sqlstm.sqlvsn = 12;
sqlstm.arrsiz = 4;
sqlstm.sqladtp = &sqladt;
sqlstm.sqltdsp = &sqltds;
sqlstm.iters = (unsigned int )10;
sqlstm.offset = (unsigned int )5;
sqlstm.cud = sqlcud0;
sqlstm.sqlest = (unsigned char )&sqlca;
sqlstm.sqlety = (unsigned short)4352;
sqlstm.occurs = (unsigned int )0;
sqlstm.sqhstv[0] = ( void *)&username;
sqlstm.sqhstl[0] = (unsigned int )22;
sqlstm.sqhsts[0] = ( int )22;
sqlstm.sqindv[0] = ( void *)0;
sqlstm.sqinds[0] = ( int )0;
sqlstm.sqharm[0] = (unsigned int )0;
sqlstm.sqadto[0] = (unsigned short )0;
sqlstm.sqtdso[0] = (unsigned short )0;
sqlstm.sqhstv[1] = ( void *)&password;
sqlstm.sqhstl[1] = (unsigned int )22;
sqlstm.sqhsts[1] = ( int )22;
sqlstm.sqindv[1] = ( void *)0;
sqlstm.sqinds[1] = ( int )0;
sqlstm.sqharm[1] = (unsigned int )0;
sqlstm.sqadto[1] = (unsigned short )0;
sqlstm.sqtdso[1] = (unsigned short )0;
sqlstm.sqhstv[2] = ( void *)&serv;
sqlstm.sqhstl[2] = (unsigned int )22;
sqlstm.sqhsts[2] = ( int )22;
sqlstm.sqindv[2] = ( void *)0;
sqlstm.sqinds[2] = ( int )0;
sqlstm.sqharm[2] = (unsigned int )0;
sqlstm.sqadto[2] = (unsigned short )0;
sqlstm.sqtdso[2] = (unsigned short )0;
sqlstm.sqphsv = sqlstm.sqhstv;
sqlstm.sqphsl = sqlstm.sqhstl;
sqlstm.sqphss = sqlstm.sqhsts;
sqlstm.sqpind = sqlstm.sqindv;
sqlstm.sqpins = sqlstm.sqinds;
sqlstm.sqparm = sqlstm.sqharm;
sqlstm.sqparc = sqlstm.sqharc;
sqlstm.sqpadto = sqlstm.sqadto;
sqlstm.sqptdso = sqlstm.sqtdso;
sqlstm.sqlcmax = (unsigned int )100;
sqlstm.sqlcmin = (unsigned int )2;
sqlstm.sqlcincr = (unsigned int )1;
sqlstm.sqlctimeout = (unsigned int )0;
sqlstm.sqlcnowait = (unsigned int )0;
sqlcxt((void *
)0, &sqlctx, &sqlstm, &sqlfpn);
}

printf("Connect!n");
/* EXEC SQL SELECT no INTO :userid FROM liuyazheng WHERE no =:thisno; */

{
struct sqlexd sqlstm;
sqlstm.sqlvsn = 12;
sqlstm.arrsiz = 4;
sqlstm.sqladtp = &sqladt;
sqlstm.sqltdsp = &sqltds;
sqlstm.stmt = "select no into :b0 from liuyazheng where no=:b1";
sqlstm.iters = (unsigned int )1;
sqlstm.offset = (unsigned int )36;
sqlstm.selerr = (unsigned short)1;
sqlstm.cud = sqlcud0;
sqlstm.sqlest = (unsigned char )&sqlca;
sqlstm.sqlety = (unsigned short)4352;
sqlstm.occurs = (unsigned int )0;
sqlstm.sqhstv[0] = ( void *)&userid;
sqlstm.sqhstl[0] = (unsigned int )sizeof(int);
sqlstm.sqhsts[0] = ( int )0;
sqlstm.sqindv[0] = ( void *)0;
sqlstm.sqinds[0] = ( int )0;
sqlstm.sqharm[0] = (unsigned int )0;
sqlstm.sqadto[0] = (unsigned short )0;
sqlstm.sqtdso[0] = (unsigned short )0;
sqlstm.sqhstv[1] = ( void *)&thisno;
sqlstm.sqhstl[1] = (unsigned int )sizeof(int);
sqlstm.sqhsts[1] = ( int )0;
sqlstm.sqindv[1] = ( void *)0;
sqlstm.sqinds[1] = ( int )0;
sqlstm.sqharm[1] = (unsigned int )0;
sqlstm.sqadto[1] = (unsigned short )0;
sqlstm.sqtdso[1] = (unsigned short )0;
sqlstm.sqphsv = sqlstm.sqhstv;
sqlstm.sqphsl = sqlstm.sqhstl;
sqlstm.sqphss = sqlstm.sqhsts;
sqlstm.sqpind = sqlstm.sqindv;
sqlstm.sqpins = sqlstm.sqinds;
sqlstm.sqparm = sqlstm.sqharm;
sqlstm.sqparc = sqlstm.sqharc;
sqlstm.sqpadto = sqlstm.sqadto;
sqlstm.sqptdso = sqlstm.sqtdso;
sqlcxt((void *
)0, &sqlctx, &sqlstm, &sqlfpn);
}

printf( "First name = %dn",userid);
/* EXEC SQL COMMIT WORK RELEASE; */

{
struct sqlexd sqlstm;
sqlstm.sqlvsn = 12;
sqlstm.arrsiz = 4;
sqlstm.sqladtp = &sqladt;
sqlstm.sqltdsp = &sqltds;
sqlstm.iters = (unsigned int )1;
sqlstm.offset = (unsigned int )59;
sqlstm.cud = sqlcud0;
sqlstm.sqlest = (unsigned char )&sqlca;
sqlstm.sqlety = (unsigned short)4352;
sqlstm.occurs = (unsigned int )0;
sqlcxt((void *
)0, &sqlctx, &sqlstm, &sqlfpn);
}

printf("Disconnect!n");
return 1;
}

时间: 2024-11-02 15:35:01

proc oracle sqlcxt-proc 嵌入sql 数据库为oracle,忙帮看看程序有问题吗?的相关文章

SQL数据库与oracle数据库镜像有什么不同对比_数据库其它

Oracle数据库与MSSQL数据操作上有很大的不同,但是,在镜像操作方面有类比的地方.这篇文章关于MSSQL数据库镜像在Oracle数据库中是如何实现的,它们之间存在哪些差异呢. 首先,微软SQL数据库中的镜像数据库类似于Oracle数据库中的备用数据库.我说的只是类似,确切的说,我们需要考虑不同数据库在自己体系中的差异.MSSQL作为一个实例来操作,一个实例包含几个数据库,你首先要登录一个实例,然后选择哪个数据库作用于该实例.而在Oracle数据库中,简单模式(忽略RAC)就只有一个数据库与

SQL Server访问Oracle查询性能问题解决

1. 问题 系统有个模块,需要查询Oracle数据库中的数据.目前是通过建立链接服务器实现的. SQLServer访问Oracle实现 可参考这篇文章http://www.cnblogs.com/gnielee/archive/2010/09/07/access-oracle-from-sqlserver.html 目前的查询语句就是一个简单的带where条件的查询语句,类似如下: SELECT*FROM LINKED_NAME..ACCOUNT_NAME.TABLE_NAME WHERE CO

数据统计-oracle中如何进行sql优化

问题描述 oracle中如何进行sql优化 在oracle中如何进行sql优化,not in以及not null,in,请各位大侠指教,谢谢. 解决方案 http://zhidao.baidu.com/link?url=ys3SrPa01XA7QSVwKnZfQzCgXJ7wkWH6_A5Xnb1vSRoyDmlfqCyY2W-K4le1Vgku4wVxNc8A69H8LESrJxWlsK

SQL Server与Oracle数据库在查询优化上的差异(一)

一般来说,Oracle数据库在大型数据环境下,其运行性能比SQL Server数据库效率要高.单从查询优化上讲,两者就有比较大的差异.下面,笔者将数据库查询优化的差异做一个描述,若有不准确的地方,还请大家批评指教. 一. 在数据库排序查询优化上的差异. 在讲解这个内容之前,为了读者能够清楚我讲的内容,我要先谈一个概念.命中率,它是指从内存中取得数据而不从磁盘中取得数据的比率.我们在前几篇文章中都提到过,当在数据库中查询数据时,数据库服务器都是先从内存中寻找数据.只有在内存中数据不存在的情况下,才

转换数据库-数据库:Oracle数据库转换成SQL server数据库

问题描述 数据库:Oracle数据库转换成SQL server数据库 把oracle数据库转换成SQL server数据库(2008 r2)版本的,数据迁移,大概百万条数据,有什么好的办法或者是执行语句嘛: 解决方案 我只知道可以把脚本倒出来 然后在sql中执行 解决方案二: http://wenku.baidu.com/link?url=TA7z0XmVyfKHyTQqiPwE6gAdkKbFG7ngBBL75mvjbRbAGFVElPyxOLFSvNT4YskRl8KLdeVdOlHc8a6

sql-通过SQL数据库,创建oracle数据库链接,始终不成功!

问题描述 通过SQL数据库,创建oracle数据库链接,始终不成功! 环境如下: 1.1台服务器为SQL2005数据库,安装了oracle client11g 2.1台服务器为oracle 10g数据库,安装了oracle client10g,已经创建了数据库为test,有表tab1. 3.两台服务器监听已经配置,并测试提示链接成功! 4.通过SQL 2005数据库创建服务器,使用Oracle Provider for OLE DB 接口创建成功,链接服务器名称为:ORAC 5.通过select

pl sql-用pl/sql连接oracle出现异常,刚刚装上oracle,没有数据库

问题描述 用pl/sql连接oracle出现异常,刚刚装上oracle,没有数据库 解决方案 在oracle工具net manager里面配置的数据库链接对不对,里面可以测试的. 测试通过后,打开plsql会自动加载数据库. 解决方案二: 数据库的连接字符串估计有问题,所以连接不上,出错了 解决方案三: PL/SQL的监听没有设置对吧 解决方案四: PL/SQL连接oracle数据库oracle配置数据库连接[PL/SQL]

Vertica的这些事<六>—— SQL Server、Oracle、MySQL和Vertica数据库常用函数对比

SQL Server.Oracle.MySQL和Vertica数据库常用函数对比 Vertica数据库是HP公司新收购的用于BI方面的数据库. 绝对值 S:select abs(-1) value O:select abs(-1) value from dual M:select abs(-1) value from dual V:select abs(-1) 向上取整 S:select ceiling(-1.001) value O:select ceil(-1.001) value from

从SQL SERVER 向ORACLE 8迁移的技术实现方案

oracle|server  不知道从哪里得到这个文档,有用就放上来了 -gwb  数据库端SQL语法的迁移以下为常用的SQL语法迁移,包括数据类型.ID列向SEQUENCE迁移.表(主键.外键.CHECK.UNIQUE.DEFAULT.INDEX).游标.存储过程.函数.触发器.常用SQL语法与函数几个方面,考虑SQL SERVER的实际情况,没有涉及ORACLE特有的PACKAGE.EXCEPTION等.在以下的描述中,将SQL SERVER的TRANSACT-SQL简称为T-SQL.在OR