I have a code that invoke a SQL statement for a simple select * from
query, but I don't know what I´m doing wrong, always gives me an error.
This is the shell code:
#!/bin/sh
. /usr/local/bin/oracle.profile.prod
. /usr/local/bin/bscs.profile.prod
hostname=`uname -n`
basedato=PQBSCS
if [[ $basedato = "PQBSCS" && $hostname = "panhp03" ]];then
export RUTASHELL=/user/cartera_varios/Shell_Portabilidad/others/shell
export RUTASQL=/user/cartera_varios/Shell_Portabilidad/others/plsql
export RUTALOG=/user/cartera_varios/Shell_Portabilidad/others/log
. /user/cartera_varios/Shell_Portabilidad/others/.MM.txt
else
echo " ambiente no valido, se cancela el proceso."
exit 1
fi
FECHA=`date +%Y%m%d%H%M%S`
sqlplus -S $USER/$PASS@$basedato @$RUTASQL/consulta.sql $RUTA_UTL $DIAS> $RUTALOG/Consulta$FECHA.log
sleep 5
echo " proceso finalizado, revisar la ruta de log "
And this is the SQL statement that I´m trying to invoke:
SET SERVEROUTPUT ON SIZE 1000000 SET PAGESIZE 1000 SET TIMING OFF SET VERIFY OFF SET HEADING OFF
SPOOL /user/cartera_varios/Shell_Portabilidad/others/log/resultado_select.txt
declare
/*Variable que almacena el resultado de la función*/ resul varchar2(30);
begin
/* LLamada a la funcion*/ resul:=select * from mdsrrtab where REQUEST
= '536897804';
END; / EXIT;
and this is the result.
result:=select * from mdsrrtab where REQUEST = '536897804';
* ERROR at line 9: ORA-06550: line 9, column 8: PLS-00103: Encountered the symbol "SELECT" when expecting one of the following: ( - + case mod new not null <an identifier> <a double-quoted delimited-identifier> <a bind variable> avg count current exists max min prior sql stddev sum variance execute forall merge time timestamp interval date <a string literal with character set specification> <a number> <a single-quoted SQL string> pipe ORA-06550: line 12, column 1: PLS-00103: Encountered the symbol "DBMS_OUTPUT" ORA-06550: line 12, column 33: PLS-00103: Encountered the symbol ";" when expecting one of the following: . ( , * % & - + / at mod rem <an identifier> <a double-quoted delimited-identifier> <an exponent (**)> as from into || bulk
Any help will be highly appreciated.