I'm new to Teradata and trying to write simple program using CLIv2 (Teradata version 12). Using the sample cli code provided by Teradata I could able to connect and execute the statements like CREATE TABLE, INSERT INTO.. But when I want to fetch the result set of a query SELECT * from SAMPLES.table1 I'm facing problem in coding. I dont know how to get the records from the query. Could any one help me in coding this. According to me after executing the query using DBCHCL(&result,cnta,&dbcarea), the result will be stored in dbcarea.fet_data_ptr; I dont know for which structure I have to type cast this, and also do I need to take care of the Data Types returned by the result set. In the Teradata sample program, it is reading character by character and storing in a file. I want to how to read a Database column. I sample example for fetching the records will be very helpful me.
It is best to post this to the Teradata Developer Exchange as that is the forum going forward; this forum will be discontinued, and may therefore not be monitored by very many people.
Having said all of that, I will add the following (but would rather continue the discussion on the Developer Exchange):
You need to call DBCHCL with function DBFFET. That will fetch the parcels. The first parcel should be success. The next parcel should be a record parcel, depending on your CLI settings (if you are in parcel mode). In the record parcel, that is one row/record of data. If you want to extract out a column, you will need to know the exact layout of the record so that you can parse down to find the column you want. If you want to just write the entire record to a file, just memcpy from dbcptr->fet_data_ptr to wherever you want the data to go.