Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2006
    Posts
    3

    Question Unanswered: 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

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    yes, what's your question?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    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

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Which shell, and what SQL engine?

    -PatP

  5. #5
    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

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    moving thread to Unix Shell Scripts forum
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  7. #7
    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 17:27.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •