Re: PL/SQL run from SQL*Plus

From: <champs_at_hhcs.gov.au>
Date: 8 Mar 93 08:32:36 +1100
Message-ID: <1993Mar8.083236.646_at_hhcs.gov.au>


In article <1993Mar5.093138.1_at_vax1.tcd.ie>, mcgrathm_at_vax1.tcd.ie writes:
>
>
> Hi Folks,
>
> I wish to run a PL/SQL script from SQL*PLUS. However
> I am getting error messages such as:-
>
>
> Unknown command beginning "Cursor .." rest of line ignored
>
> This occurs for each of the PL/SQL commands. I have appended the script
> below.
>
> My Questions are (1) Can PL/SQL be run as a script from SQL*PLUS ?
> (2) If so, what are the syntax requirements to do this ?
> (3) What system changes are needed.
>
> All help will be very welcome.
>
> Many Thanks,
>
> Michael.

Here's your problem:

You forgot the BEGIN at the top of the PL/SQL block  

>
> declare CURSOR C1 IS
> SELECT I.SESSION_CODE,req_TIME,X_LENGTH,FULL_SESS,
> START_TIME,MINS,EXAM_DATE
> FROM I.INVIG_SESSION I,X_SESSION X
> WHERE I.SESSION_CODE = X.SESSION_CODE
> AND X.SESSION_CODE IN (SELECT SESSION_CODE
> FROM INVIG_SESSION
> WHERE INVIG_SESSION.STUD_NO = '123456');
> CREC C1%ROWTYPE;
> FINISH NUMBER;
> BEGIN
> OPEN C1;
> LOOP
> FETCH C1 INTO CREC;
> EXIT WHEN CREC%NOTFOUND;
> MESSAGE (CREC.I.SESSION_CODE);
> END LOOP;
> END;
> /
 


    /\       Steven Champness (champs_at_hhcs.gov.au)
   /  \      Dept Health Housing and Community Services
  /    \     Brisbane Queensland
 /      \     via

/ / \ Canberra Australia
\ / / /
 \/ / / / MACINTOSH SOFTWARE AXIOM : If you need a manual to operate it
  \/ / /                                it wasn't designed properly in the
   \/ /                                 first place !
    \/ Received on Sun Mar 07 1993 - 22:32:36 CET

Original text of this message