Period Datatype Example Using Descriptor - Teradata Preprocessor2

Teradata® Preprocessor2 for Embedded SQL Programmer Guide - 20.00

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
Lake
VMware
Product
Teradata Preprocessor2
Release Number
20.00
Published
October 2023
ft:locale
en-US
ft:lastEdition
2023-11-20
dita:mapPath
nyr1691484085721.ditamap
dita:ditavalPath
obe1474387269547.ditaval
dita:id
xfi1470440464166
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. For details, see Period Datatypes. 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;

			      ...