#ifdef RCSID
static char *RCSid =
"$Header: rdbms/demo/cdemo81.c /main/10 2015/03/16 04:25:04 gak Exp $ ";
#endif /* RCSID */
/* Copyright (c) 1996, 2015, Oracle and/or its affiliates.
All rights reserved.*/
/*
NAME
cdemo81.c - Basic OCI V8 functionality
DESCRIPTION
* An example program which adds new employee
* records to the personnel data base. Checking
* is done to insure the integrity of the data base.
* The employee numbers are automatically selected using
* the current maximum employee number as the start.
*
* The program queries the user for data as follows:
*
* Enter employee name:
* Enter employee job:
* Enter employee salary:
* Enter employee dept:
*
* The program terminates if return key (CR) is entered
* when the employee name is requested.
*
* If the record is successfully inserted, the following
* is printed:
*
* "ename" added to department "dname" as employee # "empno"
Demonstrates creating a connection, a session and executing some SQL.
Also shows the usage of allocating memory for application use which has the
life time of the handle.
MODIFIED (MM/DD/YY)
gak 02/16/15 - Bug 20364067
aliu 02/04/14 - fix bug 18181823
aliu 09/03/13 - XbranchMerge aliu_bug-16007835 from st_rdbms_12.1.0.1
aliu 01/04/13 - fix bug 16007835 - add an variable for connect string
in OCIServerAttach
lburgess 04/14/06 - lowercase passwords
aliu 04/21/06 - use OCIEnvCreate and exit if it fails
mjaeger 07/14/99 - bug 808870: OCCS: convert tabs, no long lines
dchatter 10/14/98 - add the usage of xtrmemsz and usrmempp
azhao 06/23/97 - Use OCIBindByPos, OCIBindByName; clean up
echen 12/17/96 - OCI beautification
dchatter 07/18/96 - delete spurious header files
dchatter 07/15/96 - hda is a ub4 array to prevent bus error
mgianata 06/17/96 - change ociisc() to OCISessionBegin()
aroy 04/26/96 - change OCITransCommitt -> OCITransCommit
slari 04/24/96 - use OCITransCommitt
aroy 02/21/96 - fix bug in get descriptor handle call
lchidamb 02/20/96 - cdemo81.c converted for v8 OCI
lchidamb 02/20/96 - Creation
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <oci.h>
static text *username = (text *) "SCOTT";
static text *password = (text *) "tiger";
/* this dbname can be changed to point to a remote DB for demo to run with */
static text *dbname = (text *) "";
/* Define SQL statements to be used in program. */
static text *insert = (text *)"INSERT INTO emp(empno, ename, job, sal, deptno)\
VALUES (:empno, :ename, :job, :sal, :deptno)";
static text *seldept = (text *)"SELECT dname FROM dept WHERE deptno = :1";
static text *maxemp = (text *)"SELECT NVL(MAX(empno), 0) FROM emp";
static text *selemp = (text *)"SELECT ename, job FROM emp";
static OCIEnv *envhp = NULL;
static OCIError *errhp = NULL;
static void checkerr(/*_ OCIError *errhp, sword status _*/);
static void myfflush(/*_ void _*/);
static void free_handles(/*svchp, srvhp, authp, stmthp, stmthp1, stmthp2*/);
static void logout_detach_server(/*svchp, srvhp, authp*/);
static sword finish_demo(/*svchp, srvhp, authp, stmthp, stmthp1, stmthp2 */);
int main(/*_ int argc, char *argv[] _*/);
static sword status;
static boolean logged_on = FALSE;
int main(argc, argv)
int argc;
char *argv[];
{
sword empno, sal, deptno;
sword len, len2, rv, dsize, dsize2;
sb4 enamelen = 10;
sb4 joblen = 9;
sb4 deptlen = 14;
sb2 sal_ind, job_ind;
sb2 db_type, db2_type;
sb1 name_buf[20], name2_buf[20];
text *cp, *ename, *job, *dept;
sb2 ind[2]; /* indicator */
ub2 alen[2]; /* actual length */
ub2 rlen[2]; /* return length */
OCIDescribe *dschndl1 = (OCIDescribe *) 0,
*dschndl2 = (OCIDescribe *) 0,
*dschndl3 = (OCIDescribe *) 0;
OCISession *authp = (OCISession *) 0;
OCIServer *srvhp = NULL;
OCISvcCtx *svchp = NULL;
OCIStmt *inserthp = NULL,
*stmthp = NULL,
*stmthp1= NULL;
OCIDefine *defnp = (OCIDefine *) 0;
OCIBind *bnd1p = (OCIBind *) 0; /* the first bind handle */
OCIBind *bnd2p = (OCIBind *) 0; /* the second bind handle */
OCIBind *bnd3p = (OCIBind *) 0; /* the third bind handle */
OCIBind *bnd4p = (OCIBind *) 0; /* the fourth bind handle */
OCIBind *bnd5p = (OCIBind *) 0; /* the fifth bind handle */
OCIBind *bnd6p = (OCIBind *) 0; /* the sixth bind handle */
sword errcode = 0;
errcode = OCIEnvCreate((OCIEnv **) &envhp, (ub4) OCI_DEFAULT,
(dvoid *) 0, (dvoid * (*)(dvoid *,size_t)) 0,
(dvoid * (*)(dvoid *, dvoid *, size_t)) 0,
(void (*)(dvoid *, dvoid *)) 0, (size_t) 0, (dvoid **) 0);
if (errcode != 0) {
(void) printf("OCIEnvCreate failed with errcode = %d.\n", errcode);
exit(1);
}
(void) OCIHandleAlloc( (dvoid *) envhp, (dvoid **) &errhp, OCI_HTYPE_ERROR,
(size_t) 0, (dvoid **) 0);
/* server contexts */
(void) OCIHandleAlloc( (dvoid *) envhp, (dvoid **) &srvhp, OCI_HTYPE_SERVER,
(size_t) 0, (dvoid **) 0);
(void) OCIHandleAlloc( (dvoid *) envhp, (dvoid **) &svchp, OCI_HTYPE_SVCCTX,
(size_t) 0, (dvoid **) 0);
checkerr(errhp, OCIServerAttach ( srvhp, errhp, (text *)dbname,
(sb4) strlen((char *)dbname), 0));
/* set attribute server context in the service context */
(void) OCIAttrSet( (dvoid *) svchp, OCI_HTYPE_SVCCTX, (dvoid *)srvhp,
(ub4) 0, OCI_ATTR_SERVER, (OCIError *) errhp);
(void) OCIHandleAlloc((dvoid *) envhp, (dvoid **)&authp,
(ub4) OCI_HTYPE_SESSION, (size_t) 0, (dvoid **) 0);
(void) OCIAttrSet((dvoid *) authp, (ub4) OCI_HTYPE_SESSION,
(dvoid *) username, (ub4) strlen((char *)username),
(ub4) OCI_ATTR_USERNAME, errhp);
(void) OCIAttrSet((dvoid *) authp, (ub4) OCI_HTYPE_SESSION,
(dvoid *) password, (ub4) strlen((char *)password),
(ub4) OCI_ATTR_PASSWORD, errhp);
checkerr(errhp, OCISessionBegin ( svchp, errhp, authp, OCI_CRED_RDBMS,
(ub4) OCI_DEFAULT));
(void) OCIAttrSet((dvoid *) svchp, (ub4) OCI_HTYPE_SVCCTX,
(dvoid *) authp, (ub4) 0,
(ub4) OCI_ATTR_SESSION, errhp);
logged_on = TRUE;
checkerr(errhp, OCIHandleAlloc( (dvoid *) envhp, (dvoid **) &stmthp,
OCI_HTYPE_STMT, (size_t) 0, (dvoid **) 0));
checkerr(errhp, OCIHandleAlloc( (dvoid *) envhp, (dvoid **) &stmthp1,
OCI_HTYPE_STMT, (size_t) 0, (dvoid **) 0));
/* Retrieve the current maximum employee number. */
checkerr(errhp, OCIStmtPrepare(stmthp, errhp, maxemp,
(ub4) strlen((char *) maxemp),
(ub4) OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT));
/* bind the input variable */
checkerr(errhp, OCIDefineByPos(stmthp, &defnp, errhp, 1, (dvoid *) &empno,
(sword) sizeof(sword), SQLT_INT, (dvoid *) 0, (ub2 *)0,
(ub2 *)0, OCI_DEFAULT));
/* execute and fetch */
if (status = OCIStmtExecute(svchp, stmthp, errhp, (ub4) 1, (ub4) 0,
(CONST OCISnapshot *) NULL, (OCISnapshot *) NULL, OCI_DEFAULT))
{
if (status == OCI_NO_DATA)
empno = 10;
else
{
checkerr(errhp, status);
finish_demo(svchp, srvhp, authp,stmthp, stmthp1,i
没有合适的资源?快使用搜索试试~ 我知道了~
windowx64 oracle12.2.0.1.0 命令行工具集
共149个文件
h:30个
sym:22个
htm:18个
需积分: 0 1 下载量 108 浏览量
2024-03-05
12:15:40
上传
评论
收藏 78.07MB ZIP 举报
温馨提示
包含sqlplus、exp、imp、wrc、sqlldr和SDK Package、JDBC Supplement Package、ODBC Package。 SQL*Plus: SQL*Plus 是 Oracle 提供的命令行界面工具,用于与 Oracle 数据库进行交互、执行 SQL 查询、PL/SQL 代码和管理数据库对象。 exp 和 imp: exp 和 imp 是 Oracle 提供的导出和导入工具,用于在 Oracle 数据库之间导出和导入数据、表、索引、视图等数据库对象。 wrc: wrc 是 Oracle 的 Workload Replay Capture 工具,用于捕获生产环境的工作负载,并将其用于性能测试和分析。 sqlldr: sqlldr 是 Oracle 的 SQL*Loader 工具,用于将外部数据加载到 Oracle 数据库中。它允许你从文本文件、CSV 文件等格式加载数据。
资源推荐
资源详情
资源评论
收起资源包目录
windowx64 oracle12.2.0.1.0 命令行工具集 (149个子文件)
BASIC_README 512B
make.bat 2KB
bcmake.bat 1012B
ott.bat 358B
cdemo81.c 18KB
occidml.cpp 8KB
occiobj.cpp 5KB
blafdoc.css 6KB
blafdoc.css 6KB
oraociei12.dll 186.25MB
orannzsbb12.dll 4.49MB
orasqlplusic12.dll 1.56MB
oraocci12d.dll 1.25MB
oraocci12.dll 1.08MB
oraocci12d.dll 1.02MB
oraocci12.dll 1002KB
oci.dll 761KB
sqora32.dll 741KB
ociw32.dll 552KB
orasql12.dll 289KB
oraons.dll 247KB
sqoras32.dll 188KB
ocijdbc12.dll 149KB
oramysql12.dll 70KB
sqresus.dll 19KB
sqresja.dll 18KB
heteroxa12.dll 13KB
sqlldr.exe 1.45MB
sqlplus.exe 1.02MB
exp.exe 604KB
imp.exe 303KB
impdp.exe 204KB
expdp.exe 196KB
odbc_install.exe 101KB
odbc_uninstall.exe 97KB
genezi.exe 55KB
uidrvci.exe 20KB
adrci.exe 20KB
wrc.exe 19KB
setup_app.gif 26KB
setup_app.gif 26KB
setup_ssmig.gif 19KB
setup_ssmig.gif 19KB
odbcdrvarch.gif 17KB
odbcdrvarch.gif 17KB
setup_work.gif 14KB
setup_work.gif 14KB
setup_ora.gif 13KB
setup_ora.gif 13KB
odbcmodel.gif 13KB
odbcmodel.gif 13KB
oracle.gif 2KB
oracle.gif 2KB
ociap.h 439KB
oci.h 194KB
orl.h 158KB
ort.h 124KB
ocixstream.h 111KB
ori.h 102KB
nzt.h 79KB
occiControl.h 73KB
ldap.h 45KB
ocidef.h 43KB
oro.h 43KB
occiData.h 40KB
nzerror.h 37KB
occiCommon.h 36KB
odci.h 32KB
occiObjects.h 25KB
orid.h 15KB
ocidfn.h 12KB
occiAQ.h 12KB
oci8dp.h 10KB
xa.h 10KB
ociextp.h 9KB
ocixmldb.h 8KB
ocixml.h 8KB
oratypes.h 7KB
oci1.h 7KB
ocikpr.h 7KB
ociapr.h 6KB
ocidem.h 4KB
occi.h 2KB
sqora.htm 201KB
sqora.htm 179KB
toc.htm 9KB
toc.htm 9KB
cpyr.htm 7KB
cpyr.htm 6KB
odbcdrvarch.htm 3KB
odbcdrvarch.htm 3KB
odbcmodel.htm 1KB
odbcmodel.htm 1KB
setup_app.htm 1KB
setup_work.htm 1KB
setup_ssmig.htm 1KB
setup_ssmig.htm 1KB
setup_work.htm 1KB
setup_ora.htm 1KB
setup_app.htm 1KB
共 149 条
- 1
- 2
资源评论
(; ̄ェ ̄)。
- 粉丝: 49
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功