Period Datatype Example Using Descriptor - Preprocessor2 for Embedded SQL

Teradata Preprocessor2 for Embedded SQL Programmer Guide

Product
Preprocessor2 for Embedded SQL
Release Number
15.10
Language
English (United States)
Last Update
2018-10-07
dita:id
B035-2446
lifecycle
previous
Product Category
Teradata Tools and Utilities

A period datatype is a datatype with two values that represent the start and end of a duration of time. See “Period Datatypes” on page 31 for details. The next example shows using a period datatype with DELETE WITH DESCRIPTOR.

#define NUMVARS 1
struct 	{
		SQLInt32 Date1;
		SQLInt32 Date2;
}PeriodDate;

 

PeriodDate.Date1 = 1050213;						 																																																								 														 						 						 						 						 						 						 						 						 						 						 						 						 						 						/*February 13th, 2005*/
PeriodDate.Date2 = 1060213; 																																									 						 						 						 						 						 						 						 						 						 						 						 						 						 						 											/*February 13th, 2006*/

 

SQLDA.SqlDABC = (16 + (44 * NUMVARS)); 								 						 						 						 						 						 						 						 						 						 						 						/*data area byte count*/
SQLDA.SqlN = NUMVARS; 											 						 						 						 						 						 						 						 						 						 						 						 						 						 						 																									/*Number of variables*/
SQLDA.SqlD = NUMVARS;			 																																																																																																													 						 						 						 						 						 						 						 						 						 						 						 						 						 						 						/*Number of variables*/
SQLDA.SqlVAR[0].SqlTYPE = 832;		 									 						 						 						 						 						 						 						 						 						 						 						 						 						 						 																																																						/*Datatype for PERIOD(DATE)*/
SQLDA.SqlVAR[0].SqlLEN = 8*256;		 																																																																		 						 						 						 						 						 						 						 						 						 						 						 						 						 						 												/*variable length*/
SQLDA.SqlVAR[0].SqlDATA = (char *) (&PeriodDate); /*variable address*/
SQLDA.SqlVAR[0].SqlIND = 0;			 																																																					 						 						 						 						 						 						 						 						 						 						 						 						 						 						 						/*not using indicator*/ 

 

VARCHAR SQL_STATEMENT[36];
strcpy (SQL_STATEMENT.arr, "DELETE FROM tab01 where PeriodD = ?");
SQL_STATEMENT.len = strlen (SQL_STATEMENT.arr);

 

EXEC SQL
		PREPARE DELSTMT FROM :SQL_STATEMENT;

 

EXEC SQL
		EXECUTE DELSTMT USING DESCRIPTOR SQLDA;