Home » SQL & PL/SQL » SQL & PL/SQL » simple plsql
simple plsql [message #187768] Tue, 15 August 2006 09:50 Go to next message
nandac
Messages: 41
Registered: July 2006
Location: jersey city, usa
Member

hi! i'm just trying to connect and execute and print something on plsql from a unix script :

sqlplus /nolog <<EOF
connect newuser/newuser
declare cnt integer := 1;
WHILE (cnt < 5)
LOOP
print :cnt;
cnt := cnt + 1;
END LOOP;
EOF


but it is not working!

appreciate the feedback.
Re: simple plsql [message #187770 is a reply to message #187768] Tue, 15 August 2006 10:05 Go to previous messageGo to next message
ebrian
Messages: 2794
Registered: April 2006
Senior Member
sqlplus -s /nolog <<EOF
connect newuser/newuser
set serverout on feed off
declare cnt integer := 1;
begin
WHILE (cnt < 5)
LOOP
dbms_output.put_line(cnt);
cnt := cnt + 1;
END LOOP;
end;
/
EOF
Re: simple plsql [message #187771 is a reply to message #187768] Tue, 15 August 2006 10:08 Go to previous messageGo to next message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
First make it work (i.e. make sure it works from PL/SQL), then make it fancy (i.e. do "something" to run (already tested) PL/SQL procedure from operating system command prompt).

This, as far as I can tell, isn't a valid PL/SQL procedure.
Re: simple plsql [message #187772 is a reply to message #187768] Tue, 15 August 2006 10:12 Go to previous messageGo to next message
nandac
Messages: 41
Registered: July 2006
Location: jersey city, usa
Member

thanks for the response. now the script works.

appreciate if you could explain what the following are :

why the "-s" option when running sqlplus?

what does this do : set serverout on feed off

is there not a "print" command in plsql?

what's the "/" for before EOF?

appreciate the feedback.
Re: simple plsql [message #187775 is a reply to message #187772] Tue, 15 August 2006 10:17 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
See the first post in the forum for a link to the documentation. Time for some reading of the basics of sqlplus.
Re: simple plsql [message #187777 is a reply to message #187768] Tue, 15 August 2006 10:19 Go to previous message
BlackSwan
Messages: 25050
Registered: January 2009
Location: SoCal
Senior Member
>appreciate the feedback.
It appears that you are unwilling or incapable of doing ANY research on your own & expect to be spoon fed answers.
You could trying reading any of the fine manuals found at http://tahiti.oracle.com
Especially the ones on SQL, SQL*PLUS * PL/SQL; plus the Concepts Manual
Previous Topic: Problem with Recompiling Invalid PLSQL Objects(ORA-04068)
Next Topic: Struggeling on query......
Goto Forum:
  


Current Time: Sat Dec 10 00:53:18 CST 2016

Total time taken to generate the page: 0.10684 seconds