I have an SQL script which when run prompts me to input a value. If I don't input any value and press the Enter/Return key, it will select the default value and will pull all the records. I am trying to incorporate this into a shell script where I don't want the script to prompt me for any value and should just accept the "return key" by default. Is there a way I can do this ?

Example of what I'm trying to do.

in_code is the variable in the xecute.sql, which accepts a value. I want this variable to select the Enter/Return key by default. The code I use below doesn't work.

#! /bin/bash
sqlplus -s xxx/xxx<<!
define in_code='echo -e "\n"'
  • Any help please ?? Tried multiple areas and none seem to be working – Super Jul 21 '16 at 10:41
  • Could you edit the question and add the relevant bits of the SQL? I'm not familiar with sqlplus but seeing a bit of what the SQL is doing (reading a value, for example) might help. – Kusalananda Jul 28 '16 at 12:05
  • I am also not familiar with how sqlplus reads its input, but does it work if you put a blank line after the part of the SQL code that's expecting input? Or define in_code to be single-quote (hit enter here), single-quote? – Jeff Schaller Aug 2 '16 at 12:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.