- 论坛徽章:
- 0
|
20可用积分
==========================
大家帮我看看这个问题啊,顿首谢!
我的所有代码都在这里,究竟是什么错呢?
哪位高手朋友路过,求您指点迷津!
感谢"gawk"
==========================
我的pro*c文件:
-------------------------
[oracle@oracle11gTux1 lessons]$ cat ./gg.pc
#define USERNAME "pw"
#define PASSWORD "pw"
#define SERVICE "wilson"
#include <stdio.h>
#include <stdlib.h>
#include "sqlca.h"
EXEC SQL INCLUDE SQLCA;
typedef char ascie[20];
EXEC SQL BEGIN DECLARE SECTION;
char *username=USERNAME;
char *passwd=PASSWORD;
char *service=SERVICE;
ascie name;
int age;
float salary;
EXEC SQL END DECLARE SECTION;
void sqlerr()
{
EXEC SQL WHENEVER SQLERROR CONTINUE;
printf("\n%.*s\n",sqlca.sqlerrm.sqlerrml,sqlca.sqlerrm.sqlerrmc);
EXEC SQL ROLLBACK WORK RELEASE;
exit(1);
}
int main()
{
EXEC SQL WHENEVER SQLERROR DO sqlerr();
EXEC SQL CONNECT :username IDENTIFIED BY :passwd USING :service;
EXEC SQL DECLARE emp_cursor CURSOR FOR
SELECT NAME,AGE,SALARY FROM EMP;
EXEC SQL OPEN emp_cursor;
while(true)
{
EXEC SQL WHENEVER NOT FOUND DO break;
EXEC SQL FETCH emp_cursor
INTO :name, :age, :salary;
printf("\n%s",sqlca.sqlerrd[2]);
printf("\n%.*s\n",name,age,salary);
}
EXEC SQL CLOSE emp_cursor;
EXEC SQL COMMIT WORK RELEASE;
//if (sqlca.sqlcode == 0)
// printf("\n Connected!\n");
//else
// printf("\n%.*s\n",sqlca.sqlerrm.sqlerrml,sqlca.sqlerrm.sqlerrmc);
return 0;
}
[oracle@oracle11gTux1 lessons]$
以上标红色部分应该怎么写?
-------------------------------------------报的错误:
[oracle@oracle11gTux1 lessons]$ proc ./gg.pc
Pro*C/C++: Release 11.1.0.6.0 - Production on Thu Jun 25 05:15:15 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
System default option values taken from: /u01/oracle/precomp/admin/pcscfg.cfg
Syntax error at line 17, column 2, file ./gg.pc:
Error at line 17, column 2 in file ./gg.pc
ascie name;
.1
PCC-S-02201, Encountered the symbol "ascie" when expecting one of the following:
auto, char, const, double, enum, extern, float, int, long,
ulong_varchar, OCIBFileLocator OCIBlobLocator,
OCIClobLocator, OCIDateTime, OCIExtProcContext, OCIInterval,
OCIRowid, OCIDate, OCINumber, OCIRaw, OCIString, register,
short, signed, sql_context, sql_cursor, static, struct,
typedef, union, unsigned, utext, uvarchar, varchar, void,
volatile, a typedef name, a precompiled header, exec oracle,
exec oracle begin, exec, exec sql, exec sql begin,
exec sql end, exec sql type, exec sql var, exec sql include,
The symbol "enum," was substituted for "ascie" to continue.
Error at line 0, column 0 in file ./gg.pc
PCC-F-02102, Fatal error while doing C preprocessing
[oracle@oracle11gTux1 lessons]$
[ 本帖最后由 simhare 于 2009-6-25 17:51 编辑 ] |
最佳答案
查看完整内容
嗯,我看了oracle中的例子是这样弄的,我自己proc 执行了一下能通过你自己在编译一下看看运行怎么样
|