Tag: o

编译OCILIB OCI包装库的问题

我正在尝试在ocilib3.8.1/demo编译ocilib3.8.1/demo 。 在成功安装了ocilib库之后,我在下面编译了demo source conn.c: #include “ocilib.h” int main(void) { OCI_Connection *cn; if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT)) return EXIT_FAILURE; cn = OCI_ConnectionCreate(“db”, “usr”, “pwd”, OCI_SESSION_DEFAULT); printf(“Server major version : %i\n”, OCI_GetServerMajorVersion(cn)); printf(“Server minor version : %i\n”, OCI_GetServerMinorVersion(cn)); printf(“Server revision version : %i\n\n”, OCI_GetServerRevisionVersion(cn)); printf(“Connection version : %i\n\n”, OCI_GetVersionConnection(cn)); OCI_Cleanup(); return EXIT_SUCCESS; } 使用gcc编译: $gcc -Wall conn.c […]

如何从OCI调用ORACLE函数?

我可以通过构造命令的SQL命令在C程序中通过OCI调用ORACLE存储过程,这里是我的代码的简短片段: /* build sql statement calling stored procedure */ strcpy ( sql_stmt, “call get_tab_info(:x)” ); rc = OCIStmtPrepare(p_sql, p_err, sql_stmt, (ub4) strlen (sql_stmt), (ub4) OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT); 但是如何使用以下签名构建对ORACLE函数的调用(在我的C程序中): CREATE OR REPLACE FUNCTION get_seq_number (p_table_name IN VARCHAR2, p_seq_type IN VARCHAR2) RETURN NUMBER IS 要在PL / SQL中调用该函数,我会使用例如: v_seq := get_seq_number(v_tabname, v_seqtype); 如何构造SQL字符数组(sql_stmt)来调用我的C程序中的ORACLE函数?