The wide_compute.c example program demonstrates processing compute results with wide tables and larger column sizes, implemented in Open Client and Open Server version 12.5. First, it sends a canned query to the server using a language command. It processes the results using the standard ct_results while loop. It binds the column values to program variables. Then, it fetches and displays the rows in the standard ct_fetch while loop.
This is the canned query:
select type, price from titles where type like "%cook" order by type, price compute sum(price) by type compute sum(price)
This query returns both regular rows and compute rows. The compute rows are generated by the two compute clauses:
The first compute clause generates a compute row each time the value of type changes:
compute sum(price) by type
The second compute clause generates one compute row, which is the last to be returned:
compute sum(price)
For more information about this sample program, see the leading comments in the sample source file.
This sample requires the pubs2 database.