BTEQ examples
Teradata Teradata Discussion Forums Teradata.com Discussion Forum
Visit Teradata.com
Home       Guidelines    Member List
Welcome Guest ( Login | Register )
        


This online forum is for user-to-user discussions of Teradata products, and is not an official customer support channel for Teradata. If you require direct assistance, please contact Teradata support.

12»»

BTEQ examples Expand / Collapse
Author
Message
Posted 9/14/2006 2:53:23 PM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 10/2/2009 2:55:27 PM
Posts: 36, Visits: 13
Fellow forum members,
I need to build/write some BTEQ scripts to pickup data from laptop folders example e:\my_data\my_excel_file.txt and upload/create a file on our Teradata data mart.
Are there any concrete examples of this BTEQ script that I can use..

I have never used BTEQ so do not send me very complex scripts, It would take me sometime to understand.. start slow and maybe in 3 mths I will be an expert LOL...

Much appreciated


Vincent Gabrielli
Post #5152
Posted 9/14/2006 5:40:08 PM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 8/12/2009 6:03:17 PM
Posts: 177, Visits: 64
You can use BTEQ's .IMPORT option to load data. This is very simple to use ,provided, your input file is in Indicdata or data format.

The syntax for this looks like following

.IMPORT DATA FILE = filename

using (:field1,:field2,:field3,....,:fieldn)
insert into targettable(column list)
values
(:field1,
:field2,
.....
.....
:fieldn);

You can learn more on BTEQ's Import and Export option from BTEQs reference Manual.
Wish you best of luck .


Leo Issac

"Wants to Learn More!"

Post #5156
Posted 9/15/2006 7:05:30 AM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 11/22/2006 11:55:00 PM
Posts: 30, Visits: 1
Hi Dude,
since u wanna load the data from txt file, i believe it should be in delimited fmt.
The following script uses ',' as field delimeter.
Also, its capable of loaded 'n' number of records.
Give it a try.


.LOGON demotdat/sarathy_user,*****;
.IMPORT VARTEXT ',' FILE=C:\TD\data\ABC.TXT;
.REPEAT *
USING
emp_no (VARCHAR(6)),
emp_name (VARCHAR(25)),
emp_street (VARCHAR(25)),
emp_city (VARCHAR(25))

INSERT INTO sarathy_db.emp
values
(
:emp_no,
:emp_name,
:emp_street,
:emp_city
);

.QUIT;







SarathyG
Post #5178
Posted 9/15/2006 7:32:33 AM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 10/2/2009 2:55:27 PM
Posts: 36, Visits: 13
Thank you for the examples... much appreciated

Vincent Gabrielli
Post #5181
Posted 3/26/2007 4:28:23 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 9/11/2007 12:54:00 PM
Posts: 2, Visits: 1
I have one more query here.
when we import data from file everytime a record is inserted into the table a display message for executing query is shown up in spool. If i have 1000 records in input file it resutls in 1000 display's (Total elapsed time was 0.13 seconds.)
Can anyone please help to suppress these display messages. Thanks in advance.


Swathi

Teradata SQL certified.

Post #6981
Posted 3/27/2007 1:38:28 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 7/5/2009 2:58:22 PM
Posts: 134, Visits: 13
Comment on SwathyG post

We can load fixed length data file so long as text file and the column length are in sync.

For Swathy_Teradata post

use
.SET ERROROUT STDOUT

in your bteq script.
You could then redirect your output to a log file as in this case

/usr/bin/bteq < /home/sunopsis/util/scripts/test.bteq > /home/sunopsis/util/log/test.log

Hope this helps.

Vinay
Post #6982
Posted 3/27/2007 9:34:17 AM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 10/2/2009 2:55:27 PM
Posts: 36, Visits: 13
Thank you for all your assistance.. I have used some of the suggestions and
works very well... great team approach


Vincent Gabrielli
Post #6985
Posted 3/27/2007 1:48:42 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 9/11/2007 12:54:00 PM
Posts: 2, Visits: 1
Thanks Vinay but the issue still exists. .SET ERROROUT STDOUT is helpful only when there are error messages.
.REPEAT *
USING
emp_no (VARCHAR(6)),
emp_name (VARCHAR(25)),
emp_street (VARCHAR(25)),
emp_city (VARCHAR(25))

INSERT INTO sarathy_db.emp
values
(
:emp_no,
:emp_name,
:emp_street,
:emp_city
);
Above query in mainframes with 5 records in source file results in
*** Starting Row 0 at 12:32:37 on Tue Mar 27, 2007
*** Total elapsed time was 0.10 seconds.
*** Total elapsed time was 0.07 seconds.
*** Total elapsed time was 0.02 seconds.
*** Total elapsed time was 0.03 seconds.
*** Total elapsed time was 0.01 seconds.
*** Warning: Out of data.
*** Finished at 12:32:37 on Tue Mar 27, 2007
*** Total number of statements: 5, Accepted : 5, Rejected : 0

*** Total elapsed time was 0.25 seconds.

*** Total requests run successfully = 5
*** Successful requests per second = 20.395
In case the source file has 100 records then 100 messages corresponding to elapsed time are populated. I want only one response as
*** Total elapsed time was 0.25 seconds.


Swathi

Teradata SQL certified.

Post #6988
Posted 3/28/2007 2:45:40 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 7/10/2009 6:28:52 PM
Posts: 505, Visits: 546
From your example it looks like you are running on windows, In case you are using unix for production, something like this might help ....

bteq < mybteq.btq 2>&1 | awk '/^BTEQ/,/Starting Row/ /Finished at/,/$$$$$$$$$$$$$/' >mybteq.log
Post #6994
Posted 3/28/2007 4:53:34 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 11/5/2009 4:40:02 PM
Posts: 717, Visits: 466
Hi Swathi,
i don't know about mainframe BTEQ, but on Windows/Unix there are two solutions to suppress that "one output line per row":
- using more than 1 session
- using a ".PACK 1"

Dieter
Post #6999
« Prev Topic | Next Topic »

12»»

Reading This Topic Expand / Collapse
Active Users: 1 ( 1 guest, 0 members, 0 anonymous members )
No members currently viewing this topic.


All times are GMT -5:00, Time now is 11:59am

Powered By InstantForum.NET v4.1.4 © 2009
Execution: 0.094. 10 queries. Compression Disabled.