How to pass a shell variables to sql or pl/sql block?

In a shell script, I like to pass a shell variable (date parameter) to a sql block that will be used to update a table in a database. Please advise how I can pass a shell variable to a sql block.
Who is Participating?
Gerwin Jansen, EE MVEConnect With a Mentor Topic Advisor Commented:
Hi IT_ETL, you can use variables, like this:

sqlplus -S ${user}/${pass} <<EOF
 SELECT * FROM tableName WHERE username=${var};

Open in new window

The <<EOF construction is know as a 'here' document.

You can substitute your date variable (passed as a string I presume) with a to_date function.
Swadhin RayConnect With a Mentor Senior Technical Engineer Commented:
Check another good example on :

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.