0

I need to migrate from Oracle to Postgres.

In Oracle I have .sql files calling nested .sql files (with input and output parameters each one) in this way: nested sql scripts and variables

Looking for a similar solution in Postgres I found this: How to run postgres sql script from another script?

But what happens with the solution: \i other_script.sql

Can I pass input parameters to it? (and if yes, how?) Can I return parameters from it? (and if yes, how?)

Or the other_script.sql and the calling.script share variables?

Or there isn't an equivalent solution for input/output parameters. And variables are not shared between the two .sql files?

1 Answer 1

0

psql session variables are session based, so you can set any psql variable inside script, and you can read this variable outside script.

\set myvar some value
select :'myvar';

You can read more in psql documentation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.