IMPORT DATA WITH USING (variable)

Database

IMPORT DATA WITH USING (variable)


We need to make a BTEQSQL with the command “EXPORT REPORT” using a variable that contain the name file that we must use and generate.
Following, we explain the SQL with the syntax USING to recuperate the name file that is used to export data.

.IMPORT DATA FILE = 'TEST.DAT';
USING ROOT (CHAR (20)), CODE (CHAR(2))
.EXPORT DATA FILE =:ROOT;
SELECT NAMEFILE FROM DATABASE.USERS WHERE CODE=:CODE;
.EXPORT RESET

But this solution isn't write because we can't used the syntax USING.
Another solution?
3 REPLIES
hh
Enthusiast

Re: IMPORT DATA WITH USING (variable)

I am not sure this will work but have you try putting those values from a file into a teradata table and use the table to drive your file name?

Re: IMPORT DATA WITH USING (variable)

Hi all,

I also have a problem with an IMPORT.

my IMPORT looks like :

.IMPORT VARTEXT '|' FILE "test_export.del", SKIP=1
.REPEAT *
USING I don't know ???
INSERT INTO TableName
VALUES I don't know ???;
.LOGOFF

I don't want to describe my table "TableName" in the USING and in the VALUES, like :

.IMPORT VARTEXT '|' FILE "test_export.del", SKIP=1
.REPEAT *
USING (COETB CHAR(3) ,COEM CHAR(7), CTEM CHAR(3))
INSERT INTO TableName
VALUES(:COETB, :COEM, :CTEM);

Is someone can help me ?

Thanks
Teradata Employee

Re: IMPORT DATA WITH USING (variable)

For the export, do it in two steps

.IMPORT DATA FILE = 'TEST.DAT';

.EXPORT DATA FILE = 'WORK.TXT';
USING ROOT (CHAR (20)), CODE (CHAR(2))
SELECT '.EXPORT DATA FILE ='||:ROOT||';' (CHAR(255))
;SELECT 'SELECT NAMEFILE FROM DATABASE.USERS WHERE CODE='''||:CODE||''';' (CHAR(255))
.EXPORT RESET

.RUN FILE='WORK.TXT';
.EXPORT RESET