我有一些遗留的Pro * C代码使用下面的结构。
这种模式可以在在线论坛上找到,但在Oracle文档中没有任何内容
特别是Google can't find any doc about "sqhsts" on the Oracle website。
这种模式是否记录在哪里? 它被认为是一种很好的编程习惯吗?
/* cud (compilation unit data) array */
static const short sqlcud0[] =
{10,4130,832,0,0,
5,0,0,1,0,0,27,23,0,0,4,4,0,1,0,1,97,0,0,1,97,0,0,1,97,0,0,1,10,0,0,
36,0,0,2,30,0,4,25,0,0,1,0,0,1,0,2,97,0,0,
};
/* EXEC SQL CONNECT :user IDENTIFIED BY :pwd USING :url; */
{
struct sqlexd sqlstm;
sqlstm.sqlvsn = 10;
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)256;
sqlstm.occurs = (unsigned int )0;
sqlstm.sqhstv[0] = ( void *)user;
sqlstm.sqhstl[0] = (unsigned int )0;
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 *)pwd;
sqlstm.sqhstl[1] = (unsigned int )0;
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.sqhstv[2] = ( void *)url;
(代码从here复制,但与我的相似)
答案 0 :(得分:6)
Pro * C从
等语句中创建低级别C.EXEC SQL BEGIN DECLARE SECTION;
EXEC SQL END DECLARE SECTION;
为您声明的每个数据项创建类似OCI的描述符。使用声明部分中编码的内容,将使用这些绑定变量嵌入sql的其他语句(EXEC SQL ...;
)转换为较低级别的调用。 Pro * C很旧。我参与了25年前Pro * C的第一次测试。 ......不推荐。
在启用警告的现代编译器编译时,Pro * C预编译生成的代码并不总是完美无缺。它也不是可读的。如果您想学习OCI编程,您可以了解正在发生的事情。除非你想做一些特殊的任务,否则也不是真的推荐。
示例任务:OCI用于为Oracle创建外部C / C ++库。它几乎可以让你在oracle中以几乎任何你想做的事情处理细粒度。从这里开始:
http://www.oracle.com/technetwork/database/features/oci/index.html