Skip site navigation (1) Skip section navigation (2)

Passing Parameters To Command Scripts

From: "Duncan Garland" <duncan(dot)garland(at)ntlworld(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: Passing Parameters To Command Scripts
Date: 2006-11-15 14:56:23
Message-ID: MBEPKEEDMKGCDODFKLPPGECHDEAA.duncan.garland@ntlworld.com (view raw or flat)
Thread:
Lists: pgsql-novice
I'm in the process of converting some Oracle SQL scripts to Postgres. Many
of the scripts accept arguments along the following
lines:

@tmp.sql fred

I can't find the Postgres equivalent.

This works from outside Postgres:

psql -f tmp.sql -v arg1=fred

This works from within psql

\set arg1 fred
\i tmp.sql
\unset arg1

But the following all fail

\i tmp.sql fred
\i tmp.sql arg1=fred
\i tmp.sql -v arg1=fred

Can anyone help? What is the correct syntax?


Responses

pgsql-novice by date

Next:From: Richard Broersma JrDate: 2006-11-15 15:24:57
Subject: Re: Passing Parameters To Command Scripts
Previous:From: Richard Broersma JrDate: 2006-11-15 01:45:42
Subject: Re: hardware - generic

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group