📄 dbpub.c
字号:
static char sqla_program_id[162] =
{
0,42,68,65,75,65,73,65,68,66,80,85,66,32,32,32,52,65,121,115,
76,68,74,89,48,49,49,49,49,32,50,32,0,8,69,66,67,83,32,32,
32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0
};
#include "sqladef.h"
static struct sqla_runtime_info sqla_rtinfo =
{{'S','Q','L','A','R','T','I','N'}, sizeof(wchar_t), 0, {' ',' ',' ',' '}};
static const short sqlIsLiteral = SQL_IS_LITERAL;
static const short sqlIsInputHvar = SQL_IS_INPUT_HVAR;
#line 1 "dbpub.sqc"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <sql.h>
#include <sqlenv.h>
#include <sqlda.h>
#include <sqlca.h>
#include <sqlutil.h>
#include <db2ApiDf.h>
#include <string.h>
#include <ctype.h>
#include "public.h"
void SqlInfoGet(char *Msg, struct sqlca *pSqlca)
{
char sqlInfo[1024];
char sqlstateMsg[1024];
char errorMsg[1024];
int rc = 0;
strcpy(Msg, "");
if (pSqlca->sqlcode != 0 && pSqlca->sqlcode != 100)
{
if (pSqlca->sqlcode != 0)
{
sprintf(sqlInfo, "error report");
}
else
{
sprintf(sqlInfo, "warning report");
}
/* get error message */
rc = sqlaintp(errorMsg, 1024, 80, pSqlca);
if (rc > 0) /* return code is the length of the errorMsg string */
{
strcat(sqlInfo, errorMsg);
}
/* get SQLSTATE message */
rc = sqlogstt(sqlstateMsg, 1024, 80, pSqlca->sqlstate);
if (rc > 0)
{
strcat(sqlInfo, sqlstateMsg);
}
strcpy(Msg, sqlInfo);
}
}
int runsql(char *errorMsg, const char * p_lpszFormat, ... )
{
struct sqlca sqlca;
va_list args;
char lpszFString[1024];
va_start( args, p_lpszFormat );
vsprintf( lpszFString, p_lpszFormat, args );
va_end( args );
debugLog(__FILE__,__LINE__, "run sql: ", lpszFString);
/*
EXEC SQL EXECUTE IMMEDIATE :lpszFString;
*/
{
#line 65 "dbpub.sqc"
sqlastrt(sqla_program_id, &sqla_rtinfo, &sqlca);
#line 65 "dbpub.sqc"
sqlastls(0,lpszFString,0L);
#line 65 "dbpub.sqc"
sqlacall((unsigned short)23,1,0,0,0L);
#line 65 "dbpub.sqc"
sqlastop(0L);
}
#line 65 "dbpub.sqc"
if (sqlca.sqlcode != 0)
{
SqlInfoGet(errorMsg, &sqlca);
sprintf(errorMsg, "run sql false SQLCODE = [%-d]%s\n", sqlca.sqlcode, errorMsg);
debugLog(__FILE__,__LINE__, errorMsg);
/*
EXEC SQL ROLLBACK;
*/
{
#line 71 "dbpub.sqc"
sqlastrt(sqla_program_id, &sqla_rtinfo, &sqlca);
#line 71 "dbpub.sqc"
sqlacall((unsigned short)28,0,0,0,0L);
#line 71 "dbpub.sqc"
sqlastop(0L);
}
#line 71 "dbpub.sqc"
return sqlca.sqlcode;
}
else
{
/*
EXEC SQL COMMIT;
*/
{
#line 76 "dbpub.sqc"
sqlastrt(sqla_program_id, &sqla_rtinfo, &sqlca);
#line 76 "dbpub.sqc"
sqlacall((unsigned short)21,0,0,0,0L);
#line 76 "dbpub.sqc"
sqlastop(0L);
}
#line 76 "dbpub.sqc"
if (sqlca.sqlcode != 0)
{
SqlInfoGet(errorMsg, &sqlca);
sprintf(errorMsg, "run sql commit false SQLCODE = [%-d]%s\n", sqlca.sqlcode, errorMsg);
debugLog(__FILE__,__LINE__, errorMsg);
return sqlca.sqlcode;
}
return 0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -