TPT API C program usage

Tools & Utilities
Enthusiast

TPT API C program usage

Hi,

Found this piece of code

#include "connection.h"

#include "schema.h"

#include "DMLGroup.h"

using namespace teradata::client::API;

int returnValue = 0;

char* errorMsg = NULL;

TD_ErrorType errorType;

cout << "*** Export Driver Example ***" << endl;

Connection *conn = new Connection();

/**********************************************

* Set Operator Type and Trace/Log Levels

**********************************************/

conn->AddAttribute(TD_SYSTEM_OPERATOR,TD_EXPORT);

//conn->AddAttribute(TD_TRACE_OUTPUT,"export.txt");

//conn->AddArrayAttribute(TD_TRACE_LEVEL,2,TD_OPER_ALL,TD_OFF,NULL);

/**********************************************

* Add Attributes

**********************************************/

conn->AddAttribute(TD_USER_NAME,"user");

conn->AddAttribute(TD_USER_PASSWORD,"password");

conn->AddAttribute(TD_SELECT_STMT,"sel Associate_Name from tdload;");

conn->AddAttribute(TD_TARGET_TABLE,"tdload");

conn->AddAttribute(TD_TDP_ID,"database");

/**********************************************

* Add Schema

**********************************************/

Schema * schema = new Schema("output");

schema->AddColumn("Associate_Name",TD_CHAR,25);

conn->AddSchema(schema);

/**********************************************

* Initiate

**********************************************/

returnValue = conn->Initiate();

cout << "Driver Initiated with status " << returnValue << endl;

if ( returnValue < TD_Error )

{

/**********************************************

* Acquisition

**********************************************/

int count = 0;

char* data;

TD_Length dataLen = 0;

int exportStatus = 0;

while( exportStatus != -1){

returnValue = conn->GetRow(&data, &dataLen);

----------------------------------------------------------------------------

1.Is it possible to export the table data without specifying the column names unlike highlighted above (AddColumn)?

2.Is it possible to get complete set of table data instead of row by row as highlighted above (option GetRow)?

12 REPLIES
Teradata Employee

Re: TPT API C program usage

1. No. You need to provide the column names.

2. You can either retrieve a row at a time from the Export operator, or you can call GetBuffer to get a 64K buffer of rows. Repeated calls to GetRow or GetBuffer will allow your application to retrieve all of the rows from the result set.

-- SteveF
Enthusiast

Re: TPT API C program usage

Thanks Steve.

1.Is there any alternative so that we can skip the column names? (as its a tedious process to add all column names and we are trying to export 5000 tables and each having 50 or odd columns)

2.We are working for better performance in exporting data from Teradata db. Is the C program faster to fetch data than TPT script?

Teradata Employee

Re: TPT API C program usage

1. As I indicated above, the column names need to be provided.

2. We have not performed any performance characterizations to compare performance between a TPTAPI application and script-based TPT. Mostly because the performance of the TPTAPI application would be up to the application. And every application is different. We provide sample applications. But our ETL vendor partners also have their own applications that use TPTAPI and I imagine those ETL tools are more complex than our sample application and thus would most likely have different performance. But then on the other side, the user has to write the C++ application and maintain it.

-- SteveF
Teradata Employee

Re: TPT API C program usage

TPT EXPORT is going to be better performance than a coded solution not using the export operator capability.

Generally performance of export is gated by client CPU, client write target(eg single disk) or network performance. If you are using export, those would be the first places to look for a bottleneck.

Teradata Employee

Re: TPT API C program usage

I could be wrong, but I think he wanted to know the performance difference between a TPT-script job using the Export operator versus a TPTAPI job using the Export operator.

Script-based TPT has a lot of overhead, but then again we manage the multiple instances for the user.

A hand-coded C application might have less overhead, but the user would be responsible for a lot more of the work we already provide, but maybe better performance (less lines of code being executed).

-- SteveF
Enthusiast

Re: TPT API C program usage

Thanks Steve and Todd.

We are currently exporting using Script-Based TPT which is making IO operations, hence performance is reduced.

Hence we are trying to establish TPT-API connection and send to buffers instead of files(Similar to ETL tool just for extracting data).

@Steve/Todd - As mentioned, Is TPT EXPORT a tool for better performance?

Enthusiast

Re: TPT API C program usage

@Steve - can i use * or something like that to indicate all column names? (Since different tables with different columns and updating column names in a TPT-API code will be a tedious process :( )

Teradata Employee

Re: TPT API C program usage

I am reminded by the developer that the TPTAPI Export operator does not need a list of columns (a schema).

The Export operator has a "dynamic schema" feature in which the operator will obtain the schema from the SELECT statement, and provide it back to the application in the Connection object.

-- SteveF
Enthusiast

Re: TPT API C program usage

Thanks Steve :)

As mentioned by Todd, Is TPT EXPORT a tool for better performance?