If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Record Insert ???? Help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-12-06, 12:55
Danny1 Danny1 is offline
Registered User
 
Join Date: Aug 2006
Posts: 3
Question Record Insert ???? Help

Hi
I am a newbie to DB concepts and have a basic idea about SQL can any one help me out to have a shell Script to insert around 100 records to a Table???

Thanks in Advance
Bye
Reply With Quote
  #2 (permalink)  
Old 08-12-06, 13:43
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,543
yes, what's your question?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 08-12-06, 23:28
Danny1 Danny1 is offline
Registered User
 
Join Date: Aug 2006
Posts: 3
Red face Insert Records to Table ?????help

What I mean is how should i proceed or write a Shell Script to insert 100 or more( with a loop or with any thing else???) records to a table .

Thank you
Reply With Quote
  #4 (permalink)  
Old 08-13-06, 02:15
Pat Phelan Pat Phelan is online now
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,614
Which shell, and what SQL engine?

-PatP
Reply With Quote
  #5 (permalink)  
Old 08-13-06, 09:02
Danny1 Danny1 is offline
Registered User
 
Join Date: Aug 2006
Posts: 3
Quote:
Originally Posted by Danny1
What I mean is how should i proceed or write a Shell Script to insert 100 or more( with a loop or with any thing else???) records to a table
Thank you
bash and MySQL
Reply With Quote
  #6 (permalink)  
Old 08-13-06, 09:05
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,543
moving thread to Unix Shell Scripts forum
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #7 (permalink)  
Old 08-13-06, 16:21
Tyveleyn Tyveleyn is offline
Registered User
 
Join Date: Aug 2006
Location: The Netherlands
Posts: 248
Example

Hi, since I'm doing this stuff frequently I've got an example for you. It's done in script but usually I use awk for this, it looks more like a regular programming language.

#!/bin/bash

CNT=0

while [ $CNT -lt 100 ]; do
let CNT=${CNT}+1
INT=$CNT
STRING="${CNT}"
FLOAT=$CNT
printf "insert into table values(%d,\"%s\",%.2f);\n" "${INT}" "${STRING}" "${FLOAT}"
done

Of course the printf can be substituted by `echo`.

Grts.

BTW. I'm not familiar with MySQL but this code is standard SQL, of wich I believe MySQL will accept...

Last edited by Tyveleyn; 08-13-06 at 16:27.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On