Teradate table read?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Teradate table read?
# 1  
Old 06-05-2009
Error Teradate table read?

i have to read some data from a teradata table and use them in my shell script.. how do i do that.. we can use BTEQ .. but i don know how to pass the field values as variables to the shell.. please help me....

Last edited by depakjan; 06-05-2009 at 03:04 AM..
# 2  
Old 06-05-2009
Quote:
Originally Posted by depakjan
i have to read some data from a teradata table and use them in my shell script.. how do i do that.. we can use BTEQ .. but i don know how to pass the field values as variables to the shell.. please help me....
Are you selecting single row or multiple row from table??
If you are selecting multiple row and want to do some change in them depending on some condition its better to take data in a flat file
If its only one row you can directly pass the values to variable.
# 3  
Old 06-05-2009
hi thanks for the help vidyadhar85 and yea the table has only one row ... can you please share the code for moving the row values to a seperate varible?

imagine the table has four dates in four different formats and i want it in 4 variables with which i could program in my shell script...
# 4  
Old 06-05-2009
I never worked on teradata but in oracle we do it like this
Code:
home/> var=`sqlplus -s \/<<EOF
> set head off
> set feedback off
> set pages 0
> select to_date from dummy where rownum<5;
> exit
> EOF`
home/> echo $var
20090605 20090604 20090603 20090602

use awk or cut to get field one by one and store it in variables
# 5  
Old 06-05-2009
Thanks for the code... but i dont know how do i do it with teradate .. wont there be any connection thing or something.. and is sqlplus a keyword.. i dont know what will be the teradata equivalent of it... thanks anyway... Smilie
# 6  
Old 06-05-2009
what command you use to connect teradata from your unix box??
# 7  
Old 06-09-2009
i tried like this , but i get syntax error..
Code:
 0403-057 Syntax error at line 3 : ``' is not matched.

Code:
#/bin/ksh
VAR1=`bteq<< EOD
.RUN FILE /home/nbk6cst/dbpass;
select * from load_work.setmonth;
.logoff;
EOD'
echo $VAR1

tried without(`) then bteq gets printed... please tell me how to do this?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell Script to read hive table and send email

HI Team, I am working on reading hive table and send email in email body using shell script, can you please help on fixing the errors: I have 6 columns in my hive table and trying to send the email in the mail body. below script: #!/bin/bash hive -e 'SELECT count(*) from db.table' >... (4 Replies)
Discussion started by: Mi4304
4 Replies

2. UNIX for Beginners Questions & Answers

Read Table in file and split

HELLO I need your help please , i need to read a file that contain a table like : Name | Status ------------------ DB 1 | UP DB 2 | UP DB 3 | DOWN DB 4 | UP DB 5 | UP the objective to read each line and check if DB is UP or Down and give me the name of Down database.... (10 Replies)
Discussion started by: Abdellah
10 Replies

3. UNIX for Beginners Questions & Answers

Improving find to read table name from file

Hi there, I currently use the following find command to recursively search all the subdirectories in our file system for a table ( in this case BB_TENURE_DAYS) find -type f -exec grep -l "BB_TENURE_DAYS" {} \+ So I have this so far - the problem is how do I read the line to get the... (2 Replies)
Discussion started by: rjsha1
2 Replies

4. Shell Programming and Scripting

shell, read table and write the value for each factor to output

Hey guyz, I have a table like this: 1 A=#;B=#;C=# 2 A=#;C=#;D=#;E=#;E=# 3 B=#;B=#;B=#;D=# # are just some numbers. I want to have the output like this: * 1 2 3 A # # NA B # NA # C # # NA D NA # # E NA # NA So basically, I wanna know in each of the rows in my input (which... (9 Replies)
Discussion started by: @man
9 Replies

5. Shell Programming and Scripting

Read in Table as a matrix

Dear forum users, i'm trying to read a table with 40x122 data in a array. Following this, i'd plot each rows again the header of the file in gnuplot. i was thinking for something like that #!/bin/bash # reads from the $ips file and assigns to $MYARRAY #IFS =";" split the line after the... (6 Replies)
Discussion started by: servuskelb
6 Replies

6. HP-UX

how to read routing table

Hi all, Could someone please explain to me how I should read this routing table, # netstat -rn Routing tables Destination Gateway Flags Refs Interface Pmtu 127.0.0.1 127.0.0.1 UH 0 lo0 32808 10.222.47.82 10.222.47.82 UH... (3 Replies)
Discussion started by: rachael
3 Replies

7. Shell Programming and Scripting

Read Table,View,Package,Function and Procedure Name in a File

Hi I am new to Unix shell scripting. But i need help to slove the below issue. Issue description: I want to read table, view names and package names in a file my plan to find the table name is : search "From" key word find the table or view To find the packge name : Search "Package... (5 Replies)
Discussion started by: sboss
5 Replies

8. Shell Programming and Scripting

calling sqlplus, read table return etc

I have korn shell scripts. I want to pass a variable to a script which will execute a a sql script to read a table that contains env. variables. I want to read and then somehow export at unix level variables example for every row selected from the table build export command line field1... (5 Replies)
Discussion started by: TimHortons
5 Replies

9. Solaris

Need some lib in c/c++ to read db table at one go

Hi All, I need some sort of library or module which read the db table at one go and keep in process memory.My problem is that I have a call processing module which handles the network call and goes for db lookup for subscriber profile in oracle db for every call.I am using Oracle Standard Edition... (0 Replies)
Discussion started by: unisuraj
0 Replies

10. UNIX for Dummies Questions & Answers

Read variables from Access table

Hi! I've just started learning shell scripting, and have been somewhat 'thrown in at the deep-end and told to swim' so excuse my complete lack of knowledge and ignorance, but here goes... I've been given a unix script to 'tidy up'. Basically the script consists of the few lines of code being... (2 Replies)
Discussion started by: Sn33R
2 Replies
Login or Register to Ask a Question