﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-枫林的独唱-文章分类-plsql</title><link>http://www.blogjava.net/pineland/category/30826.html</link><description /><language>zh-cn</language><lastBuildDate>Tue, 15 Apr 2008 16:12:30 GMT</lastBuildDate><pubDate>Tue, 15 Apr 2008 16:12:30 GMT</pubDate><ttl>60</ttl><item><title>Object type, Record type and Collection in plsql (1)</title><link>http://www.blogjava.net/pineland/articles/193122.html</link><dc:creator>pineland</dc:creator><author>pineland</author><pubDate>Tue, 15 Apr 2008 07:50:00 GMT</pubDate><guid>http://www.blogjava.net/pineland/articles/193122.html</guid><wfw:comment>http://www.blogjava.net/pineland/comments/193122.html</wfw:comment><comments>http://www.blogjava.net/pineland/articles/193122.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/pineland/comments/commentRss/193122.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/pineland/services/trackbacks/193122.html</trackback:ping><description><![CDATA[<p>We need to set up the concenpt that the type define in sql and in plsql is differenct. Type define in sql can be referenced by plsql but not visa versa, e.g. the statement&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;"create or replace&nbsp;type My_Type&nbsp;AS&nbsp;OBJECT of &nbsp;...;"&nbsp; <br />
is creating a type in the sql level, which means both the sql and plsql can use that type. of course you can &nbsp;use that type in your table creation.<br />
<br />
On the contrast, Record is a plsql type only and you can only define it in plsql block, which as following:<br />
&nbsp;&nbsp;&nbsp;&nbsp;"declare<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type My_Type is RECORD ...&nbsp;;&nbsp;&nbsp;&nbsp; //declare record type;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;v_record My_Type&nbsp;;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//create a variable of that&nbsp;type;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type My_Type&nbsp;AS&nbsp;OBJECT of &nbsp;...;&nbsp;&nbsp;//samples here shows object can also defined in plsql,&nbsp;but that is in plsql level only<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;..........<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br />
&nbsp;&nbsp;&nbsp;&nbsp; "<br />
Since Record is plsql level only, the statement like "create or replace&nbsp;type My_Type&nbsp;is RECORD of &nbsp;...;" is always fault!</p>
<p>plsql(or maybe i&nbsp;should say oracle) has&nbsp;three kind of collections: associat tables, nested&nbsp;table and&nbsp;varray. Among them only the associate table is avaialable in&nbsp;plsql only, that means the statement&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;"create or relace type My_Type is table of .... index by binary_integer" <br />
will never compiled successfully. Also noted the oracle9i release1 only&nbsp; support binary_integer index while r2 can support varchar2, that make it closer to hast table in other programing language.</p>
<img src ="http://www.blogjava.net/pineland/aggbug/193122.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/pineland/" target="_blank">pineland</a> 2008-04-15 15:50 <a href="http://www.blogjava.net/pineland/articles/193122.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>