UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 8th, 2006, 12:43 PM
moonflower moonflower is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Posts: 2 moonflower User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m
Reputation Power: 0
Unhappy Newbie needs assistance writing script.

Hi,
First just so you know I have never programmed in UNIX, but have programmed in other languages..

With that being said all I want to do is this:

run a unitscript passing 1 parameter

ex:

fci_trans_xp.sh 4


in the fci_trans_xp script I want to insert that value into a table

So:
parm1=$1 (which I assume = 4)??
The line below is my login to Teradata SQL
cat $dwmod/logon/fxport.tlg > $dwrunmod/fci_trans_xpf1.rf

What I need to know is how to write the insert into UNIX.

insert into cses_dev.tablename (column1) values (parm1)

First is the syntax correct above?
Second what do I need to make that insert stmt execute?

The rest in the middle I think I can figure out. I just dont know how to execute a sql statement within UNIX.


Sorry if this is really a stupid question..
thanks
moonflower

Reply With Quote
  #2  
Old September 8th, 2006, 02:02 PM
vlsimpson vlsimpson is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2005
Location: The grassy knoll
Posts: 115 vlsimpson User rank is Sergeant Major (2000 - 5000 Reputation Level)vlsimpson User rank is Sergeant Major (2000 - 5000 Reputation Level)vlsimpson User rank is Sergeant Major (2000 - 5000 Reputation Level)vlsimpson User rank is Sergeant Major (2000 - 5000 Reputation Level)vlsimpson User rank is Sergeant Major (2000 - 5000 Reputation Level)vlsimpson User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 5 Days 2 h 1 m 30 sec
Reputation Power: 41
Don't know Teradata. Don't know the SQL stuff very well just to be upfront.

But MySQL and Postgre have command line tools to read a db login and password and a SQL command.
Command mysql for MySQL (duh) and pgsql (I think) for Postgre.

Maybe Teradata has similar.

Code:
mysql -u db_user -ppassword -e 'sql_command' the_db_name

for mysql.

script example
Code:
#!/bin/sh
parm1="$1" #quote your variables, not always necessary but it doesn't hurt
mysql -u db_user -ppassword -e 'sql_command' the_db_name
#all the rest


Some thing like that.

Reply With Quote
  #3  
Old September 8th, 2006, 02:54 PM
moonflower moonflower is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Posts: 2 moonflower User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m
Reputation Power: 0
Newbie Help

Although I would think your syntax would work our Teradata login is kept in a separate file. I would have to call that file to get logon information, thus the sql stmt needs to be a separate entity within the unix script..

This is where I am getting lost on how to execute it.

thanks
moon

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Newbie needs assistance writing script.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT