<?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>entwicklungsgedanken &#187; INSERT INTO ROWTYPE</title>
	<atom:link href="http://www.entwicklungsgedanken.de/tag/insert-into-rowtype/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.entwicklungsgedanken.de</link>
	<description>Verschiedene Gedanken rund um die Softwareentwicklung</description>
	<lastBuildDate>Mon, 09 Jan 2012 14:47:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>INSERT INTO via ROWTYPE</title>
		<link>http://www.entwicklungsgedanken.de/2008/01/09/insert-into-rowtype/</link>
		<comments>http://www.entwicklungsgedanken.de/2008/01/09/insert-into-rowtype/#comments</comments>
		<pubDate>Wed, 09 Jan 2008 19:51:11 +0000</pubDate>
		<dc:creator>Sven Thämar</dc:creator>
				<category><![CDATA[PL/SQL]]></category>
		<category><![CDATA[INSERT INTO ROWTYPE]]></category>

		<guid isPermaLink="false">http://www.entwicklungsgedanken.de/2008/01/09/insert-into-rowtype/</guid>
		<description><![CDATA[Allgemein Ab der Oracle Datenbank Version 9.2 ist das INSERT-Statement um eine weitere funktionalität Erweitert worden. Es ist nun möglich, an eine Insert-Anweisung, statt einzelner Felder, einen kompletten Record zu übergeben. Dieser Record muss dabei die gleiche Struktur wie die entsprechende Tabelle widerspiegeln. Jedoch dürfen dabei einzelne Felder leer bleiben. Der Vorteil dieser erweiterten funktionalität [...]]]></description>
			<content:encoded><![CDATA[<div class="lang-de"></div>
<h3>Allgemein</h3>
<p>Ab der Oracle Datenbank Version 9.2 ist das INSERT-Statement um eine weitere funktionalität Erweitert worden. Es ist nun möglich, an eine Insert-Anweisung, statt einzelner Felder, einen kompletten Record zu übergeben. Dieser Record muss dabei die gleiche Struktur wie die entsprechende Tabelle widerspiegeln. Jedoch dürfen dabei einzelne Felder leer bleiben.</p>
<p>Der Vorteil dieser erweiterten funktionalität liegt vor allem daran, wenn man ein INSERT-Statement in eine Prozedur/Funktion einbettet und einen Datensatz als Parameter übergibt. Dadurch kann die Tabelle ohne Probleme erweitert/geändert werden ohne das der Parameter angepasst werden muss. D.h die Signatur der Prozedur/Funktion bleibt unverändert.</p>
<h3>Source Code</h3>
<p>Prozedur zum einfügen eines Datensatzes via ROWTYPE.</p>

<div class="wp_syntax"><div class="code"><pre class="plsql" style="font-family:monospace;"><span style="color: #00F;">PROCEDURE</span> do_insert<span style="color: #00F;">&#40;</span>pi_rec hr<span style="color: #00F;">.</span>employees<span style="color: #00F;">%</span><span style="color: #00F;">ROWTYPE</span><span style="color: #00F;">&#41;</span> <span style="color: #00F;">IS</span> 
<span style="color: #00F;">BEGIN</span> 
   <span style="color: #00F;">INSERT</span> <span style="color: #00F;">INTO</span> hr<span style="color: #00F;">.</span>employees <span style="color: #00F;">VALUES</span> pi_rec<span style="color: #00F;">;</span> 
   <span style="color: #00F;">COMMIT</span><span style="color: #00F;">;</span> 
<span style="color: #00F;">END</span> do_insert<span style="color: #00F;">;</span></pre></div></div>

<p>Prozedur zum initialisieren der Felder.</p>

<div class="wp_syntax"><div class="code"><pre class="plsql" style="font-family:monospace;"><span style="color: #00F;">PROCEDURE</span> initialisierung <span style="color: #00F;">IS</span> 
   l_rec hr<span style="color: #00F;">.</span>employees<span style="color: #00F;">%</span><span style="color: #00F;">ROWTYPE</span><span style="color: #00F;">;</span> 
<span style="color: #00F;">BEGIN</span> 
   <span style="color: #080; font-style: italic;">-- Der Inhalt des Feldes &quot;employee_id&quot; wird durch ein INSERT-Trigger gesetzt. </span>
   <span style="color: #080; font-style: italic;">-- Die Inhalte der Felder &quot;email&quot;, &quot;phone_number&quot; und &quot;commission_pct&quot; bleiben leer. </span>
   l_rec<span style="color: #00F;">.</span>first_name <span style="color: #00F;">:=</span> <span style="color: #F00;">'Max'</span><span style="color: #00F;">;</span> 
   l_rec<span style="color: #00F;">.</span>last_name <span style="color: #00F;">:=</span> <span style="color: #F00;">'Mustermann'</span><span style="color: #00F;">;</span> 
   l_rec<span style="color: #00F;">.</span>hire_date <span style="color: #00F;">:=</span> <span style="color: #000;">SYSDATE</span><span style="color: #00F;">;</span> 
   l_rec<span style="color: #00F;">.</span>job_id <span style="color: #00F;">:=</span> <span style="color: #F00;">'IT-PROG'</span><span style="color: #00F;">;</span> 
   l_rec<span style="color: #00F;">.</span>salary <span style="color: #00F;">:=</span> <span style="color: #800;">4800</span><span style="color: #00F;">;</span> 
   l_rec<span style="color: #00F;">.</span>manager_it <span style="color: #00F;">:=</span> <span style="color: #800;">103</span><span style="color: #00F;">;</span> 
   l_rec<span style="color: #00F;">.</span>department_id <span style="color: #00F;">:=</span> <span style="color: #800;">60</span><span style="color: #00F;">;</span>  
&nbsp;
   do_insert<span style="color: #00F;">&#40;</span>l_rec<span style="color: #00F;">&#41;</span><span style="color: #00F;">;</span> 
<span style="color: #00F;">END</span> initialisierung<span style="color: #00F;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.entwicklungsgedanken.de/2008/01/09/insert-into-rowtype/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

