<?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; PL/SQL Functions</title>
	<atom:link href="http://www.technooracle.com/oracle-tutorials/category/oracle-plsql/plsql-functions/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>PL/SQL Functions</title>
		<link>http://www.technooracle.com/oracle-tutorials/plsql-functions/</link>
		<comments>http://www.technooracle.com/oracle-tutorials/plsql-functions/#comments</comments>
		<pubDate>Tue, 29 Jun 2010 17:32:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Oracle PL/SQL]]></category>
		<category><![CDATA[PL/SQL Functions]]></category>
		<category><![CDATA[function in pl sql]]></category>
		<category><![CDATA[function pl sql]]></category>
		<category><![CDATA[functions in pl sql]]></category>
		<category><![CDATA[pl sql function example]]></category>
		<category><![CDATA[pl sql functions]]></category>

		<guid isPermaLink="false">http://www.technooracle.com/?p=106</guid>
		<description><![CDATA[A PL/SQL function is a schema object that logically groups a set of SQL and other PL/SQL programming language statements together to perform a specific task. or pl/sql functions are a pl/sql block which is named and stored in oracle database.the main difference between a stored procedure and stored function is that a stored function [...]]]></description>
			<content:encoded><![CDATA[<p>A PL/SQL function is a schema object that logically groups a set of SQL and other PL/SQL programming language statements together to perform a specific task.<br />
or<br />
pl/sql functions are a pl/sql block which is named and stored in oracle database.the main difference between a stored procedure  and stored function is that a stored function should return at least one value but a stored procedure may or may not return a value.it is used like as built in functions.<br />
<span id="more-106"></span>pl/sql functions can be invoked from sql  or pl/sql statements or from expressions functions are created in a user&#8217;s schema and stored in a<br />
database for continued use.</p>
<p>You can execute a procedure or function interactively using an Oracle tool, such as SQL*Plus, or call it explicitly in the code of a database<br />
application, such as an Oracle Forms or Precompiler application, or in the code of another procedure or trigger.</p>
<h2><strong>creating Functions in PL/SQL<br />
</strong></h2>
<p>syntax is</p>
<p>CREATE [OR REPLACE ] FUNCTION function_name<br />
[(Formal parameter1 [MODE] Data_type,<br />
(Formal parameter2 [MODE] Data_type,<br />
&#8230;..)] RETURN data_type<br />
IS | AS</p>
<p>BEGIN</p>
<p>PL/SQL Block</p>
<p>RETURN return_variable;</p>
<p>END;</p>
<p>Where</p>
<p><strong>Modes</strong></p>
<p>MODE can be IN,OUT or IN OUT.However  as per the standard,functions avoid using OUT and IN OUT parameters.The  explicit return</p>
<p>of values is done through return statements and not through out parameters.Function should return a value to the calling phase.</p>
<p><strong>Return Statment</strong></p>
<p>RETURN data_type<br />
&gt;&gt;Only type has to be specified and size specification is not allowed<br />
&gt;&gt;Can be Scalar data type or composite datatype<br />
&gt;&gt;Can Return only one value<br />
&gt;&gt;should have only one return statment in the PL/SQL block</p>
<p><strong>Example</strong></p>
<p>CREATE OR REPLACE FUNCTION get_sal_emp(v_emp_id IN number)<br />
RETURN number<br />
IS<br />
v_emp_sal number;<br />
BEGIN</p>
<p>SELECT emp_sal into v_emp_sal<br />
FROM emp    WHERE emp_id=v_emp_id;</p>
<p>RETURN v_emp_sal;</p>
<p>END;</p>
<p>Invoking the Function</p>
<p>SQL:&gt;execute:salary:=get_sal_emp(182312);</p>
<p><strong>Removing  the Function</strong></p>
<p>DROP FUNCTION function_name;</p>
<p>example</p>
<p>DROP FUNCTION get_emp_sal;</p>
<p>It will remove the stored function get_emp_sal<br />
It also remove the related data dictionary entries and contents</p>
]]></content:encoded>
			<wfw:commentRss>http://www.technooracle.com/oracle-tutorials/plsql-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

