Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2010

    Unanswered: Passing in paramters to scripts run with \i

    I have a ton of experience using Oracle. PostgreSQL... not so much. I am banging my head against the wall trying to do stuff that was really easy in Oracle.

    My Question: I am using "psql" interactively and I want to run a script using the "\i" command, how can I pass in arguments on the fly?

    Ie. I would like to do something like:

    \i my_script.psql arg1 arg2 arg3

    And in my script would be something like:

    SELECT :arg1 FROM :arg2 WHERE mycolumn = ':arg3';

    I really DON'T want to use \set to set each variable in advance. Sorry if this is a totally noob question... I couldn't find an answer using Search.


  2. #2
    Join Date
    Nov 2006
    I think you cant do it with \i but you can with psql (-v option). I think you can call psql command when logged to database using \!.

Tags for this Thread

Posting Permissions

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