procedure get_R0BrdLib(
batch_size in integer,
found in out integer,
done_fetch out integer,
BoardType1 out numArrayType,/*单板类型Board Type*/
BoardName1 out charArrayType/*各子单元类型包含的子单元个数Sunit Number Per Type*/) is
begin
if not CUR_R0BrdLib%isopen then
open CUR_R0BrdLib;
end if;
done_fetch := 0;
found := 0;
for i in 1..batch_size loop
fetch CUR_R0BrdLib
into BoardType1(i),BoardName1(i);
if CUR_R0BrdLib%notfound then
close CUR_R0BrdLib;
done_fetch := 1;
exit;
else
found := found + 1;
end if;
end loop;
end get_R0BrdLib;
end testEptTbl;
/
show err
1.3.2 游标方式:
//倒出数据到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,%22OS time:\t\t\t%s\n%22, 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,%22b01c01%22);
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,%22b01c01%22);
文章来源于领测软件测试网 https://www.ltesting.net/