some_file")." />
 
Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Mon, 10 Sep 2007 @ 12:21:22 GMT


     
  <Prev Next>   <<First <Prev
Next>
Last>>
 


Subj:   Re: How to Get Output of SQL in UNIX Variable
 
From:   McCall, Glenn David

  > I am trying to store a value returned by BTEQ query into a UNIX variable. Please tell me the syntex for this.  


Bteq (and most other unix tools) don't work that way.

You have a couple of options that are all based upon the same concept. The option you choose will depend upon what value you are trying to get.

1. Capture the output.

2. Parse the output to extract the data you are looking for.


If you are looking for something in the data returned by a query (e.g. a particular column in a particular row, you can export the result set to a file and parse that. Refer to the .export command.

If you are looking for something from the bteq output - e.g. the number of rows, then you will need to redirect the output of the bteq command itself using the redirection operator (e.g. "bteq > some_file").

Once you've captured the output, you can use any number of Unix utilities to find the data you're looking for and do whatever you like with it. Perl is a great tool for this sort of thing.

Another possibility if you are prepared to use perl is to run your query through DBI. You might find this approach to be far less tedious.


I hope this helps

Glenn Mc



     
  <Prev Next>   <<First <Prev
Next>
Last>>
 
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023