Go to the source code of this file.
This file contains two macros, PR_SUBMIT_DATE_QUERY and SELECT_AUDIT_TRAIL. These macros define the SQL that is needed when fetching the audit trail information from the database.
PR_SUBMIT_DATE_QUERY is used to get the submittion information.
SELECT_AUDIT_TRAIL is used to get the rest of the audit trail.
Typical code that fetches and prints out the audit trail will look like this (C compilers hate embedded C-style comments, so I put C++ style comments in the code example):
// For this code snippet, the following variables are defined
// and setup:
// sql_buffer : already allocated GString* (see glib)
// pr_pk : primary key of problem report
// conn : pointer to database connection (see libpq)
// res : result pointer to store our results (see libpq)
// First, get the submittion information for the problem report.
// This information consists of who submitted it, and when. The
// query should only return on row (if it ever returns more, there
// is serious trouble).
g_string_sprintf (sql_buffer, PR_SUBMIT_DATE_QUERY, pr_pk);
res = PQexec (conn, sql_buffer->str);
fprintf (out_file, "%s\n", PQgetvalue (res, 0, 0));
PQclear (res);
// After this, get the rest of the audit trail information. This
// query may return more than one row, so we need to loop through
// the results to get them all.
g_string_sprintf (sql_buffer, SELECT_AUDIT_TRAIL, pr_pk, pr_pk);
res = PQexec (conn, sql_buffer->str);
num = PQntuples (res);
for (i = 0; i < num; i++)
{
fprintf (out_file, "%s\n", PQgetvalue (res, i, 0));
}
1.2.14 written by Dimitri van Heesch,
© 1997-2002