21.02.2013 Views

System i: Programming i5/OS PASE - IBM

System i: Programming i5/OS PASE - IBM

System i: Programming i5/OS PASE - IBM

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

SQLRETURN fun_Process()<br />

{<br />

static<br />

char*pszId = "fun_Process()";<br />

charcLastName[ 80 ];<br />

nml_ReturnCode = SQLAllocStmt( nml_HandleToDatabaseConnection,<br />

&nml_HandleToSqlStatement );<br />

if ( nml_ReturnCode != SQL_SUCCESS ) {<br />

printf( "%s: SQLAllocStmt() failed\n", pszId );<br />

fun_PrintError( SQL_NULL_HSTMT );<br />

printf( "%s: Terminating\n", pszId );<br />

return SQL_ERROR;<br />

} else {<br />

printf( "%s: SQLAllocStmt() succeeded\n", pszId );<br />

} /* endif */<br />

strcpy( chs_SqlStatement01, "select LSTNAM, STATE " );<br />

strcat( chs_SqlStatement01, "from QIWS.QCUSTCDT " );<br />

strcat( chs_SqlStatement01, "where " );<br />

strcat( chs_SqlStatement01, "STATE =?");<br />

nml_ReturnCode = SQLPrepare( nml_HandleToSqlStatement,<br />

chs_SqlStatement01,<br />

SQL_NTS );<br />

if ( nml_ReturnCode != SQL_SUCCESS ) {<br />

printf( "%s: SQLPrepare() failed\n", pszId );<br />

fun_PrintError( nml_HandleToSqlStatement );<br />

nml_ReturnCode = fun_ReleaseStmHandle();<br />

printf( "%s: Terminating\n", pszId );<br />

return SQL_ERROR;<br />

} else {<br />

printf( "%s: SQLPrepare() succeeded\n", pszId );<br />

} /* endif */<br />

Nmi_vParam = SQL_TRUE;<br />

nml_ReturnCode = SQLSetStmtOption( nml_HandleToSqlStatement,<br />

SQL_ATTR_CURSOR_SCROLLABLE,<br />

( SQLINTEGER * ) &Nmi_vParam );<br />

if ( nml_ReturnCode != SQL_SUCCESS ) {<br />

printf( "%s: SQLSetStmtOption() failed\n", pszId );<br />

fun_PrintError( nml_HandleToSqlStatement );<br />

nml_ReturnCode = fun_ReleaseStmHandle();<br />

printf( "%s: Terminating\n", pszId );<br />

return SQL_ERROR;<br />

} else {<br />

printf( "%s: SQLSetStmtOption() succeeded\n", pszId );<br />

} /* endif */<br />

Nmi_vParam = SQL_TRUE;<br />

nml_ReturnCode = SQLSetStmtOption( nml_HandleToSqlStatement,<br />

SQL_ATTR_FOR_FETCH_ONLY,<br />

( SQLINTEGER * ) &Nmi_vParam );<br />

if ( nml_ReturnCode != SQL_SUCCESS ) {<br />

printf( "%s: SQLSetStmtOption() failed\n", pszId );<br />

fun_PrintError( nml_HandleToSqlStatement );<br />

nml_ReturnCode = fun_ReleaseStmHandle();<br />

printf( "%s: Terminating\n", pszId );<br />

return SQL_ERROR;<br />

} else {<br />

printf( "%s: SQLSetStmtOption() succeeded\n", pszId );<br />

} /* endif */<br />

nmi_PcbValue = 0;<br />

nml_ReturnCode = SQLBindParam( nml_HandleToSqlStatement,<br />

1,<br />

<strong>i5</strong>/<strong>OS</strong> <strong>PASE</strong> 45

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!