Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run SQL Statement in AIX

Status
Not open for further replies.

tms05

Technical User
Apr 2, 2003
21
0
0
US
I was wondering if someone could help me. I am farely new to Unix and AIX. I was wondering how I can run a SQL statement in AIX. I have no clue on the syntax to connect, run the statement, and save as text. I do have and can use USQL on my desktop but I need it to run on AIX and send the results to our FTP server the Home/Data directory. Only a select few have the transoft license on their machines so we were thinking that we could have the results store on the FTP server and then our frontend database could link to the results. Any help or suggestions would be greatly appreciated.
 
I beg you pardon tsm05... you weren't that clear.
You have a DB (which kind? MySQL? Oracle? DB2...) on an AIX machine?
Do you wish to run some SQL statements on this AIX system and then send the output to some other server using FTP?
Do you wish to run all this stuff from another machine i.e. your workstation?
 
Sorry sbix. I really have no idea. I know we are using AIX and our FTP client is Reflections. We also have Usql utilities. How would I find out what kind of database we have and are using. Our driver is transoft. I was assuming we dont have a database and that the transoft driver is just pulling in flat file data but I could totally be mistaken as I am really new to all this software. I use Win Usqli to run the statements in windows. I would like to run within AIX and save or export as a text file. I can FTP it into my database that Im working on. Hope that makes it a little more clearer, if not I do apologize. Note, I did get my statement to run but now trying to figure out how to save the results in a file.
 
Oh... I see... yes probably Transoft gives you the way to query your flat files as like a RDBMS.
Well, the best idea is to look on the Transoft docs if there is a CLI runnable on server side.
Good Luck!
 
Over simplified but what about something like:

Code:
cd /directory/that/contains/usqlsd.ini

usqli <<EOF
<Datasource>
select * from accounts;
EOF

Regards,
Chuck
 
Yes we are using transoft. Thanks Chuck, but I can get my result but unsure how to save or create a file from the result.
 
cspilman-- How would I process the lines you provided above? When I go into AIX I CD to the folder then type in usqli. I then get prompted for Database then user then password. It then is expecting my statement. SOrry, I am not at all familiar with using usqli.
 
To save the results, put the commands in a script and redirect to a file something like this:

Code:
scriptname.sh > outputfile.txt

Let me clarify a point, I do not have any personal experience with using usqli but the documentation I see from the google searches indicate that the <Datasource> would be the database you are trying to connect to. You might try putting the password in the script as well but then you end up with security issues because you're putting passwords in a flat file that potentially anyone could see depending on permissions of the script.

The other option you might want to consider is using expect, but still... you end up using a password in clear text.

Sorry I couldn't be of more help. I'll post more if I think of anything else.

Regards,
Chuck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top