Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Total Newbie PL/SQL Question

Status
Not open for further replies.

modfather

MIS
Feb 15, 2000
75
US
I hope this isn't posted to the wrong area - my apologies if so. My question is very basic:

In PL/SQL, what determines where the program "begins"? I understand that there is three sections: declaritive, executable, and exception. From the VERY brief reading I've done (yes, I'm brand new to Oracle - I have programmed in some similar languages to PL/SQL, so I can understand the basic functionality) I'm having difficulty understanding something. But let me show you all a bit of code, with some questions:

CREATE OR REPLACE Package APPS.CUSTOM_STUDENT_LOAD
IS
PROCEDURE STUDENT_LOAD_MAINLINE;
g_last_name VARCHAR2(25) := 'SMITH';

PROCEDURE STUDENT_LOAD_MAINLINE
IS

CURSOR STUDENTS_C IS

SELECT *
FROM STUDENTS
WHERE LAST_NAME = g_last_name;

ABNORMAL_END exception;

BEGIN
FOR VENDOR_DATA IN STUDENTS_C LOOP
...
END LOOP;
END STUDENT_LOAD_MAINLINE;
END CUSTOM_STUDENT_LOAD;

There may be some syntax errors above, but can someone explain to me why the program automatically knows to start with the "BEGIN" statement? I ask because the "BEGIN" statement is nested inside the "STUDENT_LOAD_MAINLINE" procedure. So that procedure isn't technically "called" from the main program?

This program was already written and I'm picking up the pieces and am just trying to get a handle on it... Any feedback?

Thanks!
Steve
 
The program begins with the first byte and ends with the last byte, comment statements excluded. This is a basic fundamental of PL/SQL which all new Students need to understand.

-------------------------
The trouble with doing something right the first time is that noboby appreciates how difficult it was.
- Steven Wright
 
johnherman,

Thanks for your reply. I kind of assumed that, but procedures have to be called, right? In other words, if I have many procedures/functions in my package, and they do certain functionality, that isn't performed until the procedure/function is called, right?

If that's the case, then why is my PROCEDURE STUDENT_LOAD_MAINLINE procedure automatically run without calling it?

Thanks.
Steve
 
HI,
No Procedure runs 'on its own' - it MUST be called by something ( not just an interactive user, however)..

If it is somehow running automatically it must be being called by another proc or some trigger in the database...

Read the DBA and Concepts manuals for info on triggers or go to
and read as much of the documentation as you can stand..



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
You are very generous Turkbear, for to err is to learn and to learn is to Student and we all were Students once, some perhaps more recently than others.

Even though I am no longer a Student, I continue to learn. Some people stop learning while they are still Students.

-------------------------
The trouble with doing something right the first time is that noboby appreciates how difficult it was.
- Steven Wright
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top