<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Techno Oracle &#187; Procedures in PL/SQL</title>
	<atom:link href="http://www.technooracle.com/oracle-tutorials/category/procedures-in-plsql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.technooracle.com</link>
	<description>Oracle information centre</description>
	<lastBuildDate>Tue, 17 Apr 2012 12:07:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Stored Procedures-Advanced Concepts</title>
		<link>http://www.technooracle.com/oracle-tutorials/stored-procedures-advanced-concepts/</link>
		<comments>http://www.technooracle.com/oracle-tutorials/stored-procedures-advanced-concepts/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 16:47:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Procedures in PL/SQL]]></category>

		<guid isPermaLink="false">http://www.technooracle.com/?p=105</guid>
		<description><![CDATA[Use your normal text editor to write the procedure. At the beginning of the procedure, place the command CREATE PROCEDURE procedure_name AS   ... For example, to use the example , you can create a text (source) file called get_emp.sql containing the following code: CREATE PROCEDURE procedure_name AS ... For example, to use the example , [...]]]></description>
			<content:encoded><![CDATA[<p>Use your normal text editor to write the procedure. At the beginning of the procedure, place the command</p>
<p><tt>CREATE PROCEDURE procedure_name AS   ...</tt></p>
<p>For example, to use the example , you can create a text (source) file called <em>get_emp.sql</em> containing the following code:</p>
<p><tt>CREATE PROCEDURE procedure_name AS   ...</tt></p>
<p>For example, to use the example , you can create a text (source) file called <em>get_emp.sql</em> containing the following code:</p>
<p><tt><strong>CREATE PROCEDURE get_emp_rec (emp_number  IN emp.empno%TYPE,</strong></tt></p>
<p><tt><strong> emp_ret    OUT emp%ROWTYPE) AS</strong></tt></p>
<p><tt><strong>BEGIN</strong></tt></p>
<p><tt><strong> SELECT empno, ename, job, mgr, hiredate, sal, comm, deptno</strong></tt></p>
<p><tt><strong> INTO emp_ret</strong></tt></p>
<p><tt><strong> FROM emp</strong></tt></p>
<p><tt><strong> WHERE empno = emp_number;</strong></tt></p>
<p><tt><strong>END;</strong></tt></p>
<p><span id="more-105"></span></p>
<p>Then, using an interactive too such as SQL*Plus, load the text file containing the procedure by entering the command</p>
<p><tt> <strong>SQLPLUS&gt; @get_emp</strong></tt><strong></strong></p>
<p>to load the procedure into the current schema. (.SQL is the default file extension.) Note the slash (/) at the end of the code. This is not part of the code; it just activates the loading of the procedure.</p>
<p>When developing a new procedure, it is usually much more convenient to use the CREATE OR REPLACE . . . PROCEDURE command. This replaces any previous version of that procedure in the same schema with the newer version. <strong><em>This is done with no warning.</em></strong></p>
<p>You can use either the keyword <span style="text-decoration: underline;">IS</span> or <span style="text-decoration: underline;">AS</span> after the procedure parameter list.</p>
<p><strong>Privileges Required to Create Procedures </strong></p>
<p>To create a stand-alone procedure or function, or package specification or body, you must meet the following prerequisites:</p>
<ul>
<li>You must have the <strong>CREATE PROCEDURE</strong> system      privilege to create a procedure or      package in your schema,      or the <strong>CREATE ANY PROCEDURE</strong> system privilege to create a procedure or package in another user&#8217;s      schema.</li>
</ul>
<p><strong>Attention</strong>: To create without errors, that is, to compile the procedure or package successfully, requires the following additional privileges:</p>
<p>&gt;&gt; The <strong>owner</strong> of the procedure or package must have been explicitly granted the necessary object privileges for all objects referenced within the body of the code;</p>
<p>&gt;&gt;The <strong>owner</strong> cannot have obtained required privileges through roles.</p>
<p>&gt;&gt; If the privileges of a procedure&#8217;s or package&#8217;s owner change, the procedure must be reauthenticated before it is executed.</p>
<p>&gt;&gt;If a necessary privilege to a referenced object is revoked from the owner of the procedure (or package), the procedure cannot be executed.</p>
<p>&gt;&gt;The <span style="text-decoration: underline;">EXECUTE</span> privilege on a procedure gives a user the right to execute a procedure owned by another user.</p>
<p>&gt;&gt;Privileged users execute the procedure under the security domain of the procedure&#8217;s owner.</p>
<p>&gt;&gt;Therefore, users never have to be granted the privileges to the objects referenced by a procedure.</p>
<p>&gt;&gt;This allows for more disciplined and efficient security strategies with database applications and their users.</p>
<p>&gt;&gt;Furthermore, all procedures and packages are stored in the data dictionary</p>
<p>&gt;&gt;No quota controls the amount of space available to a user who creates procedures and packages.</p>
<h3>Altering Stored Procedures</h3>
<p>To alter a stored procedure , you must:-</p>
<p>&gt;&gt;  first DROP it, using the DROP PROCEDURE  command.</p>
<p>&gt;&gt; then recreate it using the CREATE PROCEDURE command.</p>
<p>&gt;&gt;Alternatively, use the CREATE OR REPLACE PROCEDURE command, which first drops the procedure or function if it exists, then recreates it as specified.</p>
<p>&gt;&gt;  The procedure  is dropped <strong><em>with no warning.</em></strong></p>
<table style="border: 1px solid #000000; width: 100%; margin: auto;" border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td align="center"><a onclick="prev();" href="http://www.technooracle.com/oracle-tutorials/procedure-parameters/">«Prevoius Stored Procedures Parameters</a></td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.technooracle.com/oracle-tutorials/stored-procedures-advanced-concepts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stored Procedure Parameters</title>
		<link>http://www.technooracle.com/oracle-tutorials/procedure-parameters/</link>
		<comments>http://www.technooracle.com/oracle-tutorials/procedure-parameters/#comments</comments>
		<pubDate>Sun, 27 Jun 2010 20:02:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Procedures in PL/SQL]]></category>

		<guid isPermaLink="false">http://www.technooracle.com/?p=104</guid>
		<description><![CDATA[Stored procedures and functions can take parameters. The following example shows a stored procedure that is similar to the anonymous block : PROCEDURE get_emp_names (dept_num IN NUMBER) IS emp_name VARCHAR2(10); CURSOR c1 (depno NUMBER) IS SELECT ename FROM emp WHERE deptno = depno; BEGIN OPEN c1(dept_num); LOOP FETCH c1 INTO emp_name; EXIT WHEN c1%NOTFOUND; DBMS_OUTPUT.PUT_LINE(emp_name); [...]]]></description>
			<content:encoded><![CDATA[<p>Stored procedures and functions can take parameters.<br />
The following example shows a stored procedure that is similar to the anonymous block :</p>
<p><tt><strong>PROCEDURE get_emp_names (dept_num IN NUMBER) IS</strong></tt><br />
<tt><strong> emp_name       VARCHAR2(10);</strong></tt><br />
<tt><strong> CURSOR         c1 (depno NUMBER) IS</strong></tt><br />
<tt><strong> SELECT ename FROM emp</strong></tt><br />
<tt><strong> WHERE deptno = depno;<br />
BEGIN</strong></tt><br />
<tt><strong> OPEN c1(dept_num);</strong></tt><br />
<tt><strong> LOOP</strong></tt><br />
<tt><strong> FETCH c1 INTO emp_name;</strong></tt><br />
<tt><strong> EXIT WHEN c1%NOTFOUND;</strong></tt><br />
<tt><strong> DBMS_OUTPUT.PUT_LINE(emp_name);</strong></tt><br />
<tt><strong> END LOOP;</strong></tt><br />
<tt><strong> CLOSE c1;</strong></tt><br />
<tt><strong>END;</strong></tt><br />
<span id="more-104"></span><br />
In the stored procedure example, the department number is an input parameter, which is used when the parameterized cursor C1 is opened.</p>
<p>-The formal parameters of a procedure have three major parts:</p>
<p><span style="text-decoration: underline;">1)name :</span></p>
<p>The name of the parameter, which must be a legal PL/SQL identifier.</p>
<p><span style="text-decoration: underline;">2)mode :</span></p>
<p>The parameter mode, which indicates whether the parameter is an input-only parameter (IN), an output-only parameter (OUT), or is both an input and an output parameter (IN OUT). If the mode is not specified, IN is assumed.</p>
<p><span style="text-decoration: underline;">3)datatype :</span></p>
<p>The parameter datatype is a standard PL/SQL datatype.</p>
<h4>Parameter Modes</h4>
<p>-You use parameter modes to define the behavior of formal parameters.</p>
<p>-          The three parameter modes, IN (the default), OUT, and IN OUT, can be used with any subprogram.</p>
<p>-          However, avoid using the OUT and IN OUT modes with functions. The purpose of a function is to take zero or more arguments and return a single value. It is poor programming practice to have a function return multiple values. Also, functions should be free from <em>side effects</em>, which change the values of variables not local to the subprogram.</p>
<p>The following table summarizes the information about parameter modes.</p>
<table border="1" cellpadding="0">
<tbody>
<tr>
<td valign="top"><strong>IN</strong></td>
<td valign="top"><strong>OUT</strong></td>
<td valign="top"><strong>IN OUT</strong></td>
</tr>
<tr>
<td valign="top">the default</td>
<td valign="top">must be specified</td>
<td valign="top">must be specified</td>
</tr>
<tr>
<td valign="top">passes values to a subprogram</td>
<td valign="top">returns values to the caller</td>
<td valign="top">passes initial values to a   subprogram; returns updated values to the caller</td>
</tr>
<tr>
<td valign="top">formal parameter acts like a   constant</td>
<td valign="top">formal parameter acts like an   uninitialized variable</td>
<td valign="top">formal parameter acts like an   initialized variable</td>
</tr>
<tr>
<td valign="top">formal parameter cannot be   assigned a value</td>
<td valign="top">formal parameter cannot be used in   an expression; must be assigned a value</td>
<td valign="top">formal parameter should be   assigned a value</td>
</tr>
<tr>
<td valign="top">actual parameter can be a   constant, initialized variable, literal, or expression</td>
<td valign="top">actual parameter must be a   variable</td>
<td valign="top">actual parameter must be a   variable</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong><br />
</strong></p>
<h4>Parameter Datatypes</h4>
<p>The datatype of a formal parameter consists of one of the following:</p>
<ul>
<li>an <em>unconstrained</em> type name, such as NUMBER or VARCHAR2.</li>
</ul>
<ul>
<li>a      type that is constrained using the %TYPE or %ROWTYPE attributes.</li>
</ul>
<p><strong>Attention</strong>: Numerically constrained types such as NUMBER(2) or VARCHAR2(20) are not allowed in a parameter list.</p>
<p><strong>%TYPE and %ROWTYPE Attributes</strong></p>
<p>-          However, you can use the type attributes %TYPE and %ROWTYPE to constrain the parameter.</p>
<p>-           For example, the GET_EMP_NAMES procedure specification <a href="d:ORAWIN95docserverdocADG73ch7.htm#prc-getempnames"></a>could be written as</p>
<pre><tt><strong>      PROCEDURE get_emp_names(dept_num IN emp.deptno%TYPE)</strong></tt><strong> </strong></pre>
<p>-          to have the DEPT_NUM parameter take the same datatype as the DEPTNO column in the EMP table. The column and table must be available when a declaration using %TYPE (or %ROWTYPE) is elaborated.</p>
<p>-          Using %TYPE is recommended, since if the type of the column in the table changes, it is not necessary to change the application code.</p>
<p>-          If the GET_EMP_NAMES procedure is part of a package, then you can use previously-declared public (package) variables to constrain a parameter datatype. For example:<br />
<tt><strong>dept_number    number(2);</strong></tt><br />
<tt><strong>...</strong></tt><br />
<tt><strong>PROCEDURE get_emp_names(dept_num IN dept_number%TYPE);</strong></tt><strong> </strong><br />
-          You use the %ROWTYPE attribute to create a record that contains all the columns of the specified table. The following example defines the GET_EMP_REC procedure, that <em>returns all the columns of the EMP table in a PL/SQL record, for the given EMPNO: </em><br />
<tt><strong>PROCEDURE get_emp_rec (emp_number  IN emp.empno%TYPE,</strong></tt><br />
<tt><strong> emp_ret    OUT emp%ROWTYPE) IS</strong></tt><br />
<tt><strong>BEGIN</strong></tt><br />
<tt><strong> SELECT empno, ename, job, mgr, hiredate, sal, comm, deptno</strong></tt><br />
<tt><strong> INTO emp_ret</strong></tt><br />
<tt><strong> FROM emp</strong></tt><br />
<tt><strong> WHERE empno = emp_number;</strong></tt><br />
<tt><strong>END;</strong></tt><br />
<em>You could call this procedure from a PL/SQL block as follows: </em><br />
<tt> </tt><br />
<tt> </tt><br />
<tt><strong>DECLARE</strong></tt><br />
<tt><strong> emp_row      emp%ROWTYPE;     -- declare a record matching a</strong></tt><br />
<tt><strong> -- row in the EMP table</strong></tt><br />
<tt><strong>BEGIN</strong></tt><br />
<tt><strong> get_emp_rec(7499, emp_row);   -- call for emp# 7499</strong></tt><br />
<tt><strong> DBMS_OUTPUT.PUT(emp_row.ename || ' ' || emp_row.empno);</strong></tt><br />
<tt><strong> DBMS_OUTPUT.PUT(' ' || emp_row.job || ' ' || emp_row.mgr);</strong></tt><br />
<tt><strong> DBMS_OUTPUT.PUT(' ' || emp_row.hiredate || ' ' || emp_row.sal);</strong></tt><br />
<tt><strong> DBMS_OUTPUT.PUT(' ' || emp_row.comm || ' ' || emp_row.deptno);</strong></tt><br />
<tt><strong> DBMS_OUTPUT.NEW_LINE;</strong></tt><br />
<tt><strong>END;</strong></tt><br />
-          Stored functions can also return values that are declared using %ROWTYPE. For example:<br />
<tt><strong>FUNCTION get_emp_rec (dept_num IN emp.deptno%TYPE)</strong></tt><br />
<tt><strong> RETURN emp%ROWTYPE IS ...</strong></tt></p>
<h4>Tables and Records</h4>
<p>-          You can pass PL/SQL tables as parameters to stored procedures and functions.</p>
<p>-          You can also pass tables of records as parameters.</p>
<h4>Default Parameter Values</h4>
<p>-          Parameters can take default values. You use the DEFAULT keyword or the assignment operator to give a parameter a default value. For example, the specification for the GET_EMP_NAMES procedure <a href="d:ORAWIN95docserverdocADG73ch7.htm#prc-getempnames"></a>could be written as<br />
<tt><strong>PROCEDURE get_emp_names (dept_num IN NUMBER DEFAULT 20) IS ...</strong></tt><strong> </strong><br />
<strong>or as </strong><br />
<tt><strong>PROCEDURE get_emp_names (dept_num IN NUMBER := 20) IS ...</strong></tt><strong> </strong><br />
-          When a parameter takes a default value, it can be omitted from the actual parameter list when you call the procedure.</p>
<p>-           When you do specify the parameter value on the call, it overrides the default value.</p>
<h4>DECLARE Keyword</h4>
<p>-          Unlike in an anonymous PL/SQL block, you do not use the keyword DECLARE before the declarations of variables, cursors, and exceptions in a stored procedure.</p>
<p>-          In fact, it is an error to use it.</p>
<hr />
<table style="border: 1px solid #000000; width: 100%; margin: auto;" border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td align="center"><a onclick="prev();" href="http://www.technooracle.com/oracle-plsql/stored-procedures/">«Prevoius Stored Procedures</a></td>
<td align="center"><a onclick="next();" href="http://www.technooracle.com/oracle-tutorials/stored-procedures-advanced-concepts/">Stored Procedures Advanced Concepts Next»</a></td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.technooracle.com/oracle-tutorials/procedure-parameters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stored Procedures in Oracle PL/SQL</title>
		<link>http://www.technooracle.com/oracle-tutorials/stored-procedures-in-oracle/</link>
		<comments>http://www.technooracle.com/oracle-tutorials/stored-procedures-in-oracle/#comments</comments>
		<pubDate>Sun, 27 Jun 2010 15:31:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Procedures in PL/SQL]]></category>
		<category><![CDATA[stored procedure]]></category>
		<category><![CDATA[stored procedure in sql]]></category>
		<category><![CDATA[stored procedure return]]></category>
		<category><![CDATA[stored procedure sql]]></category>
		<category><![CDATA[stored procedure syntax]]></category>
		<category><![CDATA[stored procedure tutorial]]></category>
		<category><![CDATA[what is stored procedure]]></category>

		<guid isPermaLink="false">http://www.technooracle.com/?p=102</guid>
		<description><![CDATA[A procedure is a subprogram that performs a specific action . A stored procedure is a PL/SQL block that is stored in the database with a name. It is invoked using the name. Each procedure is meant for a specific purpose. A stored procedure is stored in the database as an object. It is also [...]]]></description>
			<content:encoded><![CDATA[<p>A procedure is a subprogram that performs a specific action . A stored procedure is a PL/SQL block that is stored in the database with a name. It is invoked using the name. Each procedure is meant for a specific purpose.<br />
A stored procedure is stored in the database as an object. It is also called as database procedure as it is stored in the database.</p>
<p>A procedure may take one or more parameters. If a procedure takes parameters then these parameters are to be supplied at the time of calling the procedure</p>
<p>You write procedures using the syntax :-<br />
<span id="more-102"></span><br />
<tt><strong>PROCEDURE name [(parameter[, parameter, ...])] IS</strong></tt><br />
<tt><strong> [local declarations]</strong></tt><br />
<tt><strong>BEGIN</strong></tt><br />
<tt><strong> executable statements</strong></tt><br />
<tt><strong>[EXCEPTION</strong></tt><br />
<tt><strong> exception handlers]</strong></tt><br />
<tt><strong>END [name];</strong></tt></p>
<p><strong><span style="text-decoration: none;">where :-</span></strong></p>
<p>&gt;&gt;<strong><em>parameter</em></strong> stands for the following syntax:</p>
<pre><strong><tt>parameter_name [IN | OUT | IN OUT] datatype [{:= | DEFAULT} expr]</tt> </strong></pre>
<p>&gt;&gt;You cannot impose the <strong>NOT NULL</strong> constraint on a parameter.</p>
<p>&gt;&gt;you cannot specify a constraint on the datatype. For example, the following declaration of<em> emp_id</em> is illegal:</p>
<pre><strong><tt>PROCEDURE ... (emp_id NUMBER(4)) IS  -- illegal; should be NUMBER</tt></strong></pre>
<pre><strong><tt>BEGIN ... END;</tt></strong></pre>
<p>&gt;&gt; A procedure has two parts:</p>
<p>&gt;&gt; the specification.</p>
<p><strong>&gt;&gt;</strong>the body.</p>
<h2><span style="color: #000080;"><strong>Procedure specification</strong></span></h2>
<p>&gt;&gt;begins with the keyword <strong>PROCEDURE </strong>.</p>
<p>&gt;&gt;ends with the procedure name or a parameter list.</p>
<p>&gt;&gt;Parameter declarations are optional. Procedures that take no parameters are written without parentheses.</p>
<p>&gt;&gt;The procedure body begins with the keyword IS and ends with the keyword END followed by an optional procedure name.</p>
<p><strong>&gt;&gt;</strong><strong> The procedure body has three parts:</strong></p>
<p>&gt;&gt; a declarative part.</p>
<p>&gt;&gt; an executable part.</p>
<p>&gt;&gt;and an optional exception-handling part.</p>
<p>&gt;&gt;<strong>The declarative part contains</strong>:</p>
<p>local declarations, which are placed between the keywords IS and   BEGIN.</p>
<p>The keyword DECLARE, which introduces declarations in an  anonymous PL/SQL block, is not used.</p>
<p>&gt;&gt;<strong> The executable part contains:</strong></p>
<p><strong> </strong>statements, which are placed between the keywords BEGIN and EXCEPTION (or END).</p>
<p>At least one statement must appear in the executable part of a procedure.</p>
<p>The NULL statement meets this requirement.</p>
<p>&gt;&gt; <strong> The exception-handling part contains:</strong></p>
<p>exception handlers, which are placed between the keywords EXCEPTION and END.</p>
<p><span style="color: #000080;"><strong>Example</strong> <strong>1</strong></span></p>
<p>Consider the procedure <em>raise_salary</em>, which increases the salary of an employee:</p>
<pre><tt><strong>PROCEDURE raise_salary (emp_id INTEGER, increase REAL) IS</strong></tt></pre>
<pre><tt><strong>   current_salary REAL;</strong></tt></pre>
<pre><tt><strong>   salary_missing EXCEPTION;</strong></tt></pre>
<pre><tt><strong>BEGIN</strong></tt></pre>
<pre><tt><strong>   SELECT sal INTO current_salary FROM emp</strong></tt></pre>
<pre><tt><strong>      WHERE empno = emp_id;</strong></tt></pre>
<pre><tt><strong>   IF current_salary IS NULL THEN</strong></tt></pre>
<pre><tt><strong>      RAISE salary_missing;</strong></tt></pre>
<pre><tt><strong>   ELSE</strong></tt></pre>
<pre><tt><strong>      UPDATE emp SET sal = sal + increase</strong></tt></pre>
<pre><tt><strong>         WHERE empno = emp_id;</strong></tt></pre>
<pre><tt><strong>   END IF;</strong></tt></pre>
<pre><tt><strong>EXCEPTION</strong></tt></pre>
<pre><tt><strong>   WHEN NO_DATA_FOUND THEN</strong></tt></pre>
<pre><tt><strong>      INSERT INTO emp_audit VALUES (emp_id, 'No such number');</strong></tt></pre>
<pre><tt><strong>   WHEN salary_missing THEN</strong></tt></pre>
<pre><tt><strong>      INSERT INTO emp_audit VALUES (emp_id, 'Salary is null');</strong></tt></pre>
<pre><tt><strong>END raise_salary;</strong></tt></pre>
<p><strong>When called:</strong></p>
<p>-this procedure accepts an employee number and a salary increase amount.</p>
<p>-          It uses the employee number to select the current salary from the <em>emp</em> database table.</p>
<p>-          If the employee number is not found or if the current salary is null, an exception is raised. Otherwise, the salary is updated.</p>
<p>A procedure is called as a PL/SQL statement. For example, you might call the procedure <em>raise_salary</em> as follows:</p>
<pre><tt>CALLING: raise_salary(emp_num, amount);</tt></pre>
<p><span style="color: #000080;"><strong>Example</strong> <strong>2</strong></span></p>
<p>Consider the procedure compute_stud_score, which computes the total mark and average of an student and storing into stud_score table:</p>
<pre><strong>PROCEDURE compute_stud_score (stud_id INTEGER) IS</strong></pre>
<pre><strong>mark_1     number(3);
mark_2     number(3);
mark_3     number(3);
total_mark number(4);
mark_avg   number(3);</strong></pre>
<pre><strong>BEGIN</strong></pre>
<pre><strong>SELECT mark1,mark2,mark3 INTO mark_1,mark_2,mark_3  FROM student
 WHERE student_id = stud_id;</strong></pre>
<pre><strong>total_mark:=mark_1+mark_2+mark_3;

mark_avg  =total_mark /3;
-- inserting mark and average into stud_score table</strong></pre>
<pre><strong>INSERT INTO stud_score</strong></pre>
<pre><strong>VALUES( stud_id,total_mark,mark_avg);</strong></pre>
<pre><strong>EXCEPTION</strong></pre>
<pre><strong>WHEN NO_DATA_FOUND THEN</strong></pre>
<pre><strong>  INSERT INTO stud_audit
    VALUES (stud_id, 'No such Idr');

END compute_stud_score;</strong></pre>
<hr />
<table style="border: 1px solid #000000; width: 100%; margin: auto;" border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td align="center"><a onclick="next();" href="http://www.technooracle.com/oracle-tutorials/stored-procedures-advanced-concepts/">Stored Procedures Advanced Concepts Next»</a></td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.technooracle.com/oracle-tutorials/stored-procedures-in-oracle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

