//倒出数据到zdb
void CBOARDT::WriteZdb(int SubNetID,int NodeBID)
{
EXEC SQL BEGIN DECLARE SECTION;
int iSubNetID = SubNetID;
int iNodeBID = NodeBID;
EXEC SQL END DECLARE SECTION;
char tmpbuf[128],StartTime[256],EndTime[256];
/* Set time zone from TZ environment variable. If TZ is not set,
* the operating system is queried to obtain the default value
* for the variable.
*/
_tzset();
/* Display operating system-style date and time. */
_strtime( tmpbuf );
sprintf( StartTime,"OS time:\t\t\t%s\n", tmpbuf );
/* Declare a cursor for the FETCH. */
EXEC SQL DECLARE CUR_R_BOARDT CURSOR FOR
SELECT byBoardType, abyBoardName FROM TB_BOARDT;
EXEC SQL OPEN CUR_R_BOARDT;
/* Initialize the number of rows. */
num_ret = 0;
int rows_ret=BATCHSIZE;
while (BATCHSIZE == rows_ret)
{
// Fetch from the Cursor, catching all ORA ERROR condition
EXEC SQL WHENEVER SQLERROR DO sqlerror(m_dbheader);
EXEC SQL FETCH CUR_R_BOARDT INTO
:bHostVar1,:chHostVar1;
/* Write however many rows were returned. */
rows_ret=sqlca.sqlerrd[2] - num_ret;
WriteBatchToZdb(rows_ret,"b01c01");
num_ret = sqlca.sqlerrd[2]; /* Reset the number. */
}
/* Write remaining rows from last fetch, if any. */
if ((sqlca.sqlerrd[2] - num_ret) > 0)
WriteBatchToZdb(sqlca.sqlerrd[2] - num_ret,"b01c01");
m_dbheader.dbTupleNum=sqlca.sqlerrd[2];
EXEC SQL CLOSE CUR_R_BOARDT;
_strtime(tmpbuf);
sprintf(EndTime,"OS time:\t\t\t\t%s\n", tmpbuf );
printf("begin time: %s\n",StartTime);
printf("end time: %s\n",EndTime);
WriteZdbHeader();
}
1.3.3 存储过程方式: