89楼的那个回调函数,绑定变量操作,不过是一堆switch....case..
效率不会太低吧!
static int bind_proc(void *content) //bind处理
{
register struct bindnod *bp;
T_PkgType *tp;
char *p,*bindp;
int ret,n;
short nf;
bp=(struct bindnod *)content;
p=*bp->tail;
tp=bp->tp;
bindp=*(bp->rec)+tp->offset;//要绑定的位置
//bind NULL
nf=isnull(bindp,tp->type)?-1:0;
if(1&bp->flg) bp->flg=!(nf ^ bp->ind); //如果NULL状态有变化,清空免bind标志
bp->ind=nf;
ret=0;
if(!(1&bp->flg)) {
//ShowLog(5,"bind_proc sth=%d,%s:%d",*bp->sth,tp->name,bp->bindnum);
switch(tp->type) {
#ifdef SDBC_PTR_63+1
case CH_INT63+1:
#endif
case CH_LONG:
case CH_TINY:
case CH_SHORT:
case CH_INT:
ret=sqlo_bind_by_pos(*bp->sth, bp->bindnum, SQLOT_INT, bindp, tp->len, &bp->ind, 0);
bp->flg=1; //下次免bind
break;
case CH_FLOAT:
case CH_DOUBLE:
ret=sqlo_bind_by_pos(*bp->sth, bp->bindnum, SQLOT_FLT, bindp, tp->len, &bp->ind, 0);
bp->flg=1; //下次免bind
break;
case CH_BYTE:
ret=sqlo_bind_by_pos(*bp->sth, bp->bindnum, SQLOT_BIN, bindp, tp->len, &bp->ind, 0);
bp->flg=1; //下次免bind
break;
case CH_CHAR:
case CH_CNUM:
case CH_DATE:
ret=sqlo_bind_by_pos(*bp->sth, bp->bindnum, SQLOT_STR, bindp, tp->len, &bp->ind, 0);
bp->flg=1; //下次免bind
break;
default: //类型与ORACLE不符,需变换
bindp=p;
if(tp->bindtype & RETURNING) { //bind RETURNING
n=40;
*bindp=0;
p=bindp+n; //CH_JUL...CH_USEC,.....
bp->flg=2;
} else {
p+=get_one_str(p,*bp->rec,tp,0);
n=strlen(bindp)+1;
if(n<40) n=40;
bp->flg=0;
}
ret=0;
if(bindp != bp->last_bindp) {
ret=sqlo_bind_by_pos(*bp->sth, bp->bindnum, SQLOT_STR, bindp,n,&bp->ind, 0);
bp->last_bindp=bindp;
}
*(++p)=0;
break;
}
}
*bp->tail=p;
return 0;
}
【 在 ylh1969 的大作中提到: 】
: 再来看看DAU_insert是干啥的:
: 经过环境检查后,调用:
: int bind_ins(register DAU *DP,char *buf)
: ...................
--
修改:ylh1969 FROM 221.221.52.*
FROM 221.221.52.*