|
|
void Ns_PdSendRowInfo(Ns_PdRowInfo * rowInfo);
This function sends a row encapsulated in an Ns_PdRowInfo structure to the client.
/* Things italicized would be your DBMS-specific structures and
calls. */
/* defined in nspd.h */
typedef struct Ns_PdRowData {
int elSize;
char *elData;
} Ns_PdRowData;
typedef struct Ns_PdRowInfo {
int numColumns;
Ns_PdRowData *rowData;
};
void
DBMSFunction (void) { /* similiar to Ns_PdDbGetTableInfo */
Ns_PdRowInfo *getRowInfo, *bindRowInfo;
/* Exec SQL and "select" data from a table */
/* ... */
if ((bindRowInfo = DBMSBindRow(state)) != NULL) {
getRowInfo =
Ns_PdNewRowInfo(Ns_PdGetRowInfoNumColumns(bindRowInfo));
if (getRowInfo != NULL) {
status = NS_OK;
Ns_PdSendString(OK_STATUS);
Ns_PdSendRowInfo(bindRowInfo); /* sends list of
column names */
while ((getRowRet = DBMSGetRow(handle,
getRowInfo)) == NS_OK) {
/* send row info */
Ns_PdSendRowInfo(getRowInfo);
}
Ns_PdSendData(END_DATA, strlen(END_DATA)); /* NULL
row terminates rows */
if (getRowRet == DB_END_DATA) {
status = NS_OK;
} else {
Ns_PdLog(Error, "GetTableInfo: incomplete data sent
to client.");
}
/* free the getRowInfo structure when done */
Ns_PdFreeRowInfo(getRowInfo, 0);
}
/* free the bindRowInfo data and structure when done */
Ns_PdFreeRowInfo(bindRowInfo, 1);
}
}