Example - OLE DB Provider for Teradata

OLE DB Provider for Teradata User Guide

Product
OLE DB Provider for Teradata
Release Number
15.00
Language
English (United States)
Last Update
2018-09-28
dita:id
B035-2498
Product Category
Teradata Tools and Utilities

Example

Assume the rowset is:

 

Table 19: Rowset (ServiceHistory Table)

CustomerNo

(Integer

CarMaker

(CHAR(20))

CarModel

(CHAR(20))

DateLastServiced

(DATE)

TimeLastService

(INTEGER FORMAT 99:99:99)

0001

Ford

Expedition

10/20/2001

10:10:45

0002

Chevrolet

Corvette

12/01/2001

09:43:10

0003

Toyota

Corolla

05/05/2001

11:34:32

0004

Honda

S2000

09/12/2001

15:32:22

If the consumer uses the method IRowsetChange::SetData to update the CarModel column for Customer 0004, the generated SQL is as follows:

UPDATE ServiceHistory SET CarModel=’Accord’ 
WHERE CustomerNo=? AND CarMaker=? AND CarModel=? AND 
DateLastServiced=cast (? AS DATE) AND TimeLastService=cast(? AS TIME)

Casting the parameter to TIME when compared against the TimeLastService column in the WHERE clause causes Teradata to generate the above error message.

If IRowsetChange::DeleteRows is called, the same WHERE clause is generated for the DELETE statement. This causes the same problem to occur.

When IRowsetChange::InsertRow is called the following SQL statement is generated:

INSERT INTO ServiceHistory (CustomerNo, CarMaker, CarModel, DateLastServiced, TimeLastService)
    VALUES (?, ?, ?, (? AS DATE), (? AS TIME))

In this case, casting the data to TIME in the VALUES clause also causes the above error to be generated.