--- -- 在装Oracle客户端的机器上也可以使用sqlldr,要找到这个命令 /home/oracle/oracle/app/oracle/product/11.1.0/db_1/bin> ./sqlldr test/test@102_db control=load.ctl data=in.txt SQL*Loader: Release 11.1.0.6.0 - Production on Tue Oct 26 15:38:02 2010 Copyright (c) 1982, 2007, Oracle. All rights reserved. Commit point reached - logical record count 5 ---- 多线程调用时,若主进程退出,会对线程产生影响 --- 10-26 vi命令的使用,可以提高效率 ]]光标移到文件末尾 [[光标移到文件开始 $ 光标跳到行尾 o O 新增加行进行插入 R 替换多个字符 -- 多线程练习 #include <iostream.h> #include <pthread.h> #include <unistd.h> void* fun(void* i) { cout << "i = " << i <<" " << *(int*)i << endl; return (void *)0; } int main() { for(int i = 0; i < 5; i++) { pthread_t id; sleep(1); pthread_create(&id, NULL, fun, &i); } sleep(3); cout << "main pro is over : " << endl; return 0; } 注意其中的sleep(1); 主线程会一直循环,改变i的值 -- 在流的使用中,注意open 和 close 必须要配对出现,不然会出现问题 ------- 10-28 获取目录下的文件列表 类似 ls #include <sys/types.h> #include <dirent.h> #include <unistd.h> int main() { DIR * dir; struct dirent * ptr; int i; dir = opendir("/root/test/test"); //有必要对操作结果进行检查 if(dir == NULL) { return -1; } while((ptr = readdir(dir)) != NULL) { printf("d_name: |%s|/n", ptr->d_name); } closedir(dir); return 0; } --- 通过改变指针的指向,不能使用数组 char* szName; // get the field name //cout the field name 2010-10-12 but it cannot work well //This is so suck that using char arrary is wrong // OCIAttrGet((dvoid*)mypard, OCI_DTYPE_PARAM, (text**)&fname, &sizep, OCI_ATTR_NAME, pConn->myerrhp); // use the char pointer szName can work well, why ? 2010-10-28 OCIAttrGet((dvoid*)mypard, OCI_DTYPE_PARAM, (text **)&szName, &sizep, OCI_ATTR_NAME, pConn- >myerrhp); strncpy(fname, szName, sizep); -- 10-30 测试绑定插入数据 int id[2]={3,2}; char name[88] = "test"; sb2 nu[2] = {0,0}; sb2* pp= nu; OCIBind *bnd1p = (OCIBind *) 0; /* the first bind handle */ OCIBind *bnd2p = (OCIBind *) 0; /* the second bind handle */ char * ins = "insert into student (id, name) values (:ID, :NAME)"; OCIStmtPrepare(conn.mystmthp, conn.myerrhp, (const unsigned char * )ins, (ub4) strlen((char *) ins), (ub4) OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT); OCIBindByName(conn.mystmthp, &bnd1p, conn.myerrhp, (text *) ":id", -1, (dvoid *) id, (sword) sizeof(int) , SQLT_INT, (dvoid *) pp, (ub2 *) 0, (ub2 *) 0, (ub4) 2, (ub4 *) 0, OCI_DEFAULT); OCIBindByName(conn.mystmthp, &bnd2p, conn.myerrhp, (text *) ":NAME", -1, (dvoid *) name, 32 , SQLT_STR, (dvoid *) pp, (ub2 *) 0, (ub2 *) 0, (ub4) 2, (ub4 *) 0, OCI_DEFAULT); id[0]=1;id[1]=2; OCIStmtExecute(conn.mysvchp, conn.mystmthp, conn.myerrhp, 2, 0, NULL, NULL, OCI_DEFAULT); --- 11-1 OCIStmtExecute(conn.mysvchp, conn.mystmthp, conn.myerrhp, 2, 0, NULL, NULL, OCI_DEFAULT); 调整第4个参数的值来进行多行操作,如插入多行数据 --- 11-2 可以通过信号捕获来操作进行,如处理退出信号,使程序不退出 -- 11-3 rename 函数 相当于mv命令 remove rm 一个signal例子,处理ctrl+c 信号 #include <signal.h> #include <stdio.h> #include <unistd.h> void ouch(int sig) { printf("ouch! I got the signal %d/n", sig); (void)signal(SIGINT, SIG_DFL); } int main() { (void) signal(SIGINT, ouch); while(1) { printf("hello world/n"); sleep(1); } return 0; }