PROC 动态游标的使用


下面是使用动态游标查询出id号为356对应的name,首先表里面是存在的对应值,但是打印出来的namee是空值 这是为什么啊 请大虾们帮忙看看哪写的不正确!编译时能过的

EXEC SQL INCLUDE sqlca;
#include <stdio.h>

int main( int argc, char *argv[] )
{
EXEC SQL BEGIN DECLARE SECTION;
char namee[ 5 + 1 ];
char str[] = "SELECT name FROM oci_table WHERE id = ?";
char *user = "lbt/lbt@orcl";
int num=356;
EXEC SQL END DECLARE SECTION;

EXEC SQL CONNECT :user;
memset( namee, 0x00, sizeof( namee ) );
EXEC SQL PREPARE AA FROM :str;
EXEC SQL DECLARE BB CURSOR FOR AA;
EXEC SQL OPEN BB USING :num;
EXEC SQL FETCH BB INTO :namee;
printf("name=%s\n", namee);
EXEC SQL CLOSE BB;
EXEC SQL COMMIT WORK RELEASE;
return 0;
}

c Linux

咆哮的柠檬 11 years, 4 months ago

Your Answer