Click to See Complete Forum and Search --> : Teradata BTEQ script - selecting 2 tables


darkcloud
June 16th, 2008, 10:46 AM
Any ideas why the first query is passed as a '?' in the following script

I am unsure why the code below in does not work properly. For some reason it will not pick up the first sql in the report
i.e:
SELECT CAST(CAST(MIN(CALENDAR_DATE) AS INTEGER FORMAT '99999999') AS CHAR(08)) (TITLE '')
FROM BRP_SANDBOX.CL_START_DATE

When I change it to the table SC_CL_DATES_TO_DELETE which is the one further down in the query it works, and outputs a date.
The report outputs as followed, the ? in the output refers to the first select:

UPDATE BRP_SANDBOX.SC_CL_DATES_TO_DELETE
SET CALENDAR_DATE =
?
WHERE CALENDAR_DATE =
01070601
;

My assumption is that you can only do a select on one table when creating a sql report. Is this correct? Am I doing something incorrectly.

The script is below.

.SET WIDTH 550
.SET TITLEDASHES OFF
.EXPORT REPORT FILE=/tmp/test.sql


SELECT ' UPDATE BRP_SANDBOX.SC_CL_DATES_TO_DELETE ' (TITLE '')
;SELECT 'SET CALENDAR_DATE = '(TITLE '')
;SELECT CAST(CAST(MIN(CALENDAR_DATE) AS INTEGER FORMAT '99999999') AS CHAR(08)) (TITLE '')
FROM BRP_SANDBOX.CL_START_DATE
;SELECT 'WHERE CALENDAR_DATE = ' (TITLE '')
; SELECT CAST(CAST(MIN(CALENDAR_DATE) AS INTEGER FORMAT '99999999') AS CHAR(08)) (TITLE '')
FROM BRP_SANDBOX.SC_CL_DATES_TO_DELETE
;SELECT ';' (TITLE '')
;SELECT '.IF ERRORCODE <> 0 THEN .GOTO SAM2END' (TITLE '')
;SELECT ' ' (TITLE '')
;SELECT '.LABEL SAM2END' (TITLE '')
;

.EXPORT RESET

.RUN FILE /tmp/test.sql