Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2003
    Posts
    3

    Unanswered: running the sql stmt from Linux

    Hi there,

    How can I submit a sql statment from linux using shell-script

    I tried

    ./psql tab postgres/postgres @./marco.sql
    (based on Oracle string that I use) but it didn't work.


    thank you

  2. #2
    Join Date
    Feb 2003
    Posts
    3
    Hi there, I was able to figure this one out
    ./psql tableName<scriptTorun

    another question:

    in Oracle I use the
    ACCEPT variable PROMPT 'question?'
    to prompt the user for input

    what is the equivalent in Prostgres


    thank you

  3. #3
    Join Date
    Mar 2002
    Location
    Pilipinas
    Posts
    36
    Originally posted by veteqii
    Hi there, I was able to figure this one out
    ./psql tableName<scriptTorun

    another question:

    in Oracle I use the
    ACCEPT variable PROMPT 'question?'
    to prompt the user for input

    what is the equivalent in Prostgres


    thank you
    hi there! maybe this script will give you an idea...
    --------------------------------------
    #!/bin/sh

    DATE=`date +%b%d-%y`
    DBASE="$1"
    PG_DUMP='/usr/local/pgsql/bin/pg_dump'
    GZIP='/bin/gzip'

    if ["$1" == '']
    then
    echo "syntax error!!!"
    exit
    else
    echo "$DATE: Creating BackUp..."
    $PG_DUMP "$DBASE" | $GZIP > dbase-"$DATE"_"$DBASE".dump.gz 2> dbase-"$DATE"_"$DBASE".error.log
    echo "BackUp $DBASE Finished!"
    fi
    exit 0
    --------------------------------------------

    this is just a simple script for backing up PostgreSQL database

    USAGE:
    ./script_name dbase_name

    HTH
    --- Hey! its me!!! the MaleMan ---

  4. #4
    Join Date
    Feb 2003
    Posts
    3
    thank you for your response,
    great utility, I will used it to backup my database.

    What I am looking for is the ability to request
    user input from within the SQL script

    in oracle the command is:

    in Oracle I use the
    ACCEPT variable PROMPT 'question?'

    is there something simular with postgres?

    Thank you
    Last edited by veteqii; 02-08-03 at 00:36.

Posting Permissions

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