Cat echo_time #!/bin/sh"sys/unimas as Sysdba" <<! Select to_char (sysdate,'yyyy-mm-dd') today from Dual;exit;! [email protected] shell_test]$.
Operation Result:
TODAY-----------Geneva-
-S is silent mode, does not output similar "sql>", connect the database, close the database and other information.
Eof
EOF can be any string such as "Laldf" then when you enter a single line Laldf "The shell thinks the input ends, but must indicate that the block must start with <<;
Start and end to match this symbol "<<" after the content
Example:
" Sys/unimas as Sysdba " << ABCselect to_char (sysdate,'yyyy-mm-dd') today from dual; > exit; > ABC
Run results
TODAY-----------Geneva-
Two. Sqlplus results passed to the Shell method one
[Email protected] shell_test]$CatTest2.SH #!/bin/Bashvalue= ' Sqlplus-s"Test/unimas"<<!set heading offset feedback offset pagesize0Set Verify offsetEchooffSelectTo_char (Sysdate,'YYYY-MM-DD') today from Dual;exit!`Echo$VALUEif[-N"$VALUE"]; ThenEcho "The rows is $VALUE"Exit0ElseEcho "There is no row"fi
three. Sqlplus results passed to the Shell method two
[Email protected] shell_test]$CatTest1.SH #!/bin/Bashsqlplus-S"Test/unimas"<<!set heading offset feedback offset pagesize0Set Verify offsetEchoOffcol coun new_value V_counSelectCOUNT (*) Coun from Lesson;exit V_coun!VALUE="$?"Echo "Show row: $VALUE"
Col coun New_value V_coun V_coun is the number type. Because exit can only return numeric types.
four. Pass the shell parameters to the Sqlplu
#!/bin/basht_id="$" "test/unimas " < <! 0echo offselectid=$t _id;exit !
Five. Sqlplus results are stored in the file
#!/bin/sh"test/unimas"<< 0 echo* from teacher;spool offexit; EOF
Shell calls Sqlplus query Oracle