tag:blogger.com,1999:blog-42281708085305385942024-03-12T17:32:19.682-07:00Mike's PL/SQL NotesUnknownnoreply@blogger.comBlogger20125tag:blogger.com,1999:blog-4228170808530538594.post-85960320888073193832015-08-14T10:23:00.000-07:002017-10-06T12:34:32.937-07:00Limit the number of list entries that listagg will consume.<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">SQL> select student_name, course_id from studentx order by student_name</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">STUDENT_NAME COURSE_ID</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">------------ ---------</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Chris Jones A102 </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Chris Jones C102 </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Chris Jones C102 </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Chris Jones A102 </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Chris Jones A103 </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Chris Jones A103 </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Joe Rogers B103 </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Joe Rogers A222 </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Joe Rogers A222 </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Kathy Smith B102 </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Kathy Smith A102 </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Kathy Smith A103 </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Kathy Smith B102 </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Kathy Smith A103 </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Kathy Smith A102 </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Mark Robert B103 </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">16 rows selected.</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">SQL> WITH x AS</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> (SELECT student_name,</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> course_id,</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> ROW_NUMBER () OVER (PARTITION BY student_name ORDER BY 1) AS grouprownum</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> FROM studentx)</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> SELECT student_name,</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> LISTAGG (CASE WHEN grouprownum < 5 THEN course_id ELSE NULL END, ',')</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> WITHIN GROUP (ORDER BY student_name)</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> courses</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> FROM x</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">GROUP BY student_name</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">STUDENT_NAME</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">------------</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">COURSES </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">--------------------------------------------------------------------------------</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Chris Jones </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">A102,A102,C102,C102 </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Joe Rogers </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">A222,A222,B103 </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Kathy Smith </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">A102,A103,B102,B102 </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Mark Robert </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">B103 </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">4 rows selected.</span>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-4228170808530538594.post-7797562218611931552013-09-03T12:57:00.000-07:002015-12-11T08:04:50.156-08:00How to disable Firefox mixed content blocking (in one simple graphic)<div class="separator" style="clear: both; text-align: center;">
Pertains to Firefox 23.0.1 and maybe later.</div>
<div class="separator" style="clear: both; text-align: center;">
I was surprised this information was so hard to find, so hopefully this will make it easier for you.</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-iaEwwHDR_h8/UiY7FHKFNnI/AAAAAAAAAyw/YqTU1pCh4Mo/s1600/mixedcontentblockingFireFox.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="226" src="http://2.bp.blogspot.com/-iaEwwHDR_h8/UiY7FHKFNnI/AAAAAAAAAyw/YqTU1pCh4Mo/s640/mixedcontentblockingFireFox.JPG" width="640" /></a></div>
<br />
At the company I work for we have an HTTP iframe inside an HTTPS web page. The new version of Firefox objects to this mixed content and forces the user to respond by clicking on a little shield icon in order to allow the mixed content. However Firefox does not "remember" this override, nor does it allow a "white list" of domains where you don't care about mixed content. You can however disable the checking entirely by changing these options shown in the graphic above. PLEASE do not do this unless you completely understand the security implications.<br />
<br />
<span style="text-align: center;">If this is what you were looking for, please leave a comment, just say Hi or something.</span>Unknownnoreply@blogger.com41tag:blogger.com,1999:blog-4228170808530538594.post-70896785197680993002013-04-16T12:26:00.000-07:002013-09-04T11:19:57.326-07:00Windows Search (Windows 7) IS Broken - indexer quits parsing after 39kThis post has nothing to do with PL/SQL. It's about the Windows 7 search feature called "Windows Search" The bottom line is it stops indexing text files (maybe other types too) at about the 39K mark. This is NOT a problem with my set-up or configuration of Windows Search. I know this because I created a simple text file with a unique 10-digit number on each line. Those numbers which were towards the top of the file, say lines 1 thru 3414 (approximate, I don't recall the exact cut-off point) were properly indexed. I could type in any one of those numbers on the search bar and the proper file name which contained that number would be shown. Numbers towards the bottom of the text file, were NOT indexed. i.e. the Search erroneously found that no file contained that value.<br />
<br />
So, you are not going mad, it's truly broken. I searched for hours trying to find a solution, maybe a registry parameter, or something, ... but nothing. There was actually a registry parameter, but it was for the old indexer on windows XP. maxTextFilterBytes I finally gave up on trying to find a solution and instead split my files into smaller files.<br />
<br />
If anybody finds a solution, please let me know.<br />
<br />
<br />Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-4228170808530538594.post-29255740227060057812012-05-07T13:09:00.002-07:002013-01-23T12:01:44.783-08:00Convert Excel Julian date to Oracle Date datatype<br />
SQL> select to_date(to_char(2415019+<span style="color: #cc0000;">41029</span>),'J') dd from dual<br />
<br />
DD <br />
---------<br />
30-APR-12<br />
1 row selected<br />
<br />
Where 41029 is the Excel Julian Date.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4228170808530538594.post-71492582413714417412012-04-13T12:49:00.000-07:002012-04-16T11:18:33.867-07:00SQLPLUS multi-line quoted text<div>
This document demonstrates some of the problems I've encountered when using SQLPlus to insert text that has multiple lines. You can run the INSERT statements below, to demonstrate the specific problem which I state in the actual text being inserted.<br />
<br />
--Note that these problems occur only with SQLPlus, Using TOAD, (and I assume SQL Developer), there are no errors with any of the inserts.<br />
I used SQLPLus 11g client on Windows 7. Different configurations may produce different results.<br />
<br />
I'd be interested in hearing about any other anomalies you find with multi-line text.<br />
<br />
<br />
CREATE TABLE TXT (str varchar2(500));
<br />
<br />
<br />
set echo on</div>
<div>
set sqlblanklines off</div>
<div>
set define off</div>
<div>
spool multiline_text.log<br />
<br /></div>
<div>
-------- In these examples I am using Oracle 'Q' strings: aka Quoted Strings</div>
<div>
-------- For example, instead of quoting a string like this:</div>
<div>
-------- 'Joe''s Garage is where the ''action'' is'</div>
<div>
-------- I do it like this:</div>
<div>
-------- q'~Joe's Garage is where the 'action' is~'</div>
<div>
-------- In a quoted string, the character after the initial q'</div>
<div>
-------- can be any character that is not in the actual string content.</div>
<div>
-------- I've chosen to use the tilde character.</div>
<div>
<br /></div>
<div>
---------- THE BLANK LINE --------</div>
<div>
INSERT INTO txt ( str) </div>
<div>
VALUES (q'~This shows it is NOT okay to have a </div>
<div>
<br /></div>
<div>
blank line unless you 'set sqlblanklines on'.~');</div>
<div>
<br /></div>
<div>
set sqlblanklines on</div>
<div>
<br /></div>
<div>
INSERT INTO txt ( str) </div>
<div>
VALUES (q'~This shows it is okay to have a </div>
<div>
<br /></div>
<div>
blank line after you 'set sqlblanklines on'.~');</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
---------- THE SLASH CHARACTER --------</div>
<div>
<br /></div>
<div>
INSERT INTO txt ( str) </div>
<div>
VALUES (q'~This shows it is NOT okay to have a </div>
<div>
/</div>
<div>
slash by itself on a line~');</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
INSERT INTO txt ( str) </div>
<div>
VALUES (q'~This shows it is [NOT] okay to have a </div>
<div>
/ </div>
<div>
slash followed by a space character. You can't see it, but it's there.~');</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
INSERT INTO txt ( str) </div>
<div>
VALUES (q'~This shows it is okay to have a </div>
<div>
/slash as a starting character provided that the</div>
<div>
slash is [not the only] character~');</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
INSERT INTO txt ( str) </div>
<div>
VALUES (q'~This shows it is okay to have a </div>
<div>
/ slash as a starting character</div>
<div>
even if it is followed by a blank.~');</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
-----------THE DOT CHARACTER----------</div>
<div>
<br /></div>
<div>
INSERT INTO txt ( str) </div>
<div>
VALUES (q'~This shows it is [not] okay to have a </div>
<div>
.</div>
<div>
dot on a blank line by itself.~');</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
INSERT INTO txt ( str) </div>
<div>
VALUES (q'~This shows it is [not] okay to have a </div>
<div>
. </div>
<div>
dot plus some trailing blanks on a line by itself.~');</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
INSERT INTO txt ( str) </div>
<div>
VALUES (q'~This shows it is okay to have a </div>
<div>
. dot plus more text</div>
<div>
even when dot is the first character~');</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
---------THE SEMI-COLON CHARACTER ------</div>
<div>
<br /></div>
<div>
INSERT INTO txt ( str) </div>
<div>
VALUES (q'~This shows it is okay to have a; </div>
<div>
<br /></div>
<div>
blank line provided you set sqlblanklines on~');</div>
<div>
<br /></div>
<div>
INSERT INTO txt ( str) </div>
<div>
VALUES (q'~This shows it is okay to have a; plus more</div>
<div>
<br /></div>
<div>
blank line provided you set sqlblanklines on~');</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
---------THE POUND SIGN CHARACTER ------</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
INSERT INTO txt ( str) </div>
<div>
VALUES (q'~This shows it [IS] okay to have a </div>
<div>
#</div>
<div>
pound-sign on a line by itself~');</div>
<div>
<br /></div>
<div>
INSERT INTO txt ( str) </div>
<div>
VALUES (q'~This shows it is [not] okay to have a </div>
<div>
# plus more</div>
<div>
text when the pound sign is the first character~');</div>
<div>
<br /></div>
<div>
INSERT INTO txt ( str) </div>
<div>
VALUES (q'~This shows it is okay to have a </div>
<div>
a pound-sign # so long</div>
<div>
as the #is not the first character~');</div>
<div>
<br /></div>
<div>
-- ;</div>
<div>
<br /></div>
<div>
rollback;</div>
<div>
spool off</div>
<div>
--------------------------------RESULTS----------------------<br />
<br />
Microsoft Windows [Version 6.1.7601]<br />
Copyright (c) 2009 Microsoft Corporation. All rights reserved.<br />
<br />
C:\Users\mmoore>sqlplus<br />
<br />
SQL*Plus: Release 11.2.0.3.0 Production on Mon Apr 16 11:16:11 2012<br />
<br />
Copyright (c) 1982, 2011, Oracle. All rights reserved.<br />
<br />
Enter user-name: / @mydb<br />
<br />
Connected to:<br />
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production<br />
With the Partitioning, OLAP, Data Mining and Real Application Testing options<br />
<br />
SQL> set echo on<br />
SQL> set sqlblanklines off<br />
SQL> set define off<br />
SQL> spool multiline_text.log<br />
SQL><br />
SQL> -------- In these examples I am using Oracle 'Q' strings: aka Quoted Strings<br />
SQL> -------- For example, instead of quoting a string like this:<br />
SQL> -------- 'Joe''s Garage is where the ''action'' is'<br />
SQL> -------- I do it like this:<br />
SQL> -------- q'~Joe's Garage is where the 'action' is~'<br />
SQL> -------- In a quoted string, the character after the initial q'<br />
SQL> -------- can be any character that is not in the actual string content.<br />
SQL> -------- I've chosen to use the tilde character.<br />
SQL><br />
SQL> ---------- THE BLANK LINE --------<br />
SQL> INSERT INTO txt ( str)<br />
2 VALUES (q'~This shows it is NOT okay to have a<br />
3<br />
SQL> blank line unless you 'set sqlblanklines on'.~');<br />
SP2-0734: unknown command beginning "blank line..." - rest of line ignored.<br />
SQL><br />
SQL> set sqlblanklines on<br />
SQL><br />
SQL> INSERT INTO txt ( str)<br />
2 VALUES (q'~This shows it is okay to have a<br />
3<br />
4 blank line after you 'set sqlblanklines on'.~');<br />
<br />
1 row created.<br />
<br />
SQL><br />
SQL><br />
SQL> ---------- THE SLASH CHARACTER --------<br />
SQL><br />
SQL> INSERT INTO txt ( str)<br />
2 VALUES (q'~This shows it is NOT okay to have a<br />
3 /<br />
ERROR:<br />
ORA-01756: quoted string not properly terminated<br />
<br />
<br />
SQL> slash by itself on a line~');<br />
SP2-0734: unknown command beginning "slash by i..." - rest of line ignored.<br />
SQL><br />
SQL><br />
SQL> INSERT INTO txt ( str)<br />
2 VALUES (q'~This shows it is [NOT] okay to have a<br />
3 /<br />
ERROR:<br />
ORA-01756: quoted string not properly terminated<br />
<br />
<br />
SQL> slash followed by a space character. You can't see it, but it's there.~');<br />
SP2-0734: unknown command beginning "slash foll..." - rest of line ignored.<br />
SQL><br />
SQL><br />
SQL> INSERT INTO txt ( str)<br />
2 VALUES (q'~This shows it is okay to have a<br />
3 /slash as a starting character provided that the<br />
4 slash is [not the only] character~');<br />
<br />
1 row created.<br />
<br />
SQL><br />
SQL><br />
SQL> INSERT INTO txt ( str)<br />
2 VALUES (q'~This shows it is okay to have a<br />
3 / slash as a starting character<br />
4 even if it is followed by a blank.~');<br />
<br />
1 row created.<br />
<br />
SQL><br />
SQL><br />
SQL><br />
SQL> -----------THE DOT CHARACTER----------<br />
SQL><br />
SQL> INSERT INTO txt ( str)<br />
2 VALUES (q'~This shows it is [not] okay to have a<br />
3 .<br />
SQL> dot on a blank line by itself.~');<br />
SP2-0734: unknown command beginning "dot on a b..." - rest of line ignored.<br />
SQL><br />
SQL><br />
SQL> INSERT INTO txt ( str)<br />
2 VALUES (q'~This shows it is [not] okay to have a<br />
3 .<br />
SQL> dot plus some trailing blanks on a line by itself.~');<br />
SP2-0734: unknown command beginning "dot plus s..." - rest of line ignored.<br />
SQL><br />
SQL><br />
SQL> INSERT INTO txt ( str)<br />
2 VALUES (q'~This shows it is okay to have a<br />
3 . dot plus more text<br />
4 even when dot is the first character~');<br />
<br />
1 row created.<br />
<br />
SQL><br />
SQL><br />
SQL> ---------THE SEMI-COLON CHARACTER ------<br />
SQL><br />
SQL> INSERT INTO txt ( str)<br />
2 VALUES (q'~This shows it is okay to have a;<br />
ERROR:<br />
ORA-01756: quoted string not properly terminated<br />
<br />
<br />
SQL><br />
SQL> blank line provided you set sqlblanklines on~');<br />
SP2-0734: unknown command beginning "blank line..." - rest of line ignored.<br />
SQL><br />
SQL> INSERT INTO txt ( str)<br />
2 VALUES (q'~This shows it is okay to have a; plus more<br />
3<br />
4 blank line provided you set sqlblanklines on~');<br />
<br />
1 row created.<br />
<br />
SQL><br />
SQL><br />
SQL> ---------THE POUND SIGN CHARACTER ------<br />
SQL><br />
SQL><br />
SQL> INSERT INTO txt ( str)<br />
2 VALUES (q'~This shows it [IS] okay to have a<br />
3 #<br />
3 pound-sign on a line by itself~');<br />
<br />
1 row created.<br />
<br />
SQL><br />
SQL> INSERT INTO txt ( str)<br />
2 VALUES (q'~This shows it is [not] okay to have a<br />
3 # plus more<br />
SP2-0042: unknown command "plus more" - rest of line ignored.<br />
3 text when the pound sign is the first character~');<br />
<br />
1 row created.<br />
<br />
SQL><br />
SQL> INSERT INTO txt ( str)<br />
2 VALUES (q'~This shows it is okay to have a<br />
3 a pound-sign # so long<br />
4 as the #is not the first character~');<br />
<br />
1 row created.<br />
<br />
SQL><br />
SQL> -- ;<br />
SQL><br />
SQL> rollback;<br />
<br />
Rollback complete.<br />
<br />
SQL> spool off<br />
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4228170808530538594.post-67768461511936227872012-04-11T13:28:00.000-07:002012-05-22T09:55:20.762-07:00Extract from SalesForce, Load to Oracle<br />
<span style="font-family: 'Courier New', Courier, monospace;">I did it this way for 2 reasons.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;">1)These are the tools I know how to use.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;">2)There are things I am not allowed to do at work due to access rights. </span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace;">This is not intended to be a perfect document, it's just intended to be helpful.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;">No doubt, you will find problems which I did not encounter. If you do, please leave notes in the comments to help the next guy out.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace;">---------------------OVERVIEW--------------------------------------------------------</span><br />
<span style="font-family: 'Courier New', Courier, monospace;">NOTE: When I mean something literally I use the left-bracket and right-bracket</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> character like this:</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> [that's literally what "I" mean]</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace;">This is the results of dozens of failed attempts due to SQLPLUS idiosyncrasies of dealing with </span><br />
<span style="font-family: 'Courier New', Courier, monospace;">multi-line text. If you don't have multi-line text, many of the following edits won't be applicable. </span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace;">The process I use is basically</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 1) extract data from Salesforce into a file</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 2) Use Excel to format salesforce data into Oracle INSERT statements</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 3) edit all the things out of the file which SQLPLUS will find objectionable</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> and put in a few additional script commands like COMMIT</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 4) run SQLPLUS </span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace;">This document assumes that the columns you extract from SalesForce will match exactly with the Oracle</span><br />
<span style="font-family: 'Courier New', Courier, monospace;">DB table you want to load. </span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace;">Software you will need.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 1) The Salesforce Data Loader program</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 2) TextPad (get it off the web. It's the only text editor that won't screw up your files.)</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 3) Excel 2007 or later (maybe earlier versions would work too)</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 4) An Oracle database.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace;">-----------------------INSTRUCTIONS--------------------------------------------------------------- </span><br />
<span style="font-family: 'Courier New', Courier, monospace;">1) Use Salesforce Data Loader to create the extract .csv file (hence forth called 'the extract file').</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> If you don't know how to do this, Google it. There is much better documentation on this than</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> I could ever provide. </span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace;">2) At this point, I copy all of the column headers in the .cvs file and use them to create an Oracle table. </span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> I define all the columns as VARCHAR2(4000) just for ease but you can use whatever matches the data </span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> if you want.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace;">3) Use Excel to open the extract file, from step 1, and do SAVE AS sf_extract_edited.xlxs. In other words</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> immediately save it back under a new name so that you don't overwrite the extract file in step 1.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> It does not really matter what you name it but it is a good idea to include the word "edited" so that</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> you know that this is an edited version.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 3.1) Rename the first worksheet tab (at the bottom) to [raw_data]. </span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 3.2) Do a FIND on [#NAME] using the following options ... </span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 3.2.1) ctrl-f</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 3.2.2) click on [Options] button on the FIND-dialog pop-up window.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 3.2.3) for [Look in:] dropdown, choose [Values] <--IMPORTANT !</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 3.2.4) make sure the entire sheet will be searched and click on Find Next</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 3.2.5) if the find gets a hit, note that in for formula field you will</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> probably see a value that starts with [=]</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 3.2.6) on the formula field, insert a ['] before the [=] (put a single quote before the equal sign)</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> this will prevent excel from interpreting the equal sign as a formula indicator. </span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 3.2.7) repeat this process until no more hits on the FIND.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> </span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 3.3) Insert an empty column to the left of column A (this empty column will become the new column A)</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> I'm doing this so that the cells line up with the cells of the next sheet which we are going to create</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 3.4) create a new "Sheet", name the new sheet 'inserts'</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 3.5) Create an insert statement that matches the table you will be loading then </span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> position cursor at cell A2 and paste in the first part of your INSERT statement, for example:</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace;">INSERT INTO</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> ZD_OPPORTUNITY (ID, ISDELETED, ACCOUNTID, RECORDTYPEID, NAME,</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> DESCRIPTION, STAGENAME, AMOUNT, PROBABILITY, EXPECTEDREVENUE,</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> CLOSEDATE, TYPE, NEXTSTEP, LEADSOURCE, ISCLOSED, ISWON, FORECASTCATEGORY,</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> FORECASTCATEGORYNAME, HASOPPORTUNITYLINEITEM,</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> PRICEBOOK2ID, OWNERID, CREATEDDATE, CREATEDBYID, LASTMODIFIEDDATE,</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> LASTMODIFIEDBYID, SYSTEMMODSTAMP, LASTACTIVITYDATE,</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> FISCALQUARTER, FISCALYEAR, FISCAL, SPLIT_TOTAL__C) VALUES (</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 3.6) select cell B2 and enter the formula [=CONCATENATE("q'~",raw_data!B2,"~',")] without</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> the outer brackets, on the formula line</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 3.6.1) If any text has more than 4000 characters, modify the above formula for that column to be ..</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> [=CONCATENATE("q'~", MID( raw_data!N11409,1,3200),"~',")] </span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> excel and sqlplus count chars differently hence 3200 for a safe margin.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 3.7) drag the cell out to the right to cover all of the columns that have data in the raw_data sheet</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 3.8) edit the right-most cell's formula so that your INSERT statement will end with [);] and not [,]</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 3.8.1) i.e. change this: [=CONCATENATE("q'~",raw_data!CQ2,"~',")]</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> to this: [=CONCATENATE("q'~",raw_data!CQ2,"~');")]</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 3.8) select all cells of column 2 and drag down to cover all rows in the raw_data sheet</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 3.9) save your work</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 4.0) open a new (empty) file using TextPad. You can get TextPad for free trial off the internet.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 4.1) copy-paste the entire excel content of the "inserts" tab to the empty TextPad window.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 4.2) insert the following at the top of the textpad window:</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> set sqlblanklines on</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> set define off</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> spool opp.log</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 4.3) insert SPOOL OFF at the bottom</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 4.4) save and quit out of EXCEL, we won't need it any more after this.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 4.5) Save the TextPad file now, just for safety. Several edits will now need to be made to the TextPad file. </span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 4.5.1) n/a</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 4.5.2) Replace all ["INSERT] with [INSERT] i.e. remove the quote mark</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 4.5.3) Replace all [VALUES ("] with [VALUES (] i.e. remove the quote mark</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 4.5.4) This one is a little tricky and requires using a regular expression for the Replace.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> The intent is that no text line should start with a pound-sign so we are inserting a blank.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> On the Replace dialog box, put a check mark in the Regular expression option, then do</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> Replace all [^#] with [ #]</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> Now un-check Regular express option.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 4.5.6) Replace all ["q'~] with [q'~]</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 4.5.7) Replace all [~',"] with [~',] </span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 4.5.8) Replace all [);"] with [);]</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 4.5.9) Next we will change all lines that end with [;], except for ends with [');], to end with [:]</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> This is to pick up cases such as the following multi-line text example:</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> q'~A Multi-line text;</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> where a text line ends with semi-colon</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> will cause SQLPLUS to think the line has ended and you will get</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> ERROR:</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> ORA-01756: quoted string not properly terminated~'</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 1) first replace all [');] with [````]. So they won't be picked up by our next replace.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 2) then replace all [; *$] with [:] using regular expression</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> This says, If the line ends with semi-colon, or semi-colon and a bunch of spaces,</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> replace it with a colon. If it is not acceptable for you to make slight changes</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> like this, then you will have to figure something else out.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> WARNING: If you already coded COMMIT; it is now COMMIT:, go fix it. </span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 3) change all [````] back to [');]</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 4) Replace all [^/$] with [ ] using regular expression</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> SQLPLUS does not like a text line that only contains a slash.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 5) Replace all [^\.$] with [ ] using regular expression</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> SQLPLUS does not like a text line that only contains a dot.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> </span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 4.5.9) optional - remove all tab characters </span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 1) check the Hex box and replace [09] with []</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 4.5.10) Save the file and close TextPad</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> 5.0) Get into SQLPLUS and run the INSERTs you just created.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace;">One last thing, after loading the table, carefully check any columns that are supposed to have SalesForce dates. Excel sometimes turns these into Julian dates. If you end up with excel julian dates in your oracle tables, you can translate by doing:</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"></span><br />
<span style="font-family: 'Courier New', Courier, monospace;">SELECT to_date(to_char(2415019+closedate),'J') as closedate</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace;">where closeddate is the Excel julian date.</span><br />
<br />
<br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"> </span><br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><br /></span><br />
<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4228170808530538594.post-55246770984480719712008-07-08T10:35:00.000-07:002009-06-23T18:18:29.497-07:00Performing a JOIN on groups of values using nested tables<div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">-- Join on a nested table example:</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;"><br /></span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">-- this example takes 2 tables (c & d). On each table it does</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">-- a group by, and the details of that group are collected into a nested table.</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">-- tables c & d are then joined on that nested table</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;"><br /></span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">-- I probably would never do this, but I do think it is interesting.</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;"><br /></span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">--DROP TABLE D CASCADE CONSTRAINTS;</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;"><br /></span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">CREATE TABLE d (animal VARCHAR2(5 BYTE), grp NUMBER(6));</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;"><br /></span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">SET DEFINE OFF;</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;"><br /></span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">INSERT INTO d (animal, grp) VALUES ('cat', 4);</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">INSERT INTO d (animal, grp) VALUES ('cat', 7);</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">INSERT INTO d (animal, grp) VALUES ('toad', 7);</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">INSERT INTO d (animal, grp) VALUES ('frog', 4);</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">INSERT INTO d (animal, grp) VALUES ('frog', 7);</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">COMMIT ;</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;"><br /></span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">-- DROP TABLE c CASCADE CONSTRAINTS;</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;"><br /></span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">CREATE TABLE c( animal VARCHAR2(5 BYTE), grp NUMBER(6));</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;"><br /></span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">SET DEFINE OFF;</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">INSERT INTO c (animal, grp) VALUES ('cat', 1);</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">INSERT INTO c (animal, grp) VALUES ('frog', 1);</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">INSERT INTO c (animal, grp) VALUES ('frog', 66);</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">INSERT INTO c (animal, grp) VALUES ('cat', 33);</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">INSERT INTO c (animal, grp) VALUES ('cat', 44);</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">INSERT INTO c (animal, grp) VALUES ('cat', 66);</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">INSERT INTO c (animal, grp) VALUES ('frog', 44);</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">INSERT INTO c (animal, grp) VALUES ('toad', 44);</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">COMMIT ;</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;"><br /></span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">SELECT grp, animal FROM c ORDER BY grp, animal;</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">SELECT grp, animal FROM d ORDER BY grp, animal;</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;"><br /></span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">CREATE OR REPLACE TYPE string20_table IS TABLE OF VARCHAR2(20);</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;"><br /></span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">DECLARE</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;"> mystr VARCHAR2(80);</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">BEGIN</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;"> FOR cur1 IN </span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;"> (SELECT *</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;"> FROM (SELECT grp grp1, CAST(COLLECT(animal) AS string20_table) tab1</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;"> FROM c GROUP BY grp)</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;"> JOIN</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;"> (SELECT grp grp2, CAST(COLLECT(animal) AS string20_table) tab2</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;"> FROM d GROUP BY grp) </span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;"> ON tab1 = tab2</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;"> )</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;"> LOOP</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;"> DBMS_OUTPUT.put_line( TO_CHAR(cur1.grp1)</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;"> || '='</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;"> || TO_CHAR(cur1.grp2));</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;"> END LOOP;</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">END;</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">-- final output</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">-- 1=4</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">-- 44=7</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">-- 66=4</span></span></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4228170808530538594.post-85468098094521246122007-10-23T10:15:00.000-07:002007-10-23T10:27:01.528-07:00SELECT as many rows as indicated by column value<span style="font-family:courier new;">This select statement will return as many rows as are indicated by the value of a column. For example, if the column value is 7, then 7 copies of that row will be returned.<br /><br /><span style="font-size:78%;"><br /></span><span style="font-size:78%;">CREATE TABLE S</span></span><span style="font-size:78%;"><br /><span style="font-family:courier new;">(</span><br /><span style="font-family:courier new;"> RNUM NUMBER,</span><br /><span style="font-family:courier new;"> TPART CHAR(10),</span><br /><span style="font-family:courier new;"> SQ NUMBER</span><br /><span style="font-family:courier new;">)</span><br /><span style="font-family:courier new;">;</span><br /></span><span style="font-size:78%;"><br /></span><span style="font-size:78%;"><span style="font-family:courier new;">Insert into S</span><br /><span style="font-family:courier new;"> (RNUM, TPART, SQ)</span><br /><span style="font-family:courier new;"> Values</span><br /><span style="font-family:courier new;"> (101, 'TEST_PART1', 1);</span><br /><span style="font-family:courier new;">Insert into S</span><br /><span style="font-family:courier new;"> (RNUM, TPART, SQ)</span><br /><span style="font-family:courier new;"> Values</span><br /><span style="font-family:courier new;"> (102, 'TEST_PART2', 2);</span><br /><span style="font-family:courier new;">Insert into S</span><br /><span style="font-family:courier new;"> (RNUM, TPART, SQ)</span><br /><span style="font-family:courier new;"> Values</span><br /><span style="font-family:courier new;"> (103, 'TEST_PART3', 3);</span><br /><span style="font-family:courier new;">Insert into S</span><br /><span style="font-family:courier new;"> (RNUM, TPART, SQ)</span><br /><span style="font-family:courier new;"> Values</span><br /><span style="font-family:courier new;"> (105, 'TEST_PART5', 5);</span><br /><span style="font-family:courier new;">COMMIT;</span></span><br /><br /><span style="font-family:courier new;">SELECT rnum, tpart, sq</span><br /><span style="font-family:courier new;"> FROM s s_alias, TABLE(SELECT COLLECT(dummy)</span><br /><span style="font-family:courier new;"> FROM DUAL</span><br /><span style="font-family:courier new;"> CONNECT BY LEVEL <= s_alias.sq);</span>Unknownnoreply@blogger.com3tag:blogger.com,1999:blog-4228170808530538594.post-48975511196620802062007-10-12T14:12:00.000-07:002007-10-19T14:31:30.387-07:00ORA-06502: PL/SQL: numeric or value error: host bind array too small<span style=";font-family:Arial;font-size:85%;color:navy;" ><span style=";font-family:Arial;font-size:10;color:navy;" ><span style="font-size:130%;">ORA-06502: PL/SQL: numeric or value error: host bind array too small</span><o:p><br /><br />With 10gR2 dbms_output has been improved to handle more that 255 characters. I ran into this problem when I forgot to consider that it is the <span style="font-style: italic;">CLIENT</span> ( not necessiarily the db server) that must be 10gR2. The PL/SQL procedure would run fine for me because I happened to have the 10gR2 client installed on my PC. Our QA had an older version of the client and kept running into this ora-06502.<br /><br />So, it's probably not a good idea to drop those string chunking procedures until you are sure that everybody is off of the older clients.<br /><br /></o:p></span></span>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-4228170808530538594.post-60097824870872409072007-10-06T16:40:00.000-07:002007-10-06T16:48:42.408-07:00 <div class="Section1"> <h2>Incremental elimination using predicate negation</h2> <p><span style="font-family:Arial">Application requirements sometimes include the need to match consumers with products. A common solution is to create a consumer table having a varchar2 column which will contain a string of predicates or a <i><span style="font-family:Arial">where clause</span></i>. The consumer’s <i><span style="font-family:Arial">where clause</span></i> is tested against the attributes of a product. The process of matching might be implemented in any of the following modes:</span></p> <ul type="disc"> <li class="MsoNormal" style="color:maroon"><span style="font-family:Arial">Tell me if this consumer matches this product</span></li> <li class="MsoNormal" style="color:maroon"><span style="font-family:Arial">Tell me all of the consumers that match this product</span></li> <li class="MsoNormal" style="color:maroon"><span style="font-family:Arial">Tell me all of the products that match this consumer</span></li> </ul> <p><span style="font-family:Arial">In any case, if the <i><span style="font-family:Arial">where clause</span></i> evaluation results in TRUE, the matching row will be returned in the result set. In other words the steps are;</span></p> <ul type="disc"> <li class="MsoNormal" style="color:maroon"><span style="font-family:Arial">execute a SELECT statement containing the consumer’s <i><span style="font-family:Arial">where clause</span></i> </span></li> <li class="MsoNormal" style="color:maroon"><span style="font-family:Arial">determine FOUND or NOT FOUND </span></li> <li class="MsoNormal" style="color:maroon"><span style="font-family:Arial">and if FOUND, consider it to be a match</span></li> </ul> <p><span style="font-family:Arial">This approach works fine in some situations, but what if the product is built gradually over a period of time? For example, assume we have an adoption agency for children. The child is the product. The Prakesh family ( the consumer ) is waiting to receive a child, but they have a set of <i><span style="font-family:Arial">‘child matching’</span></i> requirements which we have expressed as a <i><span style="font-family:Arial">where clause</span></i>. It looks like this:</span></p> <pre><span style="font-size:12.0pt;font-family:Arial;color:maroon">(ths = 'N' and hair_color = 'blond' and autosomal_recessive = 'No')</span></pre> <p><span style="font-family:Arial">Now babyX is born bald as a billiard ball, so we don’t yet know the hair_color. The results of the THS test will be known in one week and the autosomal_recessive test in 2 weeks. The Prakesh family thinks that babyX might be right for them but they won’t know for sure until all of the child data is available. A few days passes and babyX has enough fuzz on her head to see that she has blond hair. So, we have one piece of data, and this one piece of data has the potential to eliminate the Prakesh family as parents of babyX. In the database we have a record for babyX that looks like</span></p> <table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="margin-left:32.15pt;border-collapse:collapse;border:none"> <tr style="height:11.65pt"> <td style="width:71.25pt;border:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;height:11.65pt" valign="top" width="95"> <p><b><span style="font-size:10.0pt">Baby_ID</span></b></p> </td> <td style="width:71.25pt;border:solid windowtext 1.0pt;border-left:none;padding:0in 5.4pt 0in 5.4pt;height:11.65pt" valign="top" width="95"> <p><b><span style="font-size:10.0pt">THS</span></b></p> </td> <td style="width:112.2pt;border:solid windowtext 1.0pt;border-left:none;padding:0in 5.4pt 0in 5.4pt;height:11.65pt" valign="top" width="150"> <p><b><span style="font-size:10.0pt">Hair Color</span></b></p> </td> <td style="width:135.75pt;border:solid windowtext 1.0pt;border-left:none;padding:0in 5.4pt 0in 5.4pt;height:11.65pt" valign="top" width="181"> <p><b><span style="font-size:10.0pt">Autosomal Recessive</span></b></p> </td> </tr> <tr style="height:9.85pt"> <td style="width:71.25pt;border:solid windowtext 1.0pt;border-top:none;padding:0in 5.4pt 0in 5.4pt;height:9.85pt" valign="top" width="95"> <p><span style="font-size:10.0pt">123</span></p> </td> <td style="width:71.25pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;height:9.85pt" valign="top" width="95"> <p><span style="font-size:10.0pt"> </span></p> </td> <td style="width:112.2pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;height:9.85pt" valign="top" width="150"> <p><span style="font-size:10.0pt">blond</span></p> </td> <td style="width:135.75pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;height:9.85pt" valign="top" width="181"> <p><span style="font-size:10.0pt"> </span></p> </td> </tr> </table> <p><span style="font-family:Arial">We want to see if our new data value for hair color eliminates the Prakesh family as candidates for babyX, so we build our SELECT statement like this</span>:</p> <p><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">SELECT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'matched'</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">FROM</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> TbaBy<br> </span><span class="GramE"><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">WHERE</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> Baby</span></span><span style="font-size:10.0pt;font-family:"Courier New";color:black">_Id </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">123</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">AND</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> ths </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'N'</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">AND</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> Hair_Color </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'blond'</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">AND</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> AutoSoMal_Recessive </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'No'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span></p> <p><span style="font-family:Arial">Of course, the result will be no match. The problem is clear; if we are going to apply the <i>where_clause</i> <b><span style="font-family:Arial">before</span></b> all of the data is gathered, then we need to allow for NULL values in our where clause. We-code the where_clause so that it looks like this:</span></p> <p><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">SELECT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'matched'</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">FROM</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> TbaBy<br> </span><span class="GramE"><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">WHERE</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span></span><span style="font-size:10.0pt;font-family:"Courier New";color:black">ths </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'N'</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">OR</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> ths </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IS</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">NULL</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">AND</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">Hair_Color </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'blond'</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">OR</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> Hair_Color </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IS</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">NULL</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">AND</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">AutoSoMal_Recessive </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'No'</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">OR</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> AutoSoMal_Recessive </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IS</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">NULL</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span></p> <p class="MsoNormal"><span style="font-family:Arial">Now, given this new where clause, as soon as a new data item is written to the baby record, we can run the where clause each time we receive more data on the baby .and we will be able to tell the Prakesh family the moment that any one of their criteria is not met.</span></p> <p class="MsoNormal"><span style="font-family:Arial">In essence, by adding the “or is null” to the where_clause, we have changed the question from</span></p> <ul style="margin-top:0in" type="disc"> <li class="MsoNormal"><b><span style="font-family:Arial">Does this baby match these parents?</span></b><span style="font-family:Arial"><br> to</span></li> <li class="MsoNormal"><b><span style="font-family:Arial">Does this baby NOT match these parents?</span></b></li> </ul> <p class="MsoNormal"><span style="font-family:Arial">Adding the IS NULL test is simple as long as either the left-hand side predicate or the right-hand side predicate is a constant. It becomes a little trickier when both left-hand and right-hand sides are both variables.</span></p> <h3>Using the predicate negation technique</h3> <p class="MsoNormal"><span style="font-family:Arial">Predicate negation reverses the logic of the where clause so that any row that would not be returned is now returned and visa versa.</span></p> <table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse:collapse;border:none"> <tr style="height:3.0in"> <td style="width:351.0pt;border:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;height:3.0in" valign="top" width="468"> <address style="margin-left:3.45pt"><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">CREATE</span> <span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">TABLE</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"> PRODUCT<br> </span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"><br> PRODID </span><span style="font-size:8.0pt;font-family:"Courier New";color:red">NUMBER</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:8.0pt;font-family:"Courier New";color:maroon">5</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">),</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"><br> PRODSIZE </span><span style="font-size:8.0pt;font-family:"Courier New";color:red">INTEGER</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"><br> COLOR </span><span style="font-size:8.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:8.0pt;font-family:"Courier New";color:maroon">10</span> <span style="font-size:8.0pt;font-family:"Courier New";color:red">BYTE</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">),</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"><br> FABRIC </span><span style="font-size:8.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:8.0pt;font-family:"Courier New";color:maroon">10</span> <span style="font-size:8.0pt;font-family:"Courier New";color:red">BYTE</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">),</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">CONSTRAINT</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"> PRODUCT_PK<br> </span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">PRIMARY</span> <span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">KEY</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:8.0pt;font-family:"Courier New";color:black">PRODID</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">SET</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"> DEFINE </span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">OFF;</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">INSERT</span> <span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">INTO</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"> PRODUCT </span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:8.0pt;font-family:"Courier New";color:black">PRODID</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"> PRODSIZE</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"> COLOR</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"> FABRIC</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">VALUES</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"> </span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:8.0pt;font-family:"Courier New";color:maroon">10</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:8.0pt;font-family:"Courier New";color:maroon">14</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">NULL,</span> <span style="font-size:8.0pt;font-family:"Courier New";color:red">'cotton'</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">INSERT</span> <span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">INTO</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"> PRODUCT </span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:8.0pt;font-family:"Courier New";color:black">PRODID</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"> PRODSIZE</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"> COLOR</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"> FABRIC</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">VALUES</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"> </span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:8.0pt;font-family:"Courier New";color:maroon">20</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:8.0pt;font-family:"Courier New";color:maroon">14</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:8.0pt;font-family:"Courier New";color:red">'red'</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:8.0pt;font-family:"Courier New";color:red">'wool'</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">INSERT</span> <span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">INTO</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"> PRODUCT </span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:8.0pt;font-family:"Courier New";color:black">PRODID</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"> PRODSIZE</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"> COLOR</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"> FABRIC</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">VALUES</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"> </span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:8.0pt;font-family:"Courier New";color:maroon">30</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:8.0pt;font-family:"Courier New";color:maroon">15</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:8.0pt;font-family:"Courier New";color:red">'white'</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:8.0pt;font-family:"Courier New";color:red">'cotton'</span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:8.0pt;font-family:"Courier New";color:#0000F0">COMMIT;</span><span style="font-size:8.0pt;font-family:"Courier New";color:black"><br> <br> </span></address> </td> </tr> </table> <address><span style="font-family:"Courier New";color:black"> </span></address> <address><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- <span class="GramE">the</span> following selects assumes that all attribute</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- values have been provided ( no nulls ). A NULL value in any of the criteria</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- will result in no_data_found, hence no match.</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">SELECT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">*</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">FROM</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> Product<br> </span><span class="GramE"><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">WHERE</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> ProdSize</span></span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">14</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">AND</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">((</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">Color </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'red'</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">AND</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> Fabric </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'cotton'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">OR</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">Fabric </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'wool'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">));</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- by reversing the logic of the where clause and reversing</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- the interpretation of FOUND vs NOT FOUND, NULL values will not</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- be considered a reason for rejecting a match. If a record is returned</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- it means the product does not match the criteria.</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">SELECT</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> ProdId<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">FROM</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> Product<br> </span><span class="GramE"><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">WHERE</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span></span><span style="font-size:10.0pt;font-family:"Courier New";color:black">ProdSize </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">!=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">14</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">OR</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">((</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">Color </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">!=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'red'</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">OR</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> Fabric </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">!=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'cotton'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">AND</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">Fabric </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">!=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'wool'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)));</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- to prove that the result is the inverse of the prior result</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- we anti join to the complete table.</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">SELECT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">*</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">FROM</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> Product<br> </span><span class="GramE"><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">WHERE</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> ProdId</span></span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">NOT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(SELECT</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> ProdId<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">FROM</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> Product<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">WHERE</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">ProdSize </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">!=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">14</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">OR</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">((</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">Color </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">!=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'red'</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">OR</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> Fabric </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">!=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'cotton'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">AND</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">Fabric </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">!=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'wool'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">))));</span><span style="font-size:10.0pt;font-family:"Courier New""><br> <br> </span></address> <p class="MsoNormal"><span style="font-family:Arial">Predicate negation can be accomplished by changing</span></p> <address> </address> <table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="margin-left:32.15pt;border-collapse:collapse;border:none"> <tr style="height:99.0pt"> <td style="width:192.45pt;border:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;height:99.0pt" valign="top" width="257"> <address style="margin-left:3.45pt">OR into AND<br> = into !=<br> > into <=<br> < into >=<br> IN into NOT IN<br> BETWEEN into NOT BETWEEN<br> AND into OR</address> </td> </tr> </table> <address><br> <span style="font-family:Arial">To learn more about the formal rules of predicate negation see </span></address> <p><a href="http://wikipedia.org/wiki/De_Morgan's_theorem">De_Morgan’s theorem</a></p> <p class="MsoNormal"> </p> </div> Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-4228170808530538594.post-46316277354402172782007-10-06T13:22:00.000-07:002007-10-06T13:26:25.742-07:00 <div class="Section1"> <p class="MsoNormal"><span class="Heading2Char"><span style="font-size:14.0pt">This code will generate a list of integers from 1 to 50</span></span> <br> <i><span style="color:#333399">10g and above</span></i> </p> <p class="MsoNormal"> </p> <p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">SELECT</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> mynum<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">FROM</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(SELECT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">1</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> mynum </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">FROM</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> dual</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">MODEL</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">DIMENSION</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">BY</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">mynum </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">MEASURES</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:red">'mynote'</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">AS</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> note</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">RULES</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">note</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">[FOR</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> mynum </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">FROM</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">1</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">TO</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">50</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INCREMENT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">1</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">]</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">''</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">ORDER</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">BY</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> mynum</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-family:"Courier New""><br> </span><span style="font-size:13.5pt;font-family:Georgia">This code will also generate a list of integers from 1 to 50;</span><br> <i><span style="color:#333399">8i and above</span></i><br> <br> SELECT LEVEL num<br> FROM Dual<br> CONNECT BY LEVEL <= 50;<br> If you want to use either of these examples, make sure you test the performance. The MODEL example may be quite costly when generating very long sequences. The only advantage to the MODEL example is that it is ANSII compliant. The following example illustrates that point.<br> <br> <span style="color:#993300">Connected.<br> SQL> alter session set FLAGGER = FULL<span class="GramE">;</span><br> Session altered.<br> SQL> SELECT mynum<br> 2 FROM (SELECT 1 mynum FROM dual)<br> 3 MODEL<br> 4 DIMENSION BY (mynum )<br> 5 MEASURES ('mynote' as note)<br> 6 RULES (note[FOR mynum FROM 1 to 5 INCREMENT 1] = '' )<br> 7 ORDER BY mynum;<br> MYNUM<br> ———-<br> 1<br> 2<br> 3<br> 4<br> 5<br> SQL> SELECT LEVEL num<br> 2 FROM Dual<br> 3 CONNECT BY LEVEL <= 5;<br> CONNECT BY LEVEL <= 5<br> *<br> ERROR at line 3:<br> ORA-00097: use of Oracle SQL feature not in SQL92 Full Level<br> ORA-06550: line 4, column 1:<br> PLS-01425: Connect-by clause</span><br> <br> <br> </p> </div> Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4228170808530538594.post-3496561326429618412007-10-06T11:53:00.001-07:002007-10-06T12:39:42.959-07:00 <div class="Section1"> <p><span class="Heading2Char"><span style="font-size:14.0pt">Powermultiset to find combinations</span></span></p> <h3>Part 1 of 2</h3> <p>This article consists of a statement of the problem to be solved, and then walks through the steps of solving it. There could be mistakes. There could be a better way to do this. Hopefully the reader can find some benefit regardless of the imperfections.<br> <br> <span class="Heading3Char"><span style="font-size:13.5pt">Statement of the Problem</span></span><br> Each department has <span class="GramE">it’s</span> own products. Each product has a price.<br> The SQL query in this example answers the question<span class="GramE">:</span><br> Given that a customer can purchase, from a single department, any number of products, but not more than one of a specific product, what are the possible dollar amounts that the customer could potentially pay.<br> <span style="font-size:10.0pt;font-family:"Courier New""><br> <code>For example, Department 1 has 3 products<span class="GramE">:</span></code><br> <br> </span><span style="font-size:10.0pt;font-family:Courier;color:maroon">product 1 cost $3<br> product 2 cost $5<br> product 3 cost $2</span><span style="font-size:10.0pt;font-family:"Courier New""><br> <br> <code>A customer of Department 1 could purchase one of the following 7 combinations.</code><br> <br> </span><span style="font-size:10.0pt;font-family:Courier;color:maroon">1. <span class="GramE">product</span> 1 - cost = $3<br> 2. <span class="GramE">product</span> 2 - cost = $5<br> 3. <span class="GramE">product</span> 3 - cost = $2<br> 4. <span class="GramE">product</span> 1 and product 2 - total cost = $8<br> 5. <span class="GramE">product</span> 1 and product 3 - total cost = $5<br> 6. <span class="GramE">product</span> 2 and product 3 - total cost = $7<br> 7. product 1 and product 2 and product 3 - total cost = $10</span><span style="font-size:10.0pt;font-family:"Courier New""><br> <br> <code>So, given this data the answer would be (2,3,5,8,7 and 10)</code><br> <br> </span><span style="font-size:7.5pt;font-family:"Courier New""><br> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">CREATE</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">TABLE</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> DEMO<br> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"><br> DEPARTMENT </span><span style="font-size:8.0pt;font-family:Courier;color:red;background:white">NUMBER</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">3</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">)</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">NOT</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">NULL,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"><br> PRODUCT </span><span style="font-size:8.0pt;font-family:Courier;color:red;background:white">NUMBER</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">NOT</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">NULL,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"><br> UNIT_PRICE </span><span style="font-size:8.0pt;font-family:Courier;color:red;background:white">NUMBER</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">8</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">2</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">)</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">NOT</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">NULL</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">);</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"><br> <br> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">SET</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">DEFINE</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">OFF;</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Insert</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">into</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> DEMO </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white">DEPARTMENT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> PRODUCT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> UNIT_PRICE</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">)</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Values</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">1</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">10</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">1200</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">);</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Insert</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">into</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> DEMO </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white">DEPARTMENT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> PRODUCT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> UNIT_PRICE</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">)</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Values</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">2</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">22</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">99</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">);</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Insert</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">into</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> DEMO </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white">DEPARTMENT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> PRODUCT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> UNIT_PRICE</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">)</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Values</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">2</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">23</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">50</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">);</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Insert</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">into</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> DEMO </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white">DEPARTMENT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> PRODUCT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> UNIT_PRICE</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">)</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Values</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">2</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">24</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">101</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">);</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Insert</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">into</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> DEMO </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white">DEPARTMENT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> PRODUCT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> UNIT_PRICE</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">)</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Values</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">2</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">25</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">150</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">);</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Insert</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">into</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> DEMO </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white">DEPARTMENT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> PRODUCT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> UNIT_PRICE</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">)</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Values</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">3</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">30</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">1999</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">);</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Insert</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">into</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> DEMO </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white">DEPARTMENT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> PRODUCT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> UNIT_PRICE</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">)</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Values</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">4</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">41</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">500</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">);</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Insert</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">into</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> DEMO </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white">DEPARTMENT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> PRODUCT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> UNIT_PRICE</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">)</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Values</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">4</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">45</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">250</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">);</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Insert</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">into</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> DEMO </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white">DEPARTMENT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> PRODUCT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> UNIT_PRICE</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">)</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Values</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">5</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">56</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">40</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">);</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Insert</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">into</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> DEMO </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white">DEPARTMENT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> PRODUCT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> UNIT_PRICE</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">)</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Values</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">6</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">63</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">250</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">);</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Insert</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">into</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> DEMO </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white">DEPARTMENT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> PRODUCT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> UNIT_PRICE</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">)</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Values</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">7</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">77</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">1200</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">);</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Insert</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">into</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> DEMO </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white">DEPARTMENT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> PRODUCT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> UNIT_PRICE</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">)</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Values</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">7</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">73</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">50</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">);</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Insert</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">into</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> DEMO </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white">DEPARTMENT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> PRODUCT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> UNIT_PRICE</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">)</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Values</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">8</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">81</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">40</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">);</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Insert</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">into</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> DEMO </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white">DEPARTMENT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> PRODUCT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> UNIT_PRICE</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">)</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Values</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">9</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">91</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">200</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">);</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Insert</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">into</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> DEMO </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white">DEPARTMENT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> PRODUCT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> UNIT_PRICE</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">)</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Values</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">9</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">94</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">250</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">);</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Insert</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">into</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> DEMO </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white">DEPARTMENT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> PRODUCT</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> UNIT_PRICE</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">)</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">Values</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">10</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">77</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:8.0pt;font-family:Courier;color:maroon;background:white">500</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">);</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">COMMIT;</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"><br> <br> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">CREATE</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">OR</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">REPLACE</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">type</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> demo_prod_typ </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">as</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">object(</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"><br> department </span><span style="font-size:8.0pt;font-family:Courier;color:red;background:white">integer</span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"><br> product </span><span style="font-size:8.0pt;font-family:Courier;color:red;background:white">integer</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">)</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">/</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"><br> <br> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">CREATE</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">OR</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">REPLACE</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">type</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> demo_prod_tab_typ </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">as</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">table</span> <span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">of</span><span style="font-size:8.0pt;font-family:Courier;color:black;background:white"> demo_prod_typ<br> </span><span style="font-size:8.0pt;font-family:Courier;color:blue;background:white">/</span><span style="font-size:10.0pt;font-family:"Courier New""><br> <br> </span>In the HTML tables in this example were generated from SQLPlus using the<i> set mark html on</i> command. I used SQLPLUS because it has some useful pretty printing features. Specifically, when the output column is a nested table, SQLPlus will display the entire structure as a string. When you encounter examples of output data that look like this “DEMO_PROD_TAB_<span class="GramE">TYP(</span>DEMO_PROD_TYP(1, 10))”, you should understand that this is not the actual data. Instead, this is SQLPlus’s way of telling you that - the content of this column is a nested table named DEMO_PRD_TAB and that table contains a single object named DEMO_PROD_TYP and the object contains 2 variables which have the values of 1 and 10. If you look at the HTML table’s header for this column it will say “<span class="GramE">OID(</span>DEPARTMENT, PRODUCT). This tells you that 1 represents a department and 10 <span class="GramE">represents</span> a product.<br> <b>The final solution is shown at the bottom of this article.</b> You might want to take a look so that you can understand the context of the sub queries as I work my way from the inner most select to the outer select.<br> <br> <span class="GramE">SELECT department</span>, CAST<br> ( COLLECT ( demo_prod_typ ( department<br> , product ) ) AS demo_prod_tab_typ )<br> OID<br> FROM demo<br> GROUP BY department<br> <br> The innermost sub-query is shown above. In order to get the desired final result set, we will need to use the powermultiset function. This function operates on a table of objects, so we know that we first need to create these collections. We will have one collection per each grouping of department. COLLECT is <span class="GramE">a</span> aggregating function just like MAX and MIN in so much as they produce a single result per group. The COLLECT will result in a single nested table of demo_product_typ per department. However, the table that contains these objects will be system defined. The name of the table will be something like SYSTPL16fhcAkBaDgQAEKXAp4Gg. The powermultiset function will not be able use these ’system named’ nested tables unless we first CAST them to a type that powermultiset “knows” about. The result of this SELECT is shown below.</p> <table border="0" cellpadding="0" cellspacing="0" class="MsoTable3DFx3" style="width:68.0%;border-collapse:collapse" width="68%"> <tr> <td style="width:7.46%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="7%"> <p align="center" class="MsoNormal" style="text-align:center"><b><span style="font-size:8.0pt;font-family:"Courier New"">DEPAR TMENT</span></b></p> </td> <td style="width:91.74%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="91%"> <p align="center" class="MsoNormal" style="text-align:center"><b><span style="font-size:8.0pt;font-family:"Courier New"">OID(DEPARTMENT, PRODUCT)</span></b></p> </td> </tr> <tr> <td style="width:7.46%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="7%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">1</span></p> </td> <td style="width:91.74%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="91%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(1, 10))</span></p> </td> </tr> <tr> <td style="width:7.46%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="7%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:91.74%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="91%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2,22),DEMO_PROD_TYP(2,24),DEMO_PROD_TYP(2,25),DEMO_PROD_TYP(2,23))</span></p> </td> </tr> <tr> <td style="width:7.46%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="7%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">3</span></p> </td> <td style="width:91.74%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="91%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(3, 30))</span></p> </td> </tr> <tr> <td style="width:7.46%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="7%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">4</span></p> </td> <td style="width:91.74%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="91%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(4, 41), DEMO_PROD_TYP(4, 45))</span></p> </td> </tr> <tr> <td style="width:7.46%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="7%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">5</span></p> </td> <td style="width:91.74%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="91%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(5, 56))</span></p> </td> </tr> <tr> <td style="width:7.46%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="7%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">6</span></p> </td> <td style="width:91.74%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="91%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(6, 63))</span></p> </td> </tr> <tr> <td style="width:7.46%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="7%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">7</span></p> </td> <td style="width:91.74%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="91%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(7, 77), DEMO_PROD_TYP(7, 73))</span></p> </td> </tr> <tr> <td style="width:7.46%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="7%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">8</span></p> </td> <td style="width:91.74%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="91%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(8, 81))</span></p> </td> </tr> <tr> <td style="width:7.46%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="7%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">9</span></p> </td> <td style="width:91.74%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="91%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(9, 91), DEMO_PROD_TYP(9, 94))</span></p> </td> </tr> <tr> <td style="width:7.46%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="7%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">10</span></p> </td> <td style="width:91.74%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="91%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(10, 77))</span></p> </td> </tr> </table> <p>10 rows selected.</p> <p><br> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">SELECT</span> <span class="GramE"><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">VALUE(</span></span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">t2</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">)</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> xx</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> t3</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">.</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">department department_t3</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> t3</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">.</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">product product_t3<br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">FROM</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(SELECT</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> department</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">CAST</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(COLLECT(</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">demo_prod_typ</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">department</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> product</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">))</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">AS</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> demo_prod_tab_typ</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">)</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">OID</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">FROM</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> demo<br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">GROUP</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">BY</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> department</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">)</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> t1</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">TABLE(POWERMULTISET(</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">t1</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">.OID))</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> t2</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">;</span></p> <p><br> <br> Now, having constructed and identified our nested tables, we are ready for POWERMULTISET to do <span class="GramE">it’s</span> magic. But first, let’s talk about the JOIN in the above SELECT statement. You can see that the outer select is joining 3 tables; the first table is defined by a sub query and named t1. The second and third tables are the results of a TABLE functions and named t2 and t3 respectively. Unless you are already familiar with this type of join, you might falsely conclude that this is a 3 way Cartesian join because no join criteria have been defined. Instead, this is called a left correlated join and this specific join does goes like this<span class="GramE">:</span><br> For each row returned in the sub query known as t1, pass this row’s demo_prod_tab_typ (OID) to the POWERMULTISET function. Then, join each row from the current t1 to each row returned by the POWERMULTISET function. Then, for each row that results from the T1<span class="GramE">,T2</span> join, join to that the VALUE of t2. The value of t2 will always be a single row, and the output shown in the HTML table below might tell you why we are joining row.</p> <table border="0" cellpadding="0" cellspacing="0" class="MsoTable3DFx3" style="width:68.1%;border-collapse:collapse" width="68%"> <tr> <td style="width:80.56%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><b><span style="font-size:8.0pt;font-family:"Courier New"">XX(DEPARTMENT, PRODUCT)</span></b></p> </td> <td style="width:10.92%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><b><span style="font-size:8.0pt;font-family:"Courier New"">DEPART MENT_T3</span></b></p> </td> <td style="width:8.5%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><b><span style="font-size:8.0pt;font-family:"Courier New"">PRODU CT_T3</span></b></p> </td> </tr> <tr> <td style="width:80.56%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(1, 10))</span></p> </td> <td style="width:10.92%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">1</span></p> </td> <td style="width:8.5%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">10</span></p> </td> </tr> <tr> <td style="width:80.56%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 22))</span></p> </td> <td style="width:10.92%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">22</span></p> </td> </tr> <tr> <td style="width:80.56%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 24))</span></p> </td> <td style="width:10.92%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">24</span></p> </td> </tr> <tr> <td style="width:80.56%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 22), DEMO_PROD_TYP(2, 24))</span></p> </td> <td style="width:10.92%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">22</span></p> </td> </tr> <tr> <td style="width:80.56%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 22), DEMO_PROD_TYP(2, 24))</span></p> </td> <td style="width:10.92%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">24</span></p> </td> </tr> <tr> <td style="width:80.56%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 25))</span></p> </td> <td style="width:10.92%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">25</span></p> </td> </tr> <tr> <td style="width:80.56%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 22), DEMO_PROD_TYP(2, 25))</span></p> </td> <td style="width:10.92%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">22</span></p> </td> </tr> <tr> <td style="width:80.56%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 22), DEMO_PROD_TYP(2, 25))</span></p> </td> <td style="width:10.92%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">25</span></p> </td> </tr> <tr> <td style="width:80.56%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 24), DEMO_PROD_TYP(2, 25))</span></p> </td> <td style="width:10.92%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">24</span></p> </td> </tr> <tr> <td style="width:80.56%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 24), DEMO_PROD_TYP(2, 25))</span></p> </td> <td style="width:10.92%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">25</span></p> </td> </tr> <tr> <td style="width:80.56%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 22), DEMO_PROD_TYP(2, 24),<br> DEMO_PROD_TYP(2, 25))</span></p> </td> <td style="width:10.92%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">22</span></p> </td> </tr> <tr> <td style="width:80.56%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 22), DEMO_PROD_TYP(2, 24),<br> DEMO_PROD_TYP(2, 25))</span></p> </td> <td style="width:10.92%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">24</span></p> </td> </tr> <tr> <td style="width:80.56%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 22), DEMO_PROD_TYP(2, 24),<br> DEMO_PROD_TYP(2, 25))</span></p> </td> <td style="width:10.92%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">25</span></p> </td> </tr> <tr> <td style="width:80.56%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 23))</span></p> </td> <td style="width:10.92%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">23</span></p> </td> </tr> <tr> <td style="width:80.56%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 22), DEMO_PROD_TYP(2, 23))</span></p> </td> <td style="width:10.92%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">22</span></p> </td> </tr> <tr> <td style="width:80.56%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 22), DEMO_PROD_TYP(2, 23))</span></p> </td> <td style="width:10.92%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">23</span></p> </td> </tr> <tr> <td style="width:80.56%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 24), DEMO_PROD_TYP(2, 23))</span></p> </td> <td style="width:10.92%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">24</span></p> </td> </tr> <tr> <td style="width:80.56%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 24), DEMO_PROD_TYP(2, 23))</span></p> </td> <td style="width:10.92%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">23</span></p> </td> </tr> <tr> <td style="width:80.56%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 22), DEMO_PROD_TYP(2, 24),<br> DEMO_PROD_TYP(2, 23))</span></p> </td> <td style="width:10.92%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">22</span></p> </td> </tr> <tr> <td style="width:80.56%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 22), DEMO_PROD_TYP(2, 24),<br> DEMO_PROD_TYP(2, 23))</span></p> </td> <td style="width:10.92%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">24</span></p> </td> </tr> <tr> <td style="width:80.56%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 22), DEMO_PROD_TYP(2, 24),<br> DEMO_PROD_TYP(2, 23))</span></p> </td> <td style="width:10.92%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">23</span></p> </td> </tr> <tr> <td style="width:80.56%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 25), DEMO_PROD_TYP(2, 23))</span></p> </td> <td style="width:10.92%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">25</span></p> </td> </tr> <tr> <td style="width:80.56%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 25), DEMO_PROD_TYP(2, 23))</span></p> </td> <td style="width:10.92%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">23</span></p> </td> </tr> <tr> <td style="width:80.56%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 22), DEMO_PROD_TYP(2, 25),<br> DEMO_PROD_TYP(2, 23))</span></p> </td> <td style="width:10.92%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">22</span></p> </td> </tr> <tr> <td style="width:80.56%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 22), DEMO_PROD_TYP(2, 25),<br> DEMO_PROD_TYP(2, 23))</span></p> </td> <td style="width:10.92%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">25</span></p> </td> </tr> <tr> <td style="width:80.56%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 22), DEMO_PROD_TYP(2, 25),<br> DEMO_PROD_TYP(2, 23))</span></p> </td> <td style="width:10.92%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">23</span></p> </td> </tr> <tr> <td style="width:80.56%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 24), DEMO_PROD_TYP(2, 25),<br> DEMO_PROD_TYP(2, 23))</span></p> </td> <td style="width:10.92%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">24</span></p> </td> </tr> <tr> <td style="width:80.56%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 24), DEMO_PROD_TYP(2, 25),<br> DEMO_PROD_TYP(2, 23))</span></p> </td> <td style="width:10.92%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">25</span></p> </td> </tr> <tr> <td style="width:80.56%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 24), DEMO_PROD_TYP(2, 25),<br> DEMO_PROD_TYP(2, 23))</span></p> </td> <td style="width:10.92%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">23</span></p> </td> </tr> <tr> <td style="width:80.56%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2,22), DEMO_PROD_TYP(2,24),DEMO_PROD_TYP(2,25),DEMO_PROD_TYP(2,23))</span></p> </td> <td style="width:10.92%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">22</span></p> </td> </tr> <tr> <td style="width:80.56%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 22), DEMO_PROD_TYP(2, 24), DEMO_PROD_TYP(2, 25), DEMO_PROD_TYP(2,23))</span></p> </td> <td style="width:10.92%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">24</span></p> </td> </tr> <tr> <td style="width:80.56%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 22), DEMO_PROD_TYP(2, 24), DEMO_PROD_TYP(2, 25), DEMO_PROD_TYP(2,23))</span></p> </td> <td style="width:10.92%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">25</span></p> </td> </tr> <tr> <td style="width:80.56%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(2, 22), DEMO_PROD_TYP(2, 24), DEMO_PROD_TYP(2, 25), DEMO_PROD_TYP(2,23))</span></p> </td> <td style="width:10.92%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:8.5%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">23</span></p> </td> </tr> <tr> <td style="width:80.56%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(3, 30))</span></p> </td> <td style="width:10.92%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">3</span></p> </td> <td style="width:8.5%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">30</span></p> </td> </tr> <tr> <td style="width:80.56%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(4, 41))</span></p> </td> <td style="width:10.92%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">4</span></p> </td> <td style="width:8.5%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">41</span></p> </td> </tr> <tr> <td style="width:80.56%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(4, 45))</span></p> </td> <td style="width:10.92%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">4</span></p> </td> <td style="width:8.5%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">45</span></p> </td> </tr> <tr> <td style="width:80.56%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(4, 41), DEMO_PROD_TYP(4, 45))</span></p> </td> <td style="width:10.92%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">4</span></p> </td> <td style="width:8.5%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">41</span></p> </td> </tr> <tr> <td style="width:80.56%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(4, 41), DEMO_PROD_TYP(4, 45))</span></p> </td> <td style="width:10.92%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">4</span></p> </td> <td style="width:8.5%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">45</span></p> </td> </tr> <tr> <td style="width:80.56%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(5, 56))</span></p> </td> <td style="width:10.92%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">5</span></p> </td> <td style="width:8.5%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">56</span></p> </td> </tr> <tr> <td style="width:80.56%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(6, 63))</span></p> </td> <td style="width:10.92%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">6</span></p> </td> <td style="width:8.5%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">63</span></p> </td> </tr> <tr> <td style="width:80.56%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(7, 77))</span></p> </td> <td style="width:10.92%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">7</span></p> </td> <td style="width:8.5%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">77</span></p> </td> </tr> <tr> <td style="width:80.56%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(7, 73))</span></p> </td> <td style="width:10.92%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">7</span></p> </td> <td style="width:8.5%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">73</span></p> </td> </tr> <tr> <td style="width:80.56%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(7, 77), DEMO_PROD_TYP(7, 73))</span></p> </td> <td style="width:10.92%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">7</span></p> </td> <td style="width:8.5%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">77</span></p> </td> </tr> <tr> <td style="width:80.56%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(7, 77), DEMO_PROD_TYP(7, 73))</span></p> </td> <td style="width:10.92%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">7</span></p> </td> <td style="width:8.5%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">73</span></p> </td> </tr> <tr> <td style="width:80.56%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(8, 81))</span></p> </td> <td style="width:10.92%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">8</span></p> </td> <td style="width:8.5%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">81</span></p> </td> </tr> <tr> <td style="width:80.56%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(9, 91))</span></p> </td> <td style="width:10.92%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">9</span></p> </td> <td style="width:8.5%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">91</span></p> </td> </tr> <tr> <td style="width:80.56%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(9, 94))</span></p> </td> <td style="width:10.92%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">9</span></p> </td> <td style="width:8.5%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">94</span></p> </td> </tr> <tr> <td style="width:80.56%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(9, 91), DEMO_PROD_TYP(9, 94))</span></p> </td> <td style="width:10.92%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">9</span></p> </td> <td style="width:8.5%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">91</span></p> </td> </tr> <tr> <td style="width:80.56%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(9, 91), DEMO_PROD_TYP(9, 94))</span></p> </td> <td style="width:10.92%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">9</span></p> </td> <td style="width:8.5%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">94</span></p> </td> </tr> <tr> <td style="width:80.56%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="80%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">DEMO_PROD_TAB_TYP(DEMO_PROD_TYP(10, 77))</span></p> </td> <td style="width:10.92%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">10</span></p> </td> <td style="width:8.5%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="8%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New"">77</span></p> </td> </tr> </table> <p class="MsoNormal" style="text-autospace:none"> </p> <p class="MsoNormal"><span class="NormalWebChar">50 rows selected.<br> </span><span class="GramE">continued</span> in part 2 posting</p> </div> Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4228170808530538594.post-19905317610630782282007-10-06T11:53:00.000-07:002007-10-06T12:39:42.961-07:00 <div class="Section1"> <p><span class="Heading2Char"><span style="font-size:14.0pt">Powermultiset to find combinations</span></span></p> <h3>Part 2 of 2</h3> <p class="MsoNormal" style="margin-bottom:12.0pt;text-autospace:none"><span class="NormalWebChar">If you haven’t figured it out, the reason for the xx column is to identify the set, which was produced by the powermultiset function. Starting from row 1 of the html table above, read it like this:<br> </span><br> <span style="color:maroon">product 10 of department 1 is a member of the set (DEMO_PROD_TYP(1, 10))<br> product 24 of department 2 is a member of the set (DEMO_PROD_TYP(2, 22))<br> product 22 of department 2 is a member of the set (DEMO_PROD_TYP(2, 24))<br> product 22 of department 2 is a member of the set (DEMO_PROD_TYP(2, 22), DEMO_PROD_TYP(2, 24))<br> product 24 of department 2 is a member of the set (DEMO_PROD_TYP(2, 22), DEMO_PROD_TYP(2, 24))<br> product 25 of department 2 is a member of the set (DEMO_PROD_TYP(2, 25))<br> product 22 of department 2 is a member of the set (DEMO_PROD_TYP(2, 22), DEMO_PROD_TYP(2, 25))</span><br> <br> and so on<br> <span class="NormalWebChar">Unfortunately, we can not use GROUP BY on a nested table such as DEMO_PROD_TAB_TYP. Also, we have the groupings for the products, but we don’t have the unit_price of the products. We’ll take care of this problem in the next outward SELECT.<br> Getting the unit_price is no problem because we have the department and product from the lower level SELECT. In the below example, “SELECT unit_price <span class="GramE">… ”</span> does the job.<br> As for the nested table column, we will change it into a string so that we can perform GROUP BY on it. I don’t want to address the XML functions, so I’ll let the code speak for itself. The result of the SELECT is shown in the HTML table below the code<br> <br> </span></p> <p><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">SELECT</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">DISTINCT</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> department_t3</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">SUM(</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">price</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">)</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> possible<br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">FROM</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(SELECT</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> department_t3</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> product_t3</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(SELECT</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> unit_price<br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">FROM</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> demo<br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">WHERE</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> department </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">=</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> department_t3<br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">AND</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> product </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">=</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> product_t3</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">)</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> price</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">CAST</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">((SELECT</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">XMLELEMENT</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:10.0pt;font-family:Courier;color:red;background:white">"D"</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">XMLAGG(XMLELEMENT(</span><span style="font-size:10.0pt;font-family:Courier;color:red;background:white">"E"</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">e.</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">product</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">))).</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">getclobval<br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">()</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">AS</span> <span style="font-size:10.0pt;font-family:Courier;color:red;background:white">"department"</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">FROM</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">TABLE(</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">xx</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">)</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">e)</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">AS</span> <span style="font-size:10.0pt;font-family:Courier;color:red;background:white">VARCHAR2</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:10.0pt;font-family:Courier;color:maroon;background:white">500</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">))</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> myxml<br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">FROM</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(SELECT</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">VALUE(</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">t2</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">)</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> xx</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> t3</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">.</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">department department_t3</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> t3</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">.</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">product product_t3<br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">FROM</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(SELECT</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> department</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">CAST</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(COLLECT</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">demo_prod_typ</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">department</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">OID</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">FROM</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> demo<br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">GROUP</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">BY</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> department</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">)</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> t1</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">TABLE(POWERMULTISET(</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">t1</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">.OID))</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> t2</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">TABLE(VALUE(</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">t2</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">))</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> t3</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">))</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">GROUP</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">BY</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> department_t3</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> myxml<br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">ORDER</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">BY</span> <span style="font-size:10.0pt;font-family:Courier;color:maroon;background:white">1</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:10.0pt;font-family:Courier;color:maroon;background:white">2</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">;</span></p> <p class="MsoNormal"><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span class="NormalWebChar"><br> <span class="GramE">and</span> this is some more normal web<br> <br> </span></p> <p class="MsoNormal" style="text-autospace:none"> </p> <table border="0" cellpadding="0" cellspacing="0" class="MsoTable3DFx3" style="width:56.82%;border-collapse:collapse" width="56%"> <tr> <td style="width:13.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p class="MsoNormal"><b><span style="font-size:8.0pt;font-family:"Courier New"">DEPART MENT_T3</span></b></p> </td> <td style="width:11.64%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="center" class="MsoNormal" style="text-align:center"><b><span style="font-size:8.0pt;font-family:"Courier New"">PRODUC T_T3</span></b></p> </td> <td style="width:10.2%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="center" class="MsoNormal" style="text-align:center"><b><span style="font-size:8.0pt;font-family:"Courier New"">PRICE</span></b></p> </td> <td style="width:65.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p align="center" class="MsoNormal" style="text-align:center"><b><span style="font-size:8.0pt;font-family:"Courier New"">MYXML</span></b></p> </td> </tr> <tr> <td style="width:13.08%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">1</span></p> </td> <td style="width:11.64%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">10</span></p> </td> <td style="width:10.2%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">1200</span></p> </td> <td style="width:65.08%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>10</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">22</span></p> </td> <td style="width:10.2%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">99</span></p> </td> <td style="width:65.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>22</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">24</span></p> </td> <td style="width:10.2%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">101</span></p> </td> <td style="width:65.08%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>24</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">22</span></p> </td> <td style="width:10.2%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">99</span></p> </td> <td style="width:65.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>22</E><E>24</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">24</span></p> </td> <td style="width:10.2%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">101</span></p> </td> <td style="width:65.08%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>22</E><E>24</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">25</span></p> </td> <td style="width:10.2%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">150</span></p> </td> <td style="width:65.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>25</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">22</span></p> </td> <td style="width:10.2%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">99</span></p> </td> <td style="width:65.08%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>22</E><E>25</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">25</span></p> </td> <td style="width:10.2%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">150</span></p> </td> <td style="width:65.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>22</E><E>25</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">24</span></p> </td> <td style="width:10.2%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">101</span></p> </td> <td style="width:65.08%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>24</E><E>25</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">25</span></p> </td> <td style="width:10.2%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">150</span></p> </td> <td style="width:65.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>24</E><E>25</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">22</span></p> </td> <td style="width:10.2%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">99</span></p> </td> <td style="width:65.08%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>22</E><E>24</E><E>25</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">24</span></p> </td> <td style="width:10.2%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">101</span></p> </td> <td style="width:65.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>22</E><E>24</E><E>25</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">25</span></p> </td> <td style="width:10.2%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">150</span></p> </td> <td style="width:65.08%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>22</E><E>24</E><E>25</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">23</span></p> </td> <td style="width:10.2%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">50</span></p> </td> <td style="width:65.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>23</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">22</span></p> </td> <td style="width:10.2%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">99</span></p> </td> <td style="width:65.08%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>22</E><E>23</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">23</span></p> </td> <td style="width:10.2%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">50</span></p> </td> <td style="width:65.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>22</E><E>23</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">24</span></p> </td> <td style="width:10.2%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">101</span></p> </td> <td style="width:65.08%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>24</E><E>23</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">23</span></p> </td> <td style="width:10.2%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">50</span></p> </td> <td style="width:65.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>24</E><E>23</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">22</span></p> </td> <td style="width:10.2%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">99</span></p> </td> <td style="width:65.08%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>22</E><E>24</E><E>23</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">24</span></p> </td> <td style="width:10.2%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">101</span></p> </td> <td style="width:65.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>22</E><E>24</E><E>23</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">23</span></p> </td> <td style="width:10.2%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">50</span></p> </td> <td style="width:65.08%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>22</E><E>24</E><E>23</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">25</span></p> </td> <td style="width:10.2%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">150</span></p> </td> <td style="width:65.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>25</E><E>23</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">23</span></p> </td> <td style="width:10.2%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">50</span></p> </td> <td style="width:65.08%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>25</E><E>23</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">22</span></p> </td> <td style="width:10.2%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">99</span></p> </td> <td style="width:65.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>22</E><E>25</E><E>23</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">25</span></p> </td> <td style="width:10.2%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">150</span></p> </td> <td style="width:65.08%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>22</E><E>25</E><E>23</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">23</span></p> </td> <td style="width:10.2%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">50</span></p> </td> <td style="width:65.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>22</E><E>25</E><E>23</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">24</span></p> </td> <td style="width:10.2%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">101</span></p> </td> <td style="width:65.08%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>24</E><E>25</E><E>23</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">25</span></p> </td> <td style="width:10.2%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">150</span></p> </td> <td style="width:65.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>24</E><E>25</E><E>23</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">23</span></p> </td> <td style="width:10.2%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">50</span></p> </td> <td style="width:65.08%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>24</E><E>25</E><E>23</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">22</span></p> </td> <td style="width:10.2%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">99</span></p> </td> <td style="width:65.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>22</E><E>24</E><E>25</E><E>23</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">24</span></p> </td> <td style="width:10.2%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">101</span></p> </td> <td style="width:65.08%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>22</E><E>24</E><E>25</E><E>23</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">25</span></p> </td> <td style="width:10.2%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">150</span></p> </td> <td style="width:65.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>22</E><E>24</E><E>25</E><E>23</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:11.64%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">23</span></p> </td> <td style="width:10.2%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">50</span></p> </td> <td style="width:65.08%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>22</E><E>24</E><E>25</E><E>23</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">3</span></p> </td> <td style="width:11.64%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">30</span></p> </td> <td style="width:10.2%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">1999</span></p> </td> <td style="width:65.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>30</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">4</span></p> </td> <td style="width:11.64%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">41</span></p> </td> <td style="width:10.2%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">500</span></p> </td> <td style="width:65.08%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>41</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">4</span></p> </td> <td style="width:11.64%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">45</span></p> </td> <td style="width:10.2%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">250</span></p> </td> <td style="width:65.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>45</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">4</span></p> </td> <td style="width:11.64%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">41</span></p> </td> <td style="width:10.2%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">500</span></p> </td> <td style="width:65.08%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>41</E><E>45</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">4</span></p> </td> <td style="width:11.64%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">45</span></p> </td> <td style="width:10.2%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">250</span></p> </td> <td style="width:65.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>41</E><E>45</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">5</span></p> </td> <td style="width:11.64%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">56</span></p> </td> <td style="width:10.2%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">40</span></p> </td> <td style="width:65.08%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>56</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">6</span></p> </td> <td style="width:11.64%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">63</span></p> </td> <td style="width:10.2%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">250</span></p> </td> <td style="width:65.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>63</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">7</span></p> </td> <td style="width:11.64%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">77</span></p> </td> <td style="width:10.2%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">1200</span></p> </td> <td style="width:65.08%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>77</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">7</span></p> </td> <td style="width:11.64%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">73</span></p> </td> <td style="width:10.2%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">50</span></p> </td> <td style="width:65.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>73</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">7</span></p> </td> <td style="width:11.64%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">77</span></p> </td> <td style="width:10.2%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">1200</span></p> </td> <td style="width:65.08%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>77</E><E>73</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">7</span></p> </td> <td style="width:11.64%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">73</span></p> </td> <td style="width:10.2%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">50</span></p> </td> <td style="width:65.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>77</E><E>73</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">8</span></p> </td> <td style="width:11.64%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">81</span></p> </td> <td style="width:10.2%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">40</span></p> </td> <td style="width:65.08%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>81</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">9</span></p> </td> <td style="width:11.64%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">91</span></p> </td> <td style="width:10.2%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">200</span></p> </td> <td style="width:65.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>91</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">9</span></p> </td> <td style="width:11.64%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">94</span></p> </td> <td style="width:10.2%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">250</span></p> </td> <td style="width:65.08%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>94</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">9</span></p> </td> <td style="width:11.64%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">91</span></p> </td> <td style="width:10.2%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">200</span></p> </td> <td style="width:65.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>91</E><E>94</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">9</span></p> </td> <td style="width:11.64%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">94</span></p> </td> <td style="width:10.2%;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">250</span></p> </td> <td style="width:65.08%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>91</E><E>94</E></D></span></p> </td> </tr> <tr> <td style="width:13.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="13%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">10</span></p> </td> <td style="width:11.64%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="11%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">77</span></p> </td> <td style="width:10.2%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt" valign="top" width="10%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">500</span></p> </td> <td style="width:65.08%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt" valign="top" width="65%"> <p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New""><D><E>77</E></D></span></p> </td> </tr> </table> <p>50 rows selected.<br> We only have one more step which is addressed by the outer most SELECT. The only part of this SELECT that might not be obvious is the DISTINCT. Imagine the powerset of {1<span class="GramE">,2,3</span>}. It would be:<br> {1},{2},{3},{1,2},{1,3}{2,3}{1,2,3}, now, add together the elements of each group. The results are<br> 1,2,3,3,4,5,6.<br> As you can see, 3 <span class="GramE">occurs</span> twice. We don’t want to state twice that 3 is a possible result of adding the elements, hence DISTINCT.</p> <p><br> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">SELECT</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">DISTINCT</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> department_t3</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">SUM(</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">price</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">)</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> possible<br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">FROM</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(SELECT</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> department_t3</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> product_t3</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(SELECT</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> unit_price<br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">FROM</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> demo<br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">WHERE</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> department </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">=</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> department_t3<br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">AND</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> product </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">=</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> product_t3</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">)</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> price</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">CAST</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">((SELECT</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">XMLELEMENT</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:10.0pt;font-family:Courier;color:red;background:white">"D"</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">XMLAGG(XMLELEMENT(</span><span style="font-size:10.0pt;font-family:Courier;color:red;background:white">"E"</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">e.</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">product</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">))).</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">getclobval</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">()</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">AS</span> <span style="font-size:10.0pt;font-family:Courier;color:red;background:white">"department"</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">FROM</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">TABLE(</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">xx</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">)</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">e)</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">AS</span> <span style="font-size:10.0pt;font-family:Courier;color:red;background:white">VARCHAR2</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:10.0pt;font-family:Courier;color:maroon;background:white">500</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">))</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> myxml<br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">FROM</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(SELECT</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">VALUE(</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">t2</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">)</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> xx</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> t3</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">.</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">department department_t3</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> t3</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">.</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">product product_t3<br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">FROM</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(SELECT</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> department</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">CAST</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(COLLECT</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">demo_prod_typ</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">department</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> product</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">))</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">AS</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> demo_prod_tab_typ</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">)</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">OID</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">FROM</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> demo<br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">GROUP</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">BY</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> department</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">)</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> t1</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">TABLE(POWERMULTISET(</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">t1</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">.OID))</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> t2</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">TABLE(VALUE(</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">t2</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">))</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> t3</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">))</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">GROUP</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">BY</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> department_t3</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> myxml<br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">ORDER</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">BY</span> <span style="font-size:10.0pt;font-family:Courier;color:maroon;background:white">1</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:10.0pt;font-family:Courier;color:maroon;background:white">2</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">;</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> <br> </span></p> <p>The final result set looks like:</p> <table border="0" cellpadding="0" cellspacing="0" class="MsoTable3DFx3" style="width:32.14%;border-collapse:collapse" width="32%"> <tr style="height:14.65pt"> <td style="width:50.32%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="center" class="MsoNormal" style="text-align:center"><span style="font-size:8.0pt;font-family:"Courier New"">DEPARTMENT_T3</span></p> </td> <td style="width:47.82%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="center" class="MsoNormal" style="text-align:center"><span style="font-size:8.0pt;font-family:"Courier New"">POSSIBLE</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">1</span></p> </td> <td style="width:47.82%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">1200</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:47.82%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">50</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:47.82%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">99</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:47.82%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">101</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:47.82%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">149</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:47.82%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">150</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:47.82%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">151</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:47.82%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">200</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:47.82%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">249</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:47.82%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">250</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:47.82%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">251</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:47.82%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">299</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:47.82%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">301</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:47.82%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">350</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">2</span></p> </td> <td style="width:47.82%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">400</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">3</span></p> </td> <td style="width:47.82%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">1999</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">4</span></p> </td> <td style="width:47.82%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">250</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">4</span></p> </td> <td style="width:47.82%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">500</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">4</span></p> </td> <td style="width:47.82%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">750</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">5</span></p> </td> <td style="width:47.82%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">40</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">6</span></p> </td> <td style="width:47.82%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">250</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">7</span></p> </td> <td style="width:47.82%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">50</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">7</span></p> </td> <td style="width:47.82%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">1200</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">7</span></p> </td> <td style="width:47.82%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">1250</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">8</span></p> </td> <td style="width:47.82%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">40</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">9</span></p> </td> <td style="width:47.82%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">200</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">9</span></p> </td> <td style="width:47.82%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">250</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">9</span></p> </td> <td style="width:47.82%;border-top:solid gray 1.0pt;border-left:none;border-bottom:solid white 1.0pt;border-right:none;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">450</span></p> </td> </tr> <tr style="height:14.65pt"> <td style="width:50.32%;background:silver;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="50%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">10</span></p> </td> <td style="width:47.82%;background:#E2E2E2;padding:0in 5.4pt 0in 5.4pt;height:14.65pt" valign="top" width="47%"> <p align="right" class="MsoNormal" style="text-align:right"><span style="font-size:8.0pt;font-family:"Courier New"">500</span></p> </td> </tr> </table> <p class="MsoNormal">29 rows selected.<br> <br> </p> <p class="MsoNormal"><br> <br> </p> </div> Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4228170808530538594.post-56568529350773817272007-10-05T09:27:00.000-07:002007-10-05T09:47:09.193-07:00MERGE and Database Link ProblemUsing 10g R2 database.<br /><br />When trying to do a MERGE where the target table is on the remote database and the source table is a sub-select on the local database, the following error was raised:<br /><br /><span style="font-family: courier new;">ORA-01008: not all variables bound</span><br /><br />The MERGE statement in question had no bind variables.<br /><br />Furthermore, if I change the target table to an identical local table it works just fine, so it's not a syntax problem.<br /><br />I searched all over the web and all over technet and oracle.com but found only a few scant references to this problem. I was unable to find any restriction documented under DISTRIBUTED TRANSACTIONS in the Oracle documentation. I now believe that MERGE will only work over a DB Link when the target is on the local database and the source table is on the remote database.<br /><br />If you have information about this restriction, please leave a comment.Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-4228170808530538594.post-66702914653462332662007-10-02T17:14:00.000-07:002007-10-02T17:22:24.737-07:00 <div class="Section1"> <h1><span style="background:white">Call-Back Trigger</span></h1> <p class="MsoNormal"><span style="background:white"> </span></p> <p class="MsoNormal"><i><span style="font-size:10.0pt;font-family:Courier;color:green;background:white">--Assume you have many application servers running EHCache. You need to make</span></i><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><i><span style="font-size:10.0pt;font-family:Courier;color:green;background:white">--sure that these caches have the latest data from the database. Doing a</span></i><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><i><span style="font-size:10.0pt;font-family:Courier;color:green;background:white">--total cache refresh on a periodic basis is not feasible because there</span></i><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><i><span style="font-size:10.0pt;font-family:Courier;color:green;background:white">--is a large amount of data and only a small percentage of it gets updated.</span></i><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> <br> </span><i><span style="font-size:10.0pt;font-family:Courier;color:green;background:white">--Instead, you want the database to send the latest data to the</span></i><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><i><span style="font-size:10.0pt;font-family:Courier;color:green;background:white">--caches upon updating corresponding database data. </span></i><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> <br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">Create</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">Or</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">Replace</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">Trigger</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> Call_back<br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">Before</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">Update</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">Of</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> Prod_limit</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> Current_prod_cnt<br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">On</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> Prod_total<br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">Referencing</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">New</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">As</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">New</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">Old</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">As</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">Old</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">For</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">Each</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">Row</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">When(New.</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">Current_prod_cnt </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">>=</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">New.</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">Prod_limit</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">)</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">Declare</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">Pragma</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> Autonomous_transaction</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">;</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> L_web_page </span><span style="font-size:10.0pt;font-family:Courier;color:red;background:white">Clob</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">;</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> Err_sqlerrm </span><span style="font-size:10.0pt;font-family:Courier;color:red;background:white">Varchar2</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:10.0pt;font-family:Courier;color:maroon;background:white">150</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">);</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> L_host_name Qsn_app</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">.</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">App_server</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">.</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">Host_name%</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">Type;</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> L_port_name Qsn_app</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">.</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">App_server</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">.</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">Port_name%</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">Type;</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> L_uri_string </span><span style="font-size:10.0pt;font-family:Courier;color:red;background:white">Varchar2</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:10.0pt;font-family:Courier;color:maroon;background:white">1999</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">);</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> L_xml_string </span><span style="font-size:10.0pt;font-family:Courier;color:red;background:white">Varchar2</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:10.0pt;font-family:Courier;color:maroon;background:white">1999</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">);</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">Begin</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><i><span style="font-size:10.0pt;font-family:Courier;color:green;background:white">-- Build the url string which includes the primary key and new data</span></i><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><i><span style="font-size:10.0pt;font-family:Courier;color:green;background:white">-- The jsp will know what to do when it gets this URL data</span></i><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><i><span style="font-size:10.0pt;font-family:Courier;color:green;background:white">-- Obviously ,your url must match the specification</span></i><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><i><span style="font-size:10.0pt;font-family:Courier;color:green;background:white">-- that your Java programmer give you.</span></i><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> L_xml_string </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">:=</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:red;background:white">'/proj1-admin/manageCache_new.jsp?'</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> || </span><span style="font-size:10.0pt;font-family:Courier;color:red;background:white">'action=update&cacheName=com.myco.product.'</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> || </span><span style="font-size:10.0pt;font-family:Courier;color:red;background:white">'prod.common.entity.ProdKey&cacheKey='</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> || </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">:New.</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">Prod_total_key<br> || </span><span style="font-size:10.0pt;font-family:Courier;color:red;background:white">'&cacheData='</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> || </span><span style="font-size:10.0pt;font-family:Courier;color:red;background:white">'<?xml version = 1.0><ROWSET><ROW num=1?><PROD_LIMIT>'</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> || </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">:New.</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">Prod_limit<br> || </span><span style="font-size:10.0pt;font-family:Courier;color:red;background:white">'</PROD_LIMIT><CURRENT_PROD_CNT>'</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> || </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">:New.</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">Current_prod_cnt<br> || </span><span style="font-size:10.0pt;font-family:Courier;color:red;background:white">'</CURRENT_PROD_CNT></ROW></ROWSET>'</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">;</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><i><span style="font-size:10.0pt;font-family:Courier;color:green;background:white">-- if the web page does not come back within 5 seconds, stop waiting</span></i><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><i><span style="font-size:10.0pt;font-family:Courier;color:green;background:white">-- and report the problem</span></i><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> UTL_HTTP</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">.</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">Set_transfer_timeout</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:10.0pt;font-family:Courier;color:maroon;background:white">5</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">);</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> <br> </span><i><span style="font-size:10.0pt;font-family:Courier;color:green;background:white">-- app_servers is a table with the names of hosts which are hosting the</span></i><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><i><span style="font-size:10.0pt;font-family:Courier;color:green;background:white">-- caches which need to be updated.</span></i><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">For</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> Cur1 </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">In</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(Select</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> Host_name</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> Port_name<br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">From</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> App_servers</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">)</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">Loop</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><i><span style="font-size:10.0pt;font-family:Courier;color:green;background:white">-- assign variables to scope outside of loop so</span></i><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><i><span style="font-size:10.0pt;font-family:Courier;color:green;background:white">-- exception handling can use them</span></i><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> L_host_name </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">:=</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> Cur1</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">.</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">Host_name</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">;</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> L_port_name </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">:=</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> Cur1</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">.</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">Port_name</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">;</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><i><span style="font-size:10.0pt;font-family:Courier;color:green;background:white">-- prefix your URL with the Protocal, HOST, PORT that you are currently</span></i><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><i><span style="font-size:10.0pt;font-family:Courier;color:green;background:white">-- going to call</span></i><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> L_uri_string </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">:=</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> Utl_url</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">.Escape(</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> </span><span style="font-size:10.0pt;font-family:Courier;color:red;background:white">'http://'</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> || Cur1</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">.</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">Host_name<br> || </span><span style="font-size:10.0pt;font-family:Courier;color:red;background:white">':'</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> || Cur1</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">.</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">Port_name<br> || L_xml_string</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">);</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> <br> </span><i><span style="font-size:10.0pt;font-family:Courier;color:green;background:white">-- Send the data via HTTP GET to the target server</span></i><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">Select</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> Httpuritype</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">.</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">Createuri</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">L_uri_string</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">).</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">Getclob</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">()</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> Web_page<br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">Into</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> L_web_page<br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">From</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> DUAL</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">;</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> <br> </span><i><span style="font-size:10.0pt;font-family:Courier;color:green;background:white">-- inspect the resulting web page to see if things went good or bad</span></i><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><i><span style="font-size:10.0pt;font-family:Courier;color:green;background:white">-- if the HTTP call timed-out, (more than 5 seconds),</span></i><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><i><span style="font-size:10.0pt;font-family:Courier;color:green;background:white">-- l_web_page will be null</span></i><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><i><span style="font-size:10.0pt;font-family:Courier;color:green;background:white">--</span></i><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">If</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">INSTR(</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">L_web_page</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:10.0pt;font-family:Courier;color:red;background:white">'SUCCESS'</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">)</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">=</span> <span style="font-size:10.0pt;font-family:Courier;color:maroon;background:white">0</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">Then</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> My_util</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">.</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">Dautonomous_exception<br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">Pprogramname </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">=></span> <span style="font-size:10.0pt;font-family:Courier;color:red;background:white">'call_back'</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> Pprogramlocation </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">=></span> <span style="font-size:10.0pt;font-family:Courier;color:red;background:white">'cache refresh failed '</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> Perrormsg </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">=></span> <span style="font-size:10.0pt;font-family:Courier;color:red;background:white">'error'</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> Pmsg_line1 </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">=></span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> </span><span style="font-size:10.0pt;font-family:Courier;color:red;background:white">'ProductKey = '</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> || </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">:New.</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">Prod_total_key</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> Pmsg_line2 </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">=></span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> </span><span style="font-size:10.0pt;font-family:Courier;color:red;background:white">'Host_name = '</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> || L_host_name</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> Pmsg_line3 </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">=></span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> </span><span style="font-size:10.0pt;font-family:Courier;color:red;background:white">'Port_name = '</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> || L_port_name</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> Pmsg_line4 </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">=></span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">SUBSTR(</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">L_web_page</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:maroon;background:white">1</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:maroon;background:white">200</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">));</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">End</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">If;</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">End</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">Loop;</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">Exception</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">When</span> <span style="font-size:10.0pt;font-family:Courier;color:red;background:white">Others</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">Then</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> Err_sqlerrm </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">:=</span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">SUBSTR(SQLERRM,</span> <span style="font-size:10.0pt;font-family:Courier;color:maroon;background:white">1</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span> <span style="font-size:10.0pt;font-family:Courier;color:maroon;background:white">150</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">);</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> My_util</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">.</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">Dautonomous_exception<br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">(</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">Pprogramname </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">=></span> <span style="font-size:10.0pt;font-family:Courier;color:red;background:white">'call_back'</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> Pprogramlocation </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">=></span> <span style="font-size:10.0pt;font-family:Courier;color:red;background:white">'Serious Error'</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> Perrormsg </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">=></span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> Err_sqlerrm</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> Pmsg_line1 </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">=></span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> </span><span style="font-size:10.0pt;font-family:Courier;color:red;background:white">'ProductKey = '</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> || </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">:New.</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white">Prod_total_key</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> Pmsg_line2 </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">=></span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> </span><span style="font-size:10.0pt;font-family:Courier;color:red;background:white">'Host_name = '</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> || L_host_name</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> Pmsg_line3 </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">=></span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> </span><span style="font-size:10.0pt;font-family:Courier;color:red;background:white">'Port_name = '</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> || L_port_name</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">,</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> Pmsg_line4 </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">=></span> <span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">Null);</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">End</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"> Call_back</span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">;</span><span style="font-size:10.0pt;font-family:Courier;color:black;background:white"><br> </span><span style="font-size:10.0pt;font-family:Courier;color:blue;background:white">/</span><br> <br> </p> </div> Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4228170808530538594.post-43149905034720284102007-09-28T13:40:00.000-07:002007-09-28T14:01:37.089-07:00 <h1 class="western">Visualizing rollups</h1> <p class="western" style="margin-bottom: 0in;"><br> </p> <p class="western" style="margin-bottom: 0in;"><font size="4">Post 1 of a 3 post article.</font></p> <p class="western" style="margin-bottom: 0in;"><br> </p> <p class="western" style="margin-bottom: 0in;">Many code examples, found on the web, focus on a single feature of the programming language. There is a good reason for this which is that examples incorporating many features are less generic and therefore less likely to be of use to a large portion of the audience. The down side of this 'keep it simple' approach is that the audience is less often exposed to ways to combine features. The ability to combine the features of SQL is what makes it an amazingly powerful language. <br><br>Before you begin, you should understand the Oracle SQL reporting functions such as ROLLUP, GROUP_ID, GROUPING_SET and GROUPING_ID. If you are not familiar with these, you might still learn something interesting, but you will not understand everything that is going on. <br><br> </p> <p class="western" style="margin-bottom: 0in;">When I first encountered Oracle's reporting functions I was somewhat overwhelmed by the complexity. What I needed was a way to visualize the process of constructing non trivial rollups. I tend to be a visual learner, and if you show me a picture, I'll probably understand instantly.<br>There are plenty of examples that show rollup statements and the resulting output and that's fine, if you need to do exactly what the example shows. However, I've not seen anybody outline a methodology for constructing new rollup patterns. So, there are 2 things I am attempting to do in this article</p> <ol> <li><p class="western" style="margin-bottom: 0in;">Develope a way to think about rollups</p> </li><li><p class="western" style="margin-bottom: 0in;">Lay the groundwork for future articles that will build upon the examples in this article.</p> </li></ol> <p class="western" style="margin-bottom: 0in;"> <br>This first article will be divided into two examples. First, a simple example then a second, more complex example. <br><br><font face="Arial, sans-serif"><font size="4"><span lang="en-US"><i><b>EXAMPLE 1. a simple rollup</b></i></span></font></font><br><br> </p> <p style="margin-top: 0.08in; page-break-after: avoid;"><font size="2"><b>Table 1</b></font></p> <table border="1" bordercolor="#000000" cellpadding="8" cellspacing="0" width="571"> <col width="553"> <tbody><tr> <td valign="top" width="553"> <p class="western"><font size="2"><font face="Courier, Courier New, monospace"><font color="#0000ff">CREATE</font> <font color="#0000ff">TABLE</font> <font color="#808000">TEST_MM</font><font color="#000000"><br></font><font color="#0000ff">(</font><font color="#000000"><br> CITY </font><font color="#ff0000">CHAR</font><font color="#0000ff">(</font><font color="#800000">9</font><font color="#0000ff">),</font><font color="#000000"><br> SHIPPER </font><font color="#ff0000">CHAR</font><font color="#0000ff">(</font><font color="#800000">4</font><font color="#0000ff">),</font><font color="#000000"><br> DELIVERER </font><font color="#ff0000">CHAR</font><font color="#0000ff">(</font><font color="#800000">3</font><font color="#0000ff">),</font><font color="#000000"><br> CUSTOMER </font><font color="#ff0000">CHAR</font><font color="#0000ff">(</font><font color="#800000">8</font><font color="#0000ff">)</font><font color="#000000"><br></font><font color="#0000ff">);</font><font color="#000000"><br><br></font><font color="#0000ff">Insert</font> <font color="#0000ff">into</font> <font color="#808000">TEST_MM</font> <font color="#0000ff">(</font><font color="#000000">CITY</font><font color="#0000ff">,</font><font color="#000000"> SHIPPER</font><font color="#0000ff">,</font><font color="#000000"> DELIVERER</font><font color="#0000ff">,</font><font color="#000000"> CUSTOMER</font><font color="#0000ff">)</font><font color="#000000"><br> </font><font color="#0000ff">Values</font> <font color="#0000ff">(</font><font color="#ff0000">'Sunnyvale'</font><font color="#0000ff">,</font> <font color="#ff0000">'fedx'</font><font color="#0000ff">,</font> <font color="#ff0000">'Sam'</font><font color="#0000ff">,</font> <font color="#ff0000">'PJ Shoes'</font><font color="#0000ff">);</font><font color="#000000"><br></font><font color="#0000ff">Insert</font> <font color="#0000ff">into</font> <font color="#808000">TEST_MM</font> <font color="#0000ff">(</font><font color="#000000">CITY</font><font color="#0000ff">,</font><font color="#000000"> SHIPPER</font><font color="#0000ff">,</font><font color="#000000"> DELIVERER</font><font color="#0000ff">,</font><font color="#000000"> CUSTOMER</font><font color="#0000ff">)</font><font color="#000000"><br> </font><font color="#0000ff">Values</font> <font color="#0000ff">(</font><font color="#ff0000">'Sunnyvale'</font><font color="#0000ff">,</font> <font color="#ff0000">'fedx'</font><font color="#0000ff">,</font> <font color="#0000ff">NULL,</font> <font color="#ff0000">'PJ Shoes'</font><font color="#0000ff">);</font><font color="#000000"><br></font><font color="#0000ff">Insert</font> <font color="#0000ff">into</font> <font color="#808000">TEST_MM</font> <font color="#0000ff">(</font><font color="#000000">CITY</font><font color="#0000ff">,</font><font color="#000000"> SHIPPER</font><font color="#0000ff">,</font><font color="#000000"> DELIVERER</font><font color="#0000ff">,</font><font color="#000000"> CUSTOMER</font><font color="#0000ff">)</font><font color="#000000"><br> </font><font color="#0000ff">Values</font> <font color="#0000ff">(</font><font color="#ff0000">'Sunnyvale'</font><font color="#0000ff">,</font> <font color="#ff0000">'fedx'</font><font color="#0000ff">,</font> <font color="#ff0000">'Sam'</font><font color="#0000ff">,</font> <font color="#ff0000">'TeaVana '</font><font color="#0000ff">);</font><font color="#000000"><br></font><font color="#0000ff">Insert</font> <font color="#0000ff">into</font> <font color="#808000">TEST_MM</font> <font color="#0000ff">(</font><font color="#000000">CITY</font><font color="#0000ff">,</font><font color="#000000"> SHIPPER</font><font color="#0000ff">,</font><font color="#000000"> DELIVERER</font><font color="#0000ff">,</font><font color="#000000"> CUSTOMER</font><font color="#0000ff">)</font><font color="#000000"><br> </font><font color="#0000ff">Values</font> <font color="#0000ff">(</font><font color="#ff0000">'Sunnyvale'</font><font color="#0000ff">,</font> <font color="#ff0000">'ups '</font><font color="#0000ff">,</font> <font color="#ff0000">'Ted'</font><font color="#0000ff">,</font> <font color="#ff0000">'PJ Shoes'</font><font color="#0000ff">);</font><font color="#000000"><br></font><font color="#0000ff">Insert</font> <font color="#0000ff">into</font> <font color="#808000">TEST_MM</font> <font color="#0000ff">(</font><font color="#000000">CITY</font><font color="#0000ff">,</font><font color="#000000"> SHIPPER</font><font color="#0000ff">,</font><font color="#000000"> DELIVERER</font><font color="#0000ff">,</font><font color="#000000"> CUSTOMER</font><font color="#0000ff">)</font><font color="#000000"><br> </font><font color="#0000ff">Values</font> <font color="#0000ff">(</font><font color="#ff0000">'Sunnyvale'</font><font color="#0000ff">,</font> <font color="#ff0000">'ups '</font><font color="#0000ff">,</font> <font color="#ff0000">'Ted'</font><font color="#0000ff">,</font> <font color="#ff0000">'TeaVana '</font><font color="#0000ff">);</font><font color="#000000"><br></font><font color="#0000ff">Insert</font> <font color="#0000ff">into</font> <font color="#808000">TEST_MM</font> <font color="#0000ff">(</font><font color="#000000">CITY</font><font color="#0000ff">,</font><font color="#000000"> SHIPPER</font><font color="#0000ff">,</font><font color="#000000"> DELIVERER</font><font color="#0000ff">,</font><font color="#000000"> CUSTOMER</font><font color="#0000ff">)</font><font color="#000000"><br> </font><font color="#0000ff">Values</font> <font color="#0000ff">(</font><font color="#ff0000">'Sunnyvale'</font><font color="#0000ff">,</font> <font color="#ff0000">'con '</font><font color="#0000ff">,</font> <font color="#ff0000">'Sam'</font><font color="#0000ff">,</font> <font color="#ff0000">'TeaVana '</font><font color="#0000ff">);</font><font color="#000000"><br></font><font color="#0000ff">Insert</font> <font color="#0000ff">into</font> <font color="#808000">TEST_MM</font> <font color="#0000ff">(</font><font color="#000000">CITY</font><font color="#0000ff">,</font><font color="#000000"> SHIPPER</font><font color="#0000ff">,</font><font color="#000000"> DELIVERER</font><font color="#0000ff">,</font><font color="#000000"> CUSTOMER</font><font color="#0000ff">)</font><font color="#000000"><br> </font><font color="#0000ff">Values</font> <font color="#0000ff">(</font><font color="#ff0000">'Sunnyvale'</font><font color="#0000ff">,</font> <font color="#ff0000">'ups '</font><font color="#0000ff">,</font> <font color="#ff0000">'Ted'</font><font color="#0000ff">,</font> <font color="#ff0000">'TeaVana '</font><font color="#0000ff">);</font><font color="#000000"><br></font><font color="#0000ff">Insert</font> <font color="#0000ff">into</font> <font color="#808000">TEST_MM</font> <font color="#0000ff">(</font><font color="#000000">CITY</font><font color="#0000ff">,</font><font color="#000000"> SHIPPER</font><font color="#0000ff">,</font><font color="#000000"> DELIVERER</font><font color="#0000ff">,</font><font color="#000000"> CUSTOMER</font><font color="#0000ff">)</font><font color="#000000"><br> </font><font color="#0000ff">Values</font> <font color="#0000ff">(</font><font color="#ff0000">'Sunnyvale'</font><font color="#0000ff">,</font> <font color="#ff0000">'con '</font><font color="#0000ff">,</font> <font color="#ff0000">'Ted'</font><font color="#0000ff">,</font> <font color="#ff0000">'TeaVana '</font><font color="#0000ff">);</font><font color="#000000"><br></font><font color="#0000ff">Insert</font> <font color="#0000ff">into</font> <font color="#808000">TEST_MM</font> <font color="#0000ff">(</font><font color="#000000">CITY</font><font color="#0000ff">,</font><font color="#000000"> SHIPPER</font><font color="#0000ff">,</font><font color="#000000"> DELIVERER</font><font color="#0000ff">,</font><font color="#000000"> CUSTOMER</font><font color="#0000ff">)</font><font color="#000000"><br> </font><font color="#0000ff">Values</font> <font color="#0000ff">(</font><font color="#ff0000">'Sunnyvale'</font><font color="#0000ff">,</font> <font color="#ff0000">'fedx'</font><font color="#0000ff">,</font> <font color="#ff0000">'Sue'</font><font color="#0000ff">,</font> <font color="#ff0000">'PJ Shoes'</font><font color="#0000ff">);</font><font color="#000000"><br></font><font color="#0000ff">Insert</font> <font color="#0000ff">into</font> <font color="#808000">TEST_MM</font> <font color="#0000ff">(</font><font color="#000000">CITY</font><font color="#0000ff">,</font><font color="#000000"> SHIPPER</font><font color="#0000ff">,</font><font color="#000000"> DELIVERER</font><font color="#0000ff">,</font><font color="#000000"> CUSTOMER</font><font color="#0000ff">)</font><font color="#000000"><br> </font><font color="#0000ff">Values</font> <font color="#0000ff">(</font><font color="#ff0000">'Sunnyvale'</font><font color="#0000ff">,</font> <font color="#ff0000">'fedx'</font><font color="#0000ff">,</font> <font color="#0000ff">NULL,</font> <font color="#ff0000">'PJ Shoes'</font><font color="#0000ff">);</font><font color="#000000"><br></font><font color="#0000ff">Insert</font> <font color="#0000ff">into</font> <font color="#808000">TEST_MM</font> <font color="#0000ff">(</font><font color="#000000">CITY</font><font color="#0000ff">,</font><font color="#000000"> SHIPPER</font><font color="#0000ff">,</font><font color="#000000"> DELIVERER</font><font color="#0000ff">,</font><font color="#000000"> CUSTOMER</font><font color="#0000ff">)</font><font color="#000000"><br> </font><font color="#0000ff">Values</font> <font color="#0000ff">(</font><font color="#ff0000">'Sunnyvale'</font><font color="#0000ff">,</font> <font color="#ff0000">'fedx'</font><font color="#0000ff">,</font> <font color="#ff0000">'Sam'</font><font color="#0000ff">,</font> <font color="#ff0000">'TeaVana '</font><font color="#0000ff">);</font><font color="#000000"><br></font><font color="#0000ff">Insert</font> <font color="#0000ff">into</font> <font color="#808000">TEST_MM</font> <font color="#0000ff">(</font><font color="#000000">CITY</font><font color="#0000ff">,</font><font color="#000000"> SHIPPER</font><font color="#0000ff">,</font><font color="#000000"> DELIVERER</font><font color="#0000ff">,</font><font color="#000000"> CUSTOMER</font><font color="#0000ff">)</font><font color="#000000"><br> </font><font color="#0000ff">Values</font> <font color="#0000ff">(</font><font color="#ff0000">'Sunnyvale'</font><font color="#0000ff">,</font> <font color="#ff0000">'ups '</font><font color="#0000ff">,</font> <font color="#ff0000">'Ted'</font><font color="#0000ff">,</font> <font color="#ff0000">'PJ Shoes'</font><font color="#0000ff">);</font><font color="#000000"><br></font><font color="#0000ff">Insert</font> <font color="#0000ff">into</font> <font color="#808000">TEST_MM</font> <font color="#0000ff">(</font><font color="#000000">CITY</font><font color="#0000ff">,</font><font color="#000000"> SHIPPER</font><font color="#0000ff">,</font><font color="#000000"> DELIVERER</font><font color="#0000ff">,</font><font color="#000000"> CUSTOMER</font><font color="#0000ff">)</font><font color="#000000"><br> </font><font color="#0000ff">Values</font> <font color="#0000ff">(</font><font color="#ff0000">'Sunnyvale'</font><font color="#0000ff">,</font> <font color="#ff0000">'ups '</font><font color="#0000ff">,</font> <font color="#ff0000">'Sue'</font><font color="#0000ff">,</font> <font color="#ff0000">'TeaVana '</font><font color="#0000ff">);</font><font color="#000000"><br></font><font color="#0000ff">Insert</font> <font color="#0000ff">into</font> <font color="#808000">TEST_MM</font> <font color="#0000ff">(</font><font color="#000000">CITY</font><font color="#0000ff">,</font><font color="#000000"> SHIPPER</font><font color="#0000ff">,</font><font color="#000000"> DELIVERER</font><font color="#0000ff">,</font><font color="#000000"> CUSTOMER</font><font color="#0000ff">)</font><font color="#000000"><br> </font><font color="#0000ff">Values</font> <font color="#0000ff">(</font><font color="#ff0000">'Sunnyvale'</font><font color="#0000ff">,</font> <font color="#ff0000">'con '</font><font color="#0000ff">,</font> <font color="#ff0000">'Sam'</font><font color="#0000ff">,</font> <font color="#ff0000">'TeaVana '</font><font color="#0000ff">);</font><font color="#000000"><br></font><font color="#0000ff">Insert</font> <font color="#0000ff">into</font> <font color="#808000">TEST_MM</font> <font color="#0000ff">(</font><font color="#000000">CITY</font><font color="#0000ff">,</font><font color="#000000"> SHIPPER</font><font color="#0000ff">,</font><font color="#000000"> DELIVERER</font><font color="#0000ff">,</font><font color="#000000"> CUSTOMER</font><font color="#0000ff">)</font><font color="#000000"><br> </font><font color="#0000ff">Values</font> <font color="#0000ff">(</font><font color="#ff0000">'Sunnyvale'</font><font color="#0000ff">,</font> <font color="#ff0000">'ups '</font><font color="#0000ff">,</font> <font color="#ff0000">'Sue'</font><font color="#0000ff">,</font> <font color="#ff0000">'TeaVana '</font><font color="#0000ff">);</font><font color="#000000"><br></font><font color="#0000ff">Insert</font> <font color="#0000ff">into</font> <font color="#808000">TEST_MM</font> <font color="#0000ff">(</font><font color="#000000">CITY</font><font color="#0000ff">,</font><font color="#000000"> SHIPPER</font><font color="#0000ff">,</font><font color="#000000"> DELIVERER</font><font color="#0000ff">,</font><font color="#000000"> CUSTOMER</font><font color="#0000ff">)</font><font color="#000000"><br> </font><font color="#0000ff">Values</font> <font color="#0000ff">(</font><font color="#ff0000">'Sunnyvale'</font><font color="#0000ff">,</font> <font color="#ff0000">'ups '</font><font color="#0000ff">,</font> <font color="#ff0000">'Ted'</font><font color="#0000ff">,</font> <font color="#ff0000">'TeaVana '</font><font color="#0000ff">);</font><font color="#000000"><br></font><font color="#0000ff">COMMIT;</font></font></font></p> </td> </tr> </tbody></table> <p class="western" style="margin-bottom: 0in;"><br><br>Each record in Table 2 represents a delivery of some item to a customer.<br><br> </p> <p style="margin-top: 0.08in; page-break-after: avoid;"><a name="_Ref178737745"></a> <font size="2"><b>Table 2</b></font></p> <dl> <dd> <table border="1" bordercolor="#000000" cellpadding="8" cellspacing="0" width="264"> <col width="246"> <tbody><tr> <td height="310" valign="top" width="246"> <p class="western" style="margin-left: 0.05in;"><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: black;"><font size="2">CITY</font> <font size="2">SHIP DEL CUSTOMER<br> ------------ ---- --- -----<br> Sunnyvale con</font> <font size="2">Sam TeaVana<br> Sunnyvale con</font> <font size="2">Sam TeaVana<br> Sunnyvale con</font> <font size="2">Ted TeaVana<br> Sunnyvale fedx Sam PJ Shoe<br> Sunnyvale fedx Sam PJ Shoe<br> Sunnyvale fedx Sam PJ Shoe<br> Sunnyvale fedx Sam TeaVana<br> Sunnyvale fedx Sam TeaVana<br> Sunnyvale fedx Sue PJ Shoe<br> Sunnyvale ups</font> <font size="2">Sue TeaVana<br> Sunnyvale ups</font> <font size="2">Sue TeaVana<br> Sunnyvale ups</font> <font size="2">Ted PJ Shoe<br> Sunnyvale ups</font> <font size="2">Ted PJ Shoe<br> Sunnyvale ups</font> <font size="2">Ted TeaVana<br> Sunnyvale ups</font> <font size="2">Ted TeaVana<br> Sunnyvale ups</font> <font size="2">Ted TeaVana.</font></span></p> </td> </tr> </tbody></table> </dd></dl> <p class="western" style="margin-bottom: 0in;"><span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%"><font size="2"><font face="Courier, Courier New, monospace"><font color="#000000"><br></font></font></font></span>The measure, for this example, is the count(*) of deliveries. The rollups of interest are<br>number of deliveries per city<br>number of deliveries per city per shipper<br>number of deliveries per city per shipper per deliverer<br><span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%"><font size="2"><font face="Courier, Courier New, monospace"><font color="#000000"><br></font><font color="#008000"><br></font></font></font></span><br> </p> <p style="margin-top: 0.08in; page-break-after: avoid;"><a name="_Ref178737870"></a> <font size="2"><b>Table 3</b></font></p> <table border="1" bordercolor="#000000" cellpadding="8" cellspacing="0" width="526"> <col width="183"> <col width="309"> <tbody><tr valign="top"> <td height="294" width="183"> <p class="western"><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: black;"><font size="2">Table 2A<br> CITY</font> <font size="2">SHIP DEL CNT<br> --------- ---- ------<br> Sunnyvale con</font> <font size="2">Sam</font> <font size="2">2<br> </font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: gray;"><font size="2">Sunnyvale con</font> <font size="2">Ted</font> <font size="2">1</font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: black;"><br><font size="2"> Sunnyvale con</font> <font size="2">3<br> Sunnyvale fedx Sam</font> <font size="2">5<br> </font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: gray;"><font size="2">Sunnyvale fedx Sue</font> <font size="2">1</font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: black;"><br><font size="2"> Sunnyvale fedx</font> <font size="2">6<br> Sunnyvale ups</font> <font size="2">Sue</font> <font size="2">2<br> Sunnyvale ups</font> <font size="2">Ted</font> <font size="2">5<br> </font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: gray;"><font size="2">Sunnyvale ups</font> <font size="2">7</font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: black;"><br><font size="2"> Sunnyvale</font> <font size="2">16</font></span></p> </td> <td width="309"> <p class="western" style="margin-left: 0.09in;"><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: black;"><font size="2">Table 2B<br> CITY</font> <font size="2">SHIP DEL CUSTOMER</font> <font size="2">CNT<br> --------- ---- --- -------- ----<br> Sunnyvale fedx Sam PJ Shoes</font> <font size="2">3<br> </font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: gray;"><font size="2">Sunnyvale fedx Sue PJ Shoes</font> <font size="2">1</font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: black;"><br><font size="2"> Sunnyvale fedx</font> <font size="2">PJ Shoes</font> <font size="2">4<br> Sunnyvale ups</font> <font size="2">Ted PJ Shoes</font> <font size="2">2<br> </font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: gray;"><font size="2">Sunnyvale ups</font> <font size="2">PJ Shoes</font> <font size="2">2</font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: black;"><br><font size="2"> Sunnyvale</font> <font size="2">PJ Shoes</font> <font size="2">6<br> Sunnyvale con</font> <font size="2">Sam TeaVana</font> <font size="2">2<br> </font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: gray;"><font size="2">Sunnyvale con</font> <font size="2">Ted TeaVana</font> </span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: black;"><font size="2">1<br> Sunnyvale con</font> <font size="2">TeaVana</font> <font size="2">3<br> Sunnyvale fedx Sam TeaVana</font> <font size="2">2<br> Sunnyvale fedx</font> <font size="2">TeaVana</font> <font size="2">2<br> Sunnyvale ups</font> <font size="2">Sue TeaVana</font> <font size="2">2<br> Sunnyvale ups</font> <font size="2">Ted TeaVana</font> <font size="2">3<br> </font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: gray;"><font size="2">Sunnyvale ups</font> <font size="2">TeaVana</font> <font size="2">5<br> </font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: black;"><font size="2">Sunnyvale</font> <font size="2">TeaVana</font> <font size="2">10</font></span></p> </td> </tr> </tbody></table> <p class="western" style="margin-bottom: 0in;"><font face="Courier New, monospace"><br><br><br>Table 3</font>A shows the result set of ... <br><span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%"><font size="2"><font face="Courier, Courier New, monospace"><font color="#0000ff">SELECT</font><font color="#000000"> city</font><font color="#0000ff">,</font><font color="#000000"> shipper</font><font color="#0000ff">,</font><font color="#000000"> deliverer</font><font color="#0000ff">,</font> <font color="#0000ff">COUNT(</font><font color="#000000">*</font><font color="#0000ff">)</font><font color="#000000"> cnt </font><font color="#0000ff">FROM</font> <font color="#808000">test_mm</font><font color="#0000ff"> <br>GROUP</font> <font color="#0000ff">BY</font><font color="#000000"> city</font><font color="#0000ff">,</font> <font color="#0000ff">ROLLUP(</font><font color="#000000">shipper</font><font color="#0000ff">,</font><font color="#000000"> deliverer</font><font color="#0000ff">);</font></font></font></span><br><br><br>Table 3Bshows the result set of ...<br><span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%"><font size="2"><font face="Courier, Courier New, monospace"><font color="#0000ff">SELECT</font><font color="#000000"> city</font><font color="#0000ff">,</font><font color="#000000"> shipper</font><font color="#0000ff">,</font><font color="#000000"> deliverer</font><font color="#0000ff">,</font><font color="#000000"> customer</font><font color="#0000ff">,</font> <font color="#0000ff">COUNT(</font><font color="#000000">*</font><font color="#0000ff">)</font><font color="#000000"> cnt </font><font color="#0000ff">FROM</font> <font color="#808000">test_mm</font><font color="#0000ff"> <br>GROUP</font> <font color="#0000ff">BY</font><font color="#000000"> city</font><font color="#0000ff">,</font> <font color="#0000ff">ROLLUP(</font><font color="#000000">shipper</font><font color="#0000ff">,</font><font color="#000000"> deliverer</font><font color="#0000ff">),(</font><font color="#000000">customer</font><font color="#0000ff">);</font></font></font></span><br><br>Table 4 shows the result of joining the non-grey rows from table3 A and table3 B.I will come back<br>to this join later. For now, just observe.<br><br> </p> <p style="margin-top: 0.08in; page-break-after: avoid;"><a name="_Ref178737976"></a> <font size="2"><b>Table 4</b></font></p> <table border="1" bordercolor="#000000" cellpadding="8" cellspacing="0" width="526"> <col width="508"> <tbody><tr> <td height="132" valign="top" width="508"> <p class="western" style="margin-left: 0.22in;"><font face="Courier New, monospace"><span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%"><font size="2"><font color="#993300">Sunnyvale con Sam</font> </font></span>[<span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%"><font size="2"><font color="#000000">TeaVana 2</font></font></span>]<span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%"><font size="2"><font color="#000000"> <br></font><font color="#993300">Sunnyvale con</font> </font></span>[<font size="2"><font color="#000000"><span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%">TeaVana 3</span><br></font><span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%"><font color="#993300">Sunnyvale fedx Sam</font> </span></font>[<font size="2"><font color="#000000"><span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%">PJ Shoes 3</span>,<span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%"> TeaVana 2</span></font></font>]<br><span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%"><font size="2"><font color="#993300">Sunnyvale fedx</font> </font></span>[<font size="2"><font color="#000000"><span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%">PJ Shoes 4</span>, <span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%">TeaVana 2</span></font></font>]<span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%"><font size="2"><font color="#000000"><br></font><font color="#993300">Sunnyvale ups Sue</font> </font></span>[<font size="2"><font color="#000000"><span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%">TeaVana </span>2]</font></font><br><span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%"><font size="2"><font color="#993300">Sunnyvale ups Ted</font> </font></span>[<font size="2"><font color="#000000"><span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%">TeaVana 3</span>]<span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%"><br></span></font><span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%"><font color="#993300">Sunnyvale </font><font color="#000000">[PJ Shoes 6, TeaVana 10]</font></span></font></font></p> </td> </tr> </tbody></table> <p class="western" style="margin-bottom: 0in;"><span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%"><font size="2"><font face="Courier, Courier New, monospace"><br></font></font>In Table 4 I've shown the JOIN result is in a denormalized form. This is done to emphasize the rollup levels<br>( the first three columns) as unique, non-repeating, entities. <br><font size="2"><font face="Courier, Courier New, monospace"><br></font></font></span>Again, I'll come back to this example from time to time and use it to explain certain concepts. <br><br><br><font face="Arial, sans-serif"><font size="4"><span lang="en-US"><i><b>EXAMPLE 2 - a complex rollup</b></i></span></font></font></p> <p class="western" style="margin-bottom: 0in;"><br> </p> <p style="margin-top: 0.08in; page-break-after: avoid;"><font size="2"><b>Table 5 Table and Data Load Script</b></font></p> <table border="1" bordercolor="#000000" cellpadding="8" cellspacing="0" width="591"> <col width="573"> <tbody><tr> <td height="401" valign="top" width="573"> <p class="western" style="margin-left: 0.06in;"><span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%"><font size="2"><font face="Courier, Courier New, monospace"><font color="#0000ff">CREATE</font> <font color="#0000ff">TABLE</font> <font color="#808000">TESTDATA</font><font color="#000000"><br></font><font color="#0000ff">(</font><font color="#000000"><br> F1 </font><font color="#ff0000">NUMBER</font><font color="#0000ff">,</font><font color="#000000"> F2 </font><font color="#ff0000">NUMBER</font><font color="#0000ff">,</font><font color="#000000"> F3 </font><font color="#ff0000">NUMBER</font><font color="#0000ff">,</font><font color="#000000"> F4 </font><font color="#ff0000">NUMBER</font><font color="#0000ff">,</font><font color="#000000"> F5 </font><font color="#ff0000">NUMBER</font><font color="#0000ff">,</font><font color="#000000"><br> F6 </font><font color="#ff0000">NUMBER</font><font color="#0000ff">,</font><font color="#000000"> F7 </font><font color="#ff0000">NUMBER</font><font color="#0000ff">,</font><font color="#000000"> F8 </font><font color="#ff0000">NUMBER</font><font color="#0000ff">,</font><font color="#000000"> F9 </font><font color="#ff0000">NUMBER</font><font color="#0000ff">,</font><font color="#000000"> F10 </font><font color="#ff0000">NUMBER</font><font color="#0000ff">,</font><font color="#000000"><br> F11 </font><font color="#ff0000">NUMBER</font><font color="#0000ff">,</font><font color="#000000"> F12 </font><font color="#ff0000">NUMBER</font><font color="#0000ff">,</font><font color="#000000"> F13 </font><font color="#ff0000">NUMBER</font><font color="#0000ff">,</font><font color="#000000"> F14 </font><font color="#ff0000">NUMBER</font><font color="#0000ff">);</font><font color="#000000"><br><br></font><font color="#0000ff">Insert</font> <font color="#0000ff">into</font> <font color="#808000">TESTDATA</font><font color="#000000"><br> </font><font color="#0000ff">(</font><font color="#000000">F1</font><font color="#0000ff">,</font><font color="#000000"> F2</font><font color="#0000ff">,</font><font color="#000000"> F3</font><font color="#0000ff">,</font><font color="#000000"> F4</font><font color="#0000ff">,</font><font color="#000000"> F5</font><font color="#0000ff">,</font><font color="#000000"> F6</font><font color="#0000ff">,</font><font color="#000000"> F7</font><font color="#0000ff">,</font><font color="#000000"> F8</font><font color="#0000ff">,</font><font color="#000000"> F9</font><font color="#0000ff">,</font><font color="#000000"> F10</font><font color="#0000ff">,</font><font color="#000000"> F11</font><font color="#0000ff">,</font><font color="#000000"> F12</font><font color="#0000ff">,</font><font color="#000000"> F13</font><font color="#0000ff">,</font><font color="#000000"> F14</font><font color="#0000ff">)<br></font> <font color="#0000ff">Values</font> <font color="#0000ff">(</font><font color="#800000">1</font><font color="#0000ff">,</font> <font color="#800000">2</font><font color="#0000ff">,</font> <font color="#800000">3</font><font color="#0000ff">,</font> <font color="#800000">4</font><font color="#0000ff">,</font> <font color="#800000">5</font><font color="#0000ff">,</font> <font color="#800000">6</font><font color="#0000ff">,</font> <b><u><font color="#800000">7</font></u></b><font color="#0000ff">,</font> <font color="#800000">8</font><font color="#0000ff">,</font> <font color="#800000">9</font><font color="#0000ff">,</font> <font color="#800000">10</font><font color="#0000ff">,</font> <font color="#800000">null</font><font color="#0000ff">,</font> <b><u><font color="#800000">12</font><font color="#0000ff">,</font> <font color="#800000">13</font><font color="#0000ff">,</font> <font color="#800000">14</font></u></b><font color="#0000ff">);<br>Insert</font> <font color="#0000ff">into</font> <font color="#808000">TESTDATA<br></font> <font color="#0000ff">(</font><font color="#000000">F1</font><font color="#0000ff">,</font><font color="#000000"> F2</font><font color="#0000ff">,</font><font color="#000000"> F3</font><font color="#0000ff">,</font><font color="#000000"> F4</font><font color="#0000ff">,</font><font color="#000000"> F5</font><font color="#0000ff">,</font><font color="#000000"> F6</font><font color="#0000ff">,</font><font color="#000000"> F7</font><font color="#0000ff">,</font><font color="#000000"> F8</font><font color="#0000ff">,</font><font color="#000000"> F9</font><font color="#0000ff">,</font><font color="#000000"> F10</font><font color="#0000ff">,</font><font color="#000000"> F11</font><font color="#0000ff">,</font><font color="#000000"> F12</font><font color="#0000ff">,</font><font color="#000000"> F13</font><font color="#0000ff">,</font><font color="#000000"> F14</font><font color="#0000ff">)</font><font color="#000000"><br> </font><font color="#0000ff">Values</font> <font color="#0000ff">(</font><font color="#800000">1</font><font color="#0000ff">,</font> <font color="#800000">2</font><font color="#0000ff">,</font> <font color="#800000">3</font><font color="#0000ff">,</font> <font color="#800000">4</font><font color="#0000ff">,</font> <font color="#800000">5</font><font color="#0000ff">,</font> <font color="#800000">6</font><font color="#0000ff">,</font> <b><u><font color="#800000">7</font></u></b><font color="#0000ff">,</font> <font color="#800000">8</font><font color="#0000ff">,</font> <font color="#800000">9</font><font color="#0000ff">,</font> <font color="#800000">10</font><font color="#0000ff">,</font> <font color="#800000">null</font><font color="#0000ff">,</font> <b><u><font color="#800000">16</font><font color="#0000ff">,</font> <font color="#800000">13</font><font color="#0000ff">,</font> <font color="#800000">14</font></u></b><font color="#0000ff">);</font><font color="#000000"><br></font><font color="#0000ff">Insert</font> <font color="#0000ff">into</font> <font color="#808000">TESTDATA</font><font color="#000000"><br> </font><font color="#0000ff">(</font><font color="#000000">F1</font><font color="#0000ff">,</font><font color="#000000"> F2</font><font color="#0000ff">,</font><font color="#000000"> F3</font><font color="#0000ff">,</font><font color="#000000"> F4</font><font color="#0000ff">,</font><font color="#000000"> F5</font><font color="#0000ff">,</font><font color="#000000"> F6</font><font color="#0000ff">,</font><font color="#000000"> F7</font><font color="#0000ff">,</font><font color="#000000"> F8</font><font color="#0000ff">,</font><font color="#000000"> F9</font><font color="#0000ff">,</font><font color="#000000"> F10</font><font color="#0000ff">,</font><font color="#000000"> F11</font><font color="#0000ff">,</font><font color="#000000"> F12</font><font color="#0000ff">,</font><font color="#000000"> F13</font><font color="#0000ff">,</font><font color="#000000"> F14</font><font color="#0000ff">)</font><font color="#000000"><br> </font><font color="#0000ff">Values</font> <font color="#0000ff">(</font><font color="#800000">1</font><font color="#0000ff">,</font> <font color="#800000">2</font><font color="#0000ff">,</font> <font color="#800000">3</font><font color="#0000ff">,</font> <font color="#800000">4</font><font color="#0000ff">,</font> <font color="#800000">5</font><font color="#0000ff">,</font> <font color="#800000">6</font><font color="#0000ff">,</font> <b><font color="#800000">7</font></b><font color="#0000ff">,</font> <font color="#800000">8</font><font color="#0000ff">,</font> <font color="#800000">9</font><font color="#0000ff">,</font> <font color="#800000">null</font><font color="#0000ff">,</font> <font color="#800000">11</font><font color="#0000ff">,</font> <b><u><font color="#800000">12</font><font color="#0000ff">,</font> <font color="#800000">13</font><font color="#0000ff">,</font> <font color="#800000">14</font></u></b><font color="#0000ff">);</font><font color="#000000"><br></font><font color="#0000ff">Insert</font> <font color="#0000ff">into</font> <font color="#808000">TESTDATA</font><font color="#000000"><br> </font><font color="#0000ff">(</font><font color="#000000">F1</font><font color="#0000ff">,</font><font color="#000000"> F2</font><font color="#0000ff">,</font><font color="#000000"> F3</font><font color="#0000ff">,</font><font color="#000000"> F4</font><font color="#0000ff">,</font><font color="#000000"> F5</font><font color="#0000ff">,</font><font color="#000000"> F6</font><font color="#0000ff">,</font><font color="#000000"> F7</font><font color="#0000ff">,</font><font color="#000000"> F8</font><font color="#0000ff">,</font><font color="#000000"> F9</font><font color="#0000ff">,</font><font color="#000000"> F10</font><font color="#0000ff">,</font><font color="#000000"> F11</font><font color="#0000ff">,</font><font color="#000000"> F12</font><font color="#0000ff">,</font><font color="#000000"> F13</font><font color="#0000ff">,</font><font color="#000000"> F14</font><font color="#0000ff">)</font><font color="#000000"><br> </font><font color="#0000ff">Values</font> <font color="#0000ff">(</font><font color="#800000">1</font><font color="#0000ff">,</font> <font color="#800000">2</font><font color="#0000ff">,</font> <font color="#800000">3</font><font color="#0000ff">,</font> <font color="#800000">4</font><font color="#0000ff">,</font> <font color="#800000">5</font><font color="#0000ff">,</font> <font color="#800000">6</font><font color="#0000ff">,</font> <b><u><font color="#800000">33</font></u></b><font color="#0000ff">,</font> <font color="#800000">8</font><font color="#0000ff">,</font> <font color="#800000">9</font><font color="#0000ff">,</font> <font color="#800000">null</font><font color="#0000ff">,</font> <font color="#800000">11</font><font color="#0000ff">,</font> <b><u><font color="#800000">20</font><font color="#0000ff">,</font> <font color="#800000">20</font><font color="#0000ff">,</font> <font color="#800000">20</font></u></b><font color="#0000ff">);</font><font color="#000000"><br></font><font color="#0000ff">Insert</font> <font color="#0000ff">into</font> <font color="#808000">TESTDATA</font><font color="#000000"><br> </font><font color="#0000ff">(</font><font color="#000000">F1</font><font color="#0000ff">,</font><font color="#000000"> F2</font><font color="#0000ff">,</font><font color="#000000"> F3</font><font color="#0000ff">,</font><font color="#000000"> F4</font><font color="#0000ff">,</font><font color="#000000"> F5</font><font color="#0000ff">,</font><font color="#000000"> F6</font><font color="#0000ff">,</font><font color="#000000"> F7</font><font color="#0000ff">,</font><font color="#000000"> F8</font><font color="#0000ff">,</font><font color="#000000"> F9</font><font color="#0000ff">,</font><font color="#000000"> F10</font><font color="#0000ff">,</font><font color="#000000"> F11</font><font color="#0000ff">,</font><font color="#000000"> F12</font><font color="#0000ff">,</font><font color="#000000"> F13</font><font color="#0000ff">,</font><font color="#000000"> F14</font><font color="#0000ff">)</font><font color="#000000"><br> </font><font color="#0000ff">Values</font> <font color="#0000ff">(</font><font color="#800000">1</font><font color="#0000ff">,</font> <font color="#800000">2</font><font color="#0000ff">,</font> <font color="#800000">3</font><font color="#0000ff">,</font> <font color="#800000">4</font><font color="#0000ff">,</font> <font color="#800000">5</font><font color="#0000ff">,</font> <font color="#800000">6</font><font color="#0000ff">,</font> <b><u><font color="#800000">4</font></u></b><font color="#0000ff">,</font> <font color="#800000">8</font><font color="#0000ff">,</font> <font color="#800000">9</font><font color="#0000ff">,</font> <font color="#800000">null</font><font color="#0000ff">,</font> <font color="#800000">11</font><font color="#0000ff">,</font> <b><u><font color="#800000">22</font><font color="#0000ff">,</font> <font color="#800000">22</font><font color="#0000ff">,</font> <font color="#800000">22</font></u></b><font color="#0000ff">);</font><font color="#000000"><br><br></font><font color="#0000ff">COMMIT</font> <font color="#0000ff">;</font></font></font></span><br><br> </p> </td> </tr> </tbody></table> <p class="western" style="margin-bottom: 0in;"><span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%"><font size="2"><font face="Courier, Courier New, monospace"><font color="#000000"><br></font></font></font></span><br>We'll start with a SELECT which we will build upon later Eventually, this will become part of a <br>SUBQUERY in the final code example. <br>Don't be intimidated by the seeming complexity of this SELECT statement. I plan on walking through<br>it one small section at a time. </p> <p class="western" style="margin-bottom: 0in; page-break-before: always;"> <br> </p> <p style="margin-top: 0.08in; page-break-after: avoid;"><font size="2"><b>Table 6 in the beginning there was SELECT, and God saw that it was good</b></font></p> <table border="1" bordercolor="#000000" cellpadding="8" cellspacing="0" height="365" width="591"> <col width="573"> <tbody><tr> <td height="336" valign="top" width="573"> <p class="western" style="margin-left: 0.06in;"><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Select</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">F1</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">F2</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F3</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F4</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F5</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F6</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F7</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F8</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F9</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F10</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F11</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><br> </span><span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">F12</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F13</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F14</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Count(</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">*</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">)</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2"> Cnt</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><br> </span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Grouping(</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">F1</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">)</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2"> G1</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Grouping(</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">F2</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">)</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2"> G2</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><br> </span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Grouping(</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">F2</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">)</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2"> G3</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Grouping(</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F4</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">)</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2"> G4</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Grouping(</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F5</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">)</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2"> G5</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><br> </span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Grouping(</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F6</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">)</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2"> G6</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Grouping(</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F7</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">)</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2"> G7</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Grouping(</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F8</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">)</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2"> G8</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><br> </span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Grouping(</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F9</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">)</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2"> G9</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Grouping(</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F10</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">)</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2"> G10</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Grouping(</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F11</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">)</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2"> G11</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><br> </span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Grouping(</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">F12</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">)</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2"> G12</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Grouping(</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F13</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">)</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2"> G13</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Grouping(</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F14</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">)</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2"> G14<br> </font> </span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">From</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">Testdata</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><br> </span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Group</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">By</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">F1</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><br> </span><span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">F2</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><br> </span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Grouping</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Sets(Rollup(</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F3</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2"> F4</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2"> F5</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2"> F6</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">)),</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><br> </span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Grouping</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Sets(Rollup(</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F7</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">)),</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><br> </span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Grouping</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Sets(Rollup(</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F8</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">)),</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><br> </span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Grouping</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Sets(Rollup(</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F9</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2"> F10</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">),</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Rollup(</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F9</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2"> F11</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">)),</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><br> </span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Grouping</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Sets(Rollup((</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">F12</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2"> F13</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">,</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2"> F14</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">)))</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><br> </span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Having</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">GROUP_ID()</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">=</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: maroon"><font size="2">0</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><br> </span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">And</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Not(</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F10 </font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Is</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Null</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><br> </span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">And</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Grouping(</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F10</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">)</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">=</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: maroon"><font size="2">0</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">)</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><br> </span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">And</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Not(</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F11 </font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Is</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Null</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><br> </span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">And</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">Grouping(</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: olive"><font size="2">X</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">.</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><font size="2">F11</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">)</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">=</font></span> <span style="background: white none repeat scroll 0%; font-family: Courier; color: maroon"><font size="2">0</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: blue"><font size="2">);</font></span><span style="background: white none repeat scroll 0%; font-family: Courier; color: black"><br><font size="2"> <br> </font></span></p> </td> </tr> </tbody></table> <p class="western" style="margin-bottom: 0in;"><br> <br>In this example, f1 thru f11 are the dimensions and are analogous to the city/shipper/deliveryperson hierarchy shown in the first example. f12, f13 and f14 represent the entity for which we may or may not produce rollups depending on the aggregated counts of detail records in f1 and f7. f12, f13 and f14 are analogous to ''customer'' from the first example. COUNT(*) is our measure. Having minimums on F1 and F7 was an arbitrary choice for the sake of this example. A real-world example might have minimums applied to any or all levels of the rollup hierarchy<br><br> <br><font size="2"><font face="Courier, Courier New, monospace"><font color="#000000"><br></font></font></font><font face="Arial, sans-serif"><font style="font-size: 13pt;" size="3"><span lang="en-US"><b>GROUP BY</b></span></font></font><font size="2"><font face="Courier, Courier New, monospace"><font color="#000000"><br></font></font></font><br> </p> <p class="western" style="margin-bottom: 0in; page-break-before: always;"> Lets start by deconstructing the GROUP BY clause.<br><br> </p> <p style="margin-top: 0.08in; page-break-after: avoid;"><font size="2"><b>Table 7</b></font></p> <table border="1" bordercolor="#000000" cellpadding="8" cellspacing="0" width="549"> <col width="531"> <tbody><tr> <td height="14" valign="top" width="531"> <p class="western"><span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%"><font size="2"><font face="Courier, Courier New, monospace"><font color="#0000ff">GROUP</font> <font color="#0000ff">BY</font><font color="#000000"> f1</font><font color="#0000ff">,</font><font color="#000000"> f2</font><font color="#0000ff">,</font><font color="#000000"><br> </font><font color="#0000ff">GROUPING</font> <font color="#0000ff">SETS(ROLLUP(</font><font color="#000000">f3</font><font color="#0000ff">,</font><font color="#000000"> f4</font><font color="#0000ff">,</font><font color="#000000"> f5</font><font color="#0000ff">,</font><font color="#000000"> f6</font><font color="#0000ff">)),</font><font color="#000000"><br> </font><font color="#0000ff">GROUPING</font> <font color="#0000ff">SETS(ROLLUP(</font><font color="#000000">f7</font><font color="#0000ff">)),</font><font color="#000000"><br> </font><font color="#0000ff">GROUPING</font> <font color="#0000ff">SETS(ROLLUP(</font><font color="#000000">f8</font><font color="#0000ff">)),</font><font color="#000000"><br> </font><font color="#0000ff">GROUPING</font> <font color="#0000ff">SETS(ROLLUP(</font><font color="#000000">f9</font><font color="#0000ff">,</font><font color="#000000"> f10</font><font color="#0000ff">),</font> <font color="#0000ff">ROLLUP(</font><font color="#000000">f9</font><font color="#0000ff">,</font><font color="#000000"> f11</font><font color="#0000ff">))</font></font></font></span></p> </td> </tr> </tbody></table> <p class="western" style="margin-bottom: 0in;"><br> </p> <p class="western" style="margin-bottom: 0in; page-break-before: always;"> <span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%"><u><font size="2"><font face="Courier, Courier New, monospace"><font color="#0000ff">GROUP</font> <font color="#0000ff">BY</font><font color="#000000"> f1</font><font color="#0000ff">,</font><font color="#000000"> f2</font></font></font></u></span></p> <p class="western" style="margin-bottom: 0in; page-break-after: avoid;"> <br>All f1's will be followed by an f2 value. aggregate values will be given for the f1,f2 combination, but not for f1 alone.<br>[f1,f2, aggregates] is a valid combination.<br><br><span lang=""><img src="http://docs.google.com/File?id=dcdpzkfh_177cx3crsf2"></span></p> <p style="margin-top: 0.08in;"><font size="2"><b>Figure 1</b></font></p> <p class="western" style="margin-bottom: 0in;"><br><br><br><span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%"><u><font size="2"><font face="Courier, Courier New, monospace"><font color="#0000ff">GROUPING</font> <font color="#0000ff">SETS(ROLLUP(</font><font color="#000000">f3</font><font color="#0000ff">,</font><font color="#000000"> f4</font><font color="#0000ff">,</font><font color="#000000"> f5</font><font color="#0000ff">,</font><font color="#000000"> f6</font><font color="#0000ff">))</font></font></font></u></span></p> <p class="western" style="margin-bottom: 0in; page-break-after: avoid;"> f3, f4, f5and f6 act as a group, therefor the following combinations are valid<br><span lang=""><img src="http://docs.google.com/File?id=dcdpzkfh_178fdjgmhcd"></span></p> <p style="margin-top: 0.08in;"><font size="2"><b>Figure 2</b></font></p> <p class="western" style="margin-bottom: 0in;"><br>F6 must always be preceded by f5 which must in turn be preceded by f4, which must in turn be preceded by f3.<br>Combinations like, [f1, f2, f3, f5, f6, aggregates] will not be produced because, in this case, f5 is not preceded by f4.<br><br><br><font size="2"><font face="Courier, Courier New, monospace"><span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%"><u><font color="#0000ff">GROUPING</font> <font color="#0000ff">SETS(ROLLUP(</font><font color="#000000">f7</font><font color="#0000ff">))</font></u></span> </font></font> </p> <p class="western" style="margin-bottom: 0in; page-break-after: avoid;"> F7 will be appended to all of the previous combinations which adds these new combinations to those previously mentioned.<br><br><span lang=""><img src="http://docs.google.com/File?id=dcdpzkfh_179d4r9vsf6"></span></p> <p style="margin-top: 0.08in;"><font size="2"><b>Figure 3</b></font></p> <p class="western" style="margin-bottom: 0in;"><br><br><br><span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%"><u><font size="2"><font face="Courier, Courier New, monospace"><font color="#0000ff">GROUPING</font> <font color="#0000ff">SETS(ROLLUP(</font><font color="#000000">f8</font><font color="#0000ff">))</font></font></font></u></span></p> <p class="western" style="margin-bottom: 0in; page-break-after: avoid;"> F8 will be appended to all of the previous combinations which adds these new combinations to those previously mentioned<br><br><span lang=""><img src="http://docs.google.com/File?id=dcdpzkfh_180ds7p5fgs"></span></p> <p style="margin-top: 0.08in;"><font size="2"><b>Figure 4</b></font></p> <p class="western" style="margin-bottom: 0in;"><br><br><br><span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%"><u><font size="2"><font face="Courier, Courier New, monospace"><font color="#0000ff">GROUPING</font> <font color="#0000ff">SETS(ROLLUP(</font><font color="#000000">f9</font><font color="#0000ff">,</font><font color="#000000"> f10</font><font color="#0000ff">),</font> <font color="#0000ff">ROLLUP(</font><font color="#000000">f9</font><font color="#0000ff">,</font><font color="#000000"> f11</font><font color="#0000ff">))</font></font></font></u></span></p> <p class="western" style="margin-bottom: 0in; page-break-after: avoid;"> This grouping set says three things:<br> First, make additional combinations by appending f9 to each of the previously mentioned combinations.<br><br><span lang=""><img src="http://docs.google.com/File?id=dcdpzkfh_181fx53nrcq"></span></p> <p style="margin-top: 0.08in;"><font size="2"><b>Figure 5</b></font></p> <p class="western" style="margin-bottom: 0in; page-break-after: avoid;"> <br><br>Second, make additional combinations by appending f10 to any sequence ending with an f9, giving ...<br><br><span lang=""><img src="http://docs.google.com/File?id=dcdpzkfh_182d6kzg5hq"></span></p> <p style="margin-top: 0.08in;"><font size="2"><b>Figure 6</b></font></p> <p class="western" style="margin-bottom: 0in; page-break-after: avoid;"> <br><br>Third, make additional combinations by appending f11 to any sequence ending with an f9 as shown below.<br> Note that f10 is never followed by f11. This <font size="2"><font face="Courier, Courier New, monospace"><span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%"><font color="#0000ff">"GROUPING</font> <font color="#0000ff">SETS(ROLLUP(</font><font color="#000000">f9</font><font color="#0000ff">,</font><font color="#000000"> f10</font><font color="#0000ff">),</font> <font color="#0000ff">ROLLUP(</font><font color="#000000">f9</font><font color="#0000ff">,</font><font color="#000000"> f11</font><font color="#0000ff">))</font></span><font color="#0000ff">" </font></font></font>structure is useful for handling mutually exclusive columns of data. For example you might have [State + MetroArea] or [State + City] but never both MetroArea and City.<br><br><br><span lang=""><img src="http://docs.google.com/File?id=dcdpzkfh_183c8hvp8dh"></span></p> <p style="margin-top: 0.08in;"><font size="2"><b>Figure 7</b></font></p> <p class="western" style="margin-bottom: 0in;"><br><br> </p> <table border="1" bordercolor="#000000" cellpadding="8" cellspacing="0" height="381" width="590"> <col width="545"> <tbody><tr> <td valign="top" width="545"> <p class="western" style="page-break-after: avoid;"><img src="http://docs.google.com/File?id=dcdpzkfh_184hk9dm7fp"><img src="http://docs.google.com/File?id=dcdpzkfh_185dvfqmc6"><img src="http://docs.google.com/File?id=dcdpzkfh_186dd2vwbck"><br><br><span lang=""><img src="http://docs.google.com/File?id=dcdpzkfh_187gz53fxds"><img src="http://docs.google.com/File?id=dcdpzkfh_188hq68ksdh"><img src="http://docs.google.com/File?id=dcdpzkfh_189gk6bbhf4"><img src="http://docs.google.com/File?id=dcdpzkfh_190q55sv7gw"></span><br><br> </p> </td> </tr> </tbody></table> <p style="margin-top: 0.08in;"><font size="2"><b>Figure 8</b></font></p> <p class="western" style="margin-bottom: 0in;"><br><br><br> </p> <h3 class="western">Having<br> </h3> <table border="1" bordercolor="#000000" cellpadding="8" cellspacing="0" width="561"> <col width="543"> <tbody><tr> <td height="105" valign="top" width="543"> <h3 class="western"> <span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: blue;"><font size="2">Having</font></span> <span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: blue;"><font size="2">GROUP_ID()</font></span> <span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: blue;"><font size="2">=</font></span> <span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: maroon;"><font size="2">0</font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: black;"><br> </span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: blue;"><font size="2">And</font></span> <span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: blue;"><font size="2">Not(</font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: black;"> <font size="2">F10 </font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: blue;"><font size="2">Is</font></span> <span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: blue;"><font size="2">Null</font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: black;"><br> </span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: blue;"><font size="2">And</font></span> <span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: blue;"><font size="2">Grouping(</font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: olive;"><font size="2">X</font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: blue;"><font size="2">.</font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: black;"><font size="2">F10</font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: blue;"><font size="2">)</font></span> <span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: blue;"><font size="2">=</font></span> <span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: maroon;"><font size="2">0</font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: blue;"><font size="2">)</font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: black;"><br> </span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: blue;"><font size="2">And</font></span> <span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: blue;"><font size="2">Not(</font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: black;"> <font size="2">F11 </font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: blue;"><font size="2">Is</font></span> <span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: blue;"><font size="2">Null</font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: black;"><br> </span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: blue;"><font size="2">And</font></span> <span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: blue;"><font size="2">Grouping(</font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: olive;"><font size="2">X</font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: blue;"><font size="2">.</font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: black;"><font size="2">F11</font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: blue;"><font size="2">)</font></span> <span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: blue;"><font size="2">=</font></span> <span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: maroon;"><font size="2">0</font></span><span style="background: white none repeat scroll 0% 50%; font-family: Courier; color: blue;"><font size="2">);</font></span></h3> </td> </tr> </tbody></table> <p class="western" style="margin-bottom: 0in;"><br>The HAVING clause is doing several things. It might look complicated, but we'll address it one piece at a time starting with the first line<font face="Courier New, monospace">. GROUP_ID() = 0 </font>prevents duplicate rollup rows. I am not going to talk about why there could be duplicate rollups. If you are interested, a simple web search will get that information. I can't think of any reason why anybody would ever want duplicate rollups.<br><br>The next few predicates dealing with nulls are there to clean up a problem that was created by the bifurcated treatment of f10 and f11. It might help to recall what was said earlier:</p> <p class="western" style="margin-left: 0.5in; margin-bottom: 0in;"><i>Note that f10 is never followed by f11. This <font size="2"><font face="Courier, Courier New, monospace"><span style="background: rgb(255, 255, 255) none repeat scroll 0% 50%"><font color="#0000ff">"GROUPING</font> <font color="#0000ff">SETS(ROLLUP(</font><font color="#000000">f9</font><font color="#0000ff">,</font><font color="#000000"> f10</font><font color="#0000ff">),</font> <font color="#0000ff">ROLLUP(</font><font color="#000000">f9</font><font color="#0000ff">,</font><font color="#000000"> f11</font><font color="#0000ff">))</font></span><font color="#0000ff">" </font></font></font>structure is useful for handling mutually exclusive columns of data. For example you might have [State + MetroArea] or [State + City] but never both MetroArea and City.</i></p> <p class="western" style="margin-bottom: 0in;"><br><br>So, when f10 has a value, f11 will be null, and visa-versa. These nulls in the input data will cause rollups that we are not interested in. The following SELECT statement demonstrates this point. If you are not familiar with the GROUPING function, simply put, it produces a 1 or a 0 which indicates if the function argument column is a data level or a summary level for the current row of the result set. For example, "<font size="2"><font face="Courier New, monospace"><font color="#000000">GROUPING</font><font color="#0000f0">(</font><font color="#000000">x</font><font color="#0000f0">.</font><font color="#000000">f10</font><font color="#0000f0">)</font><font color="#000000">" </font></font></font><font color="#000000">tells if x.f10 is a data level or a summary level for the current row.</font> 1 means summary level, 0 means data level.<br><br> </p> <p class="western" style="margin-bottom: 0in; page-break-before: always;"> <br> </p> <table border="1" bordercolor="#000000" cellpadding="8" cellspacing="0" width="557"> <col width="539"> <tbody><tr> <td height="25" valign="top" width="539"> <p class="western" style="page-break-after: avoid;"><span style="font-family: Courier; color: blue;"><font size="2">Select</font></span> <span style="font-family: Courier; color: olive;"><font size="2">X</font></span><span style="font-family: Courier; color: blue;"><font size="2">.</font></span><span style="font-family: Courier; color: black;"><font size="2">F9</font></span><span style="font-family: Courier; color: blue;"><font size="2">,</font></span><span style="font-family: Courier; color: black;"><br> </span><span style="font-family: Courier; color: olive;"><font size="2">X</font></span><span style="font-family: Courier; color: blue;"><font size="2">.</font></span><span style="font-family: Courier; color: black;"><font size="2">F10</font></span><span style="font-family: Courier; color: blue;"><font size="2">,</font></span><span style="font-family: Courier; color: black;"><br> </span><span style="font-family: Courier; color: olive;"><font size="2">X</font></span><span style="font-family: Courier; color: blue;"><font size="2">.</font></span><span style="font-family: Courier; color: black;"><font size="2">F11</font></span><span style="font-family: Courier; color: blue;"><font size="2">,</font></span><span style="font-family: Courier; color: black;"><br> </span><span style="font-family: Courier; color: blue;"><font size="2">Count(</font></span><span style="font-family: Courier; color: black;"><font size="2">*</font></span><span style="font-family: Courier; color: blue;"><font size="2">)</font></span><span style="font-family: Courier; color: black;"><font size="2"> Cnt</font></span><span style="font-family: Courier; color: blue;"><font size="2">,</font></span><span style="font-family: Courier; color: black;"><br> </span><span style="font-family: Courier; color: blue;"><font size="2">Grouping(</font></span><span style="font-family: Courier; color: olive;"><font size="2">X</font></span><span style="font-family: Courier; color: blue;"><font size="2">.</font></span><span style="font-family: Courier; color: black;"><font size="2">F9</font></span><span style="font-family: Courier; color: blue;"><font size="2">)</font></span><span style="font-family: Courier; color: black;"><font size="2"> G9</font></span><span style="font-family: Courier; color: blue;"><font size="2">,</font></span><span style="font-family: Courier; color: black;"><br> </span><span style="font-family: Courier; color: blue;"><font size="2">Grouping(</font></span><span style="font-family: Courier; color: olive;"><font size="2">X</font></span><span style="font-family: Courier; color: blue;"><font size="2">.</font></span><span style="font-family: Courier; color: black;"><font size="2">F10</font></span><span style="font-family: Courier; color: blue;"><font size="2">)</font></span><span style="font-family: Courier; color: black;"><font size="2"> G10</font></span><span style="font-family: Courier; color: blue;"><font size="2">,</font></span><span style="font-family: Courier; color: black;"><br> </span><span style="font-family: Courier; color: blue;"><font size="2">Grouping(</font></span><span style="font-family: Courier; color: olive;"><font size="2">X</font></span><span style="font-family: Courier; color: blue;"><font size="2">.</font></span><span style="font-family: Courier; color: black;"><font size="2">F11</font></span><span style="font-family: Courier; color: blue;"><font size="2">)</font></span><span style="font-family: Courier; color: black;"><font size="2"> G11<br> </font> </span><span style="font-family: Courier; color: blue;"><font size="2">From</font></span> <span style="font-family: Courier; color: olive;"><font size="2">Testdata</font></span> <span style="font-family: Courier; color: olive;"><font size="2">X</font></span><span style="font-family: Courier; color: black;"><br> </span><span style="font-family: Courier; color: blue;"><font size="2">Group</font></span> <span style="font-family: Courier; color: blue;"><font size="2">By</font></span> <span style="font-family: Courier; color: olive;"><font size="2">F1</font></span><span style="font-family: Courier; color: blue;"><font size="2">,</font></span><span style="font-family: Courier; color: black;"><br> </span><span style="font-family: Courier; color: blue;"><font size="2">Grouping</font></span> <span style="font-family: Courier; color: blue;"><font size="2">Sets(Rollup(</font></span><span style="font-family: Courier; color: black;"><font size="2">F9</font></span><span style="font-family: Courier; color: blue;"><font size="2">,</font></span><span style="font-family: Courier; color: black;"><font size="2"> F10</font></span><span style="font-family: Courier; color: blue;"><font size="2">),</font></span> <span style="font-family: Courier; color: blue;"><font size="2">Rollup(</font></span><span style="font-family: Courier; color: black;"><font size="2">F9</font></span><span style="font-family: Courier; color: blue;"><font size="2">,</font></span><span style="font-family: Courier; color: black;"><font size="2"> F11</font></span><span style="font-family: Courier; color: blue;"><font size="2">))</font></span><span style="font-family: Courier; color: black;"><br> </span><span style="font-family: "Courier New"; color: blue;"><font size="2">Having</font></span> <span style="font-family: Courier; color: blue;"><font size="2">GROUP_ID()</font></span> <span style="font-family: Courier; color: blue;"><font size="2">=</font></span> <span style="font-family: Courier; color: maroon;"><font size="2">0</font></span><span style="font-family: Courier; color: blue;"><font size="2">;</font></span><span style="font-family: Courier; color: black;"><br><font size="2"> <br> </font></span></p> </td> </tr> </tbody></table> <p style="margin-top: 0.08in;"><font size="2"><b>Figure 9 SELECT showing only bifurcated part of rollup</b></font></p> <p class="western" style="margin-bottom: 0in;">In the resulting table below, we can see that there appears to be three rows that rollup to the f9 level, rows 1, 3 and 5. However, when we look at the GROUPING for the first row, we see that it is really a (f9, f10) level rollup where f10 is null. Likewise, row 3 is really a (f9, f11) level rollup where f11 is null. If the data corresponded to our [State + MetroArea] or [State + City] <br><br> </p> <p style="margin-top: 0.08in; page-break-after: avoid;"><a name="_Ref178738690"></a> <font size="2"><b>Table 8 Bifurcated rollup result set using table testdata</b></font></p> <table border="1" bordercolor="#000000" cellpadding="1" cellspacing="0" width="189"> <col width="18"> <col width="26"> <col width="26"> <col width="26"> <col width="20"> <col width="29"> <col width="29"> <tbody><tr> <td bgcolor="#e6e6e6" height="17" width="18"> <p class="western"><b>f9</b></p> </td> <td bgcolor="#e6e6e6" width="26"> <p class="western"><b>f10</b></p> </td> <td bgcolor="#e6e6e6" width="26"> <p class="western"><b>f11</b></p> </td> <td bgcolor="#e6e6e6" width="26"> <p class="western"><b>cnt</b></p> </td> <td bgcolor="#e6e6e6" width="20"> <p class="western"><b>g9</b></p> </td> <td bgcolor="#e6e6e6" width="29"> <p class="western"><b>g10</b></p> </td> <td bgcolor="#e6e6e6" width="29"> <p class="western"><b>g11</b></p> </td> </tr> <tr> <td bgcolor="#ccffff" height="18" width="18"> <p class="western">9</p> </td> <td bgcolor="#ccffff" width="26"> <p class="western"> </p> </td> <td bgcolor="#ffcc99" width="26"> <p class="western"> </p> </td> <td width="26"> <p class="western">3</p> </td> <td width="20"> <p class="western">0</p> </td> <td width="29"> <p class="western">0</p> </td> <td width="29"> <p class="western">1</p> </td> </tr> <tr> <td bgcolor="#ccffff" height="18" width="18"> <p class="western">9</p> </td> <td bgcolor="#ccffff" width="26"> <p class="western">10</p> </td> <td bgcolor="#ffcc99" width="26"> <p class="western"> </p> </td> <td width="26"> <p class="western">2</p> </td> <td width="20"> <p class="western">0</p> </td> <td width="29"> <p class="western">0</p> </td> <td width="29"> <p class="western">1</p> </td> </tr> <tr> <td bgcolor="#ccffff" height="18" width="18"> <p class="western">9</p> </td> <td bgcolor="#ffcc99" width="26"> <p class="western"> </p> </td> <td bgcolor="#ccffff" width="26"> <p class="western"><br> </p> </td> <td width="26"> <p class="western">2</p> </td> <td width="20"> <p class="western">0</p> </td> <td width="29"> <p class="western">1</p> </td> <td width="29"> <p class="western">0</p> </td> </tr> <tr> <td bgcolor="#ccffff" height="18" width="18"> <p class="western">9</p> </td> <td bgcolor="#ffcc99" width="26"> <p class="western"> </p> </td> <td bgcolor="#ccffff" width="26"> <p class="western">11</p> </td> <td width="26"> <p class="western">3</p> </td> <td width="20"> <p class="western">0</p> </td> <td width="29"> <p class="western">1</p> </td> <td width="29"> <p class="western">0</p> </td> </tr> <tr> <td bgcolor="#ccffff" height="18" width="18"> <p class="western">9</p> </td> <td bgcolor="#ffcc99" width="26"> <p class="western"> </p> </td> <td bgcolor="#ffcc99" width="26"> <p class="western"> </p> </td> <td width="26"> <p class="western">5</p> </td> <td width="20"> <p class="western">0</p> </td> <td width="29"> <p class="western">1</p> </td> <td width="29"> <p class="western">1</p> </td> </tr> <tr> <td bgcolor="#ffcc99" height="17" width="18"> <p class="western"> </p> </td> <td bgcolor="#ffcc99" width="26"> <p class="western"> </p> </td> <td bgcolor="#ffcc99" width="26"> <p class="western"> </p> </td> <td width="26"> <p class="western">5</p> </td> <td width="20"> <p class="western">1</p> </td> <td width="29"> <p class="western">1</p> </td> <td width="29"> <p class="western">1</p> </td> </tr> </tbody></table> <p class="western" style="margin-bottom: 0in;"><br> </p> <p class="western" style="margin-bottom: 0in; page-break-before: always;"> If the data corresponded to our [State + MetroArea] or [State + City] example, the data might look something like this:<br>Consider [CA,null]. This would be an aggregate level that represented all Metro Areas for CA which are unknown. Since all of our City records have 'unknown' as the Metro, the cnt = 3 on row 1 is the count (or rollup) of all records which contain valid City data! Clearly, this is not the right way to go about getting "count(*) for all cities". If you did want that information, the proper way to get it would be to add a LocationType column so that the rollup might look like [City,LocationType, Metro,City].. The question at hand is how to get rid of rows 1 and 3 in Table 8 which for our application are nonsense. So, how might we state the problem in English? How about:<br>"I want to drop any row that looks like a Metro level rollup but has a null for the metro." You might be temped to try a HAVING clause that looks like:<br>"HAVING METRO IS NOT NULL" , but oops, that would take out rows 3, 4, 5 and 6 as well. How about </p> <p class="western" style="margin-bottom: 0in;">"HAVING METRO IS NOT NULL AND CITY IS NOT NULL" . Almost, it will get rid of rows 1 and 3 as desired; unfortunately it will also get rid of rows 5 and 6, which we'd kind of like to keep. What we would really like to do is to get rid of [State=CA,Metro=null] records ONLY when Metro is not supposed to be null. And how do we know if Metro is supposed to be null or not? If you haven't guess by now, we'll have to look at the GROUPING columns. Remember, a 0 means that we should expect to find data, not a NULL. Right there in the gMetro column of row 1 it tells us that Metro is <i>not</i> a rollup level. <br><br> </p> <p style="margin-top: 0.08in; page-break-after: avoid;"><font size="2"><b>Table 9 bifurcated rollup substituting example names</b></font></p> <table border="1" bordercolor="#000000" cellpadding="1" cellspacing="0" width="362"> <col width="40"> <col width="90"> <col width="43"> <col width="26"> <col width="48"> <col width="56"> <col width="43"> <tbody><tr> <td bgcolor="#e6e6e6" height="17" width="40"> <p class="western"><b>State</b></p> </td> <td bgcolor="#e6e6e6" width="90"> <p class="western"><b>Metro</b></p> </td> <td bgcolor="#e6e6e6" width="43"> <p class="western"><b>City</b></p> </td> <td bgcolor="#e6e6e6" width="26"> <p class="western"><b>cnt</b></p> </td> <td bgcolor="#e6e6e6" width="48"> <p class="western"><b>gState</b></p> </td> <td bgcolor="#e6e6e6" width="56"> <p class="western"><b>gMetro</b></p> </td> <td bgcolor="#e6e6e6" width="43"> <p class="western"><b>gCity</b></p> </td> </tr> <tr> <td bgcolor="#ccffff" height="18" width="40"> <p class="western">CA</p> </td> <td bgcolor="#ccffff" width="90"> <p class="western"> </p> </td> <td bgcolor="#ffcc99" width="43"> <p class="western"> </p> </td> <td width="26"> <p class="western">3</p> </td> <td width="48"> <p class="western">0</p> </td> <td width="56"> <p class="western">0</p> </td> <td width="43"> <p class="western">1</p> </td> </tr> <tr> <td bgcolor="#ccffff" height="18" width="40"> <p class="western">CA</p> </td> <td bgcolor="#ccffff" width="90"> <p class="western">SF Bay Area</p> </td> <td bgcolor="#ffcc99" width="43"> <p class="western"> </p> </td> <td width="26"> <p class="western">2</p> </td> <td width="48"> <p class="western">0</p> </td> <td width="56"> <p class="western">0</p> </td> <td width="43"> <p class="western">1</p> </td> </tr> <tr> <td bgcolor="#ccffff" height="18" width="40"> <p class="western">CA</p> </td> <td bgcolor="#ffcc99" width="90"> <p class="western"> </p> </td> <td bgcolor="#ccffff" width="43"> <p class="western"><br> </p> </td> <td width="26"> <p class="western">2</p> </td> <td width="48"> <p class="western">0</p> </td> <td width="56"> <p class="western">1</p> </td> <td width="43"> <p class="western">0</p> </td> </tr> <tr> <td bgcolor="#ccffff" height="18" width="40"> <p class="western">CA</p> </td> <td bgcolor="#ffcc99" width="90"> <p class="western"> </p> </td> <td bgcolor="#ccffff" width="43"> <p class="western">Baker</p> </td> <td width="26"> <p class="western">3</p> </td> <td width="48"> <p class="western">0</p> </td> <td width="56"> <p class="western">1</p> </td> <td width="43"> <p class="western">0</p> </td> </tr> <tr> <td bgcolor="#ccffff" height="18" width="40"> <p class="western">CA</p> </td> <td bgcolor="#ffcc99" width="90"> <p class="western"> </p> </td> <td bgcolor="#ffcc99" width="43"> <p class="western"> </p> </td> <td width="26"> <p class="western">5</p> </td> <td width="48"> <p class="western">0</p> </td> <td width="56"> <p class="western">1</p> </td> <td width="43"> <p class="western">1</p> </td> </tr> <tr> <td bgcolor="#ffcc99" height="17" width="40"> <p class="western"> </p> </td> <td bgcolor="#ffcc99" width="90"> <p class="western"> </p> </td> <td bgcolor="#ffcc99" width="43"> <p class="western"> </p> </td> <td width="26"> <p class="western">5</p> </td> <td width="48"> <p class="western">1</p> </td> <td width="56"> <p class="western">1</p> </td> <td width="43"> <p class="western">1</p> </td> </tr> </tbody></table> <p class="western" style="margin-bottom: 0in;"><br> </p> <p style="margin-top: 0.08in;"><font size="2"><b>Figure 10 Solution for removinf NULL rollup rows </b></font> </p> <table border="1" bordercolor="#000000" cellpadding="8" cellspacing="0" width="617"> <col width="599"> <tbody><tr> <td height="90" valign="top" width="599"> <p class="western"><span style="font-family: Courier; color: blue;"><font size="2">Select</font></span> <span style="font-family: Courier; color: olive;"><font size="2">X</font></span><span style="font-family: Courier; color: blue;"><font size="2">.</font></span><span style="font-family: Courier; color: black;"><font size="2">F9</font></span><span style="font-family: Courier; color: blue;"><font size="2">,</font></span><span style="font-family: Courier; color: black;"><br> </span><span style="font-family: Courier; color: olive;"><font size="2">X</font></span><span style="font-family: Courier; color: blue;"><font size="2">.</font></span><span style="font-family: Courier; color: black;"><font size="2">F10</font></span><span style="font-family: Courier; color: blue;"><font size="2">,</font></span><span style="font-family: Courier; color: black;"><br> </span><span style="font-family: Courier; color: olive;"><font size="2">X</font></span><span style="font-family: Courier; color: blue;"><font size="2">.</font></span><span style="font-family: Courier; color: black;"><font size="2">F11</font></span><span style="font-family: Courier; color: blue;"><font size="2">,</font></span><span style="font-family: Courier; color: black;"><br> </span><span style="font-family: Courier; color: blue;"><font size="2">Count(</font></span><span style="font-family: Courier; color: black;"><font size="2">*</font></span><span style="font-family: Courier; color: blue;"><font size="2">)</font></span><span style="font-family: Courier; color: black;"><font size="2"> Cnt</font></span><span style="font-family: Courier; color: blue;"><font size="2">,</font></span><span style="font-family: Courier; color: black;"><br> </span><span style="font-family: Courier; color: blue;"><font size="2">Grouping(</font></span><span style="font-family: Courier; color: olive;"><font size="2">X</font></span><span style="font-family: Courier; color: blue;"><font size="2">.</font></span><span style="font-family: Courier; color: black;"><font size="2">F9</font></span><span style="font-family: Courier; color: blue;"><font size="2">)</font></span><span style="font-family: Courier; color: black;"><font size="2"> G9</font></span><span style="font-family: Courier; color: blue;"><font size="2">,</font></span><span style="font-family: Courier; color: black;"><br> </span><span style="font-family: Courier; color: blue;"><font size="2">Grouping(</font></span><span style="font-family: Courier; color: olive;"><font size="2">X</font></span><span style="font-family: Courier; color: blue;"><font size="2">.</font></span><span style="font-family: Courier; color: black;"><font size="2">F10</font></span><span style="font-family: Courier; color: blue;"><font size="2">)</font></span><span style="font-family: Courier; color: black;"><font size="2"> G10</font></span><span style="font-family: Courier; color: blue;"><font size="2">,</font></span><span style="font-family: Courier; color: black;"><br> </span><span style="font-family: Courier; color: blue;"><font size="2">Grouping(</font></span><span style="font-family: Courier; color: olive;"><font size="2">X</font></span><span style="font-family: Courier; color: blue;"><font size="2">.</font></span><span style="font-family: Courier; color: black;"><font size="2">F11</font></span><span style="font-family: Courier; color: blue;"><font size="2">)</font></span><span style="font-family: Courier; color: black;"><font size="2"> G11<br> </font> </span><span style="font-family: Courier; color: blue;"><font size="2">From</font></span> <span style="font-family: Courier; color: olive;"><font size="2">Testdata</font></span> <span style="font-family: Courier; color: olive;"><font size="2">X</font></span><span style="font-family: Courier; color: black;"><br> </span><span style="font-family: Courier; color: blue;"><font size="2">Group</font></span> <span style="font-family: Courier; color: blue;"><font size="2">By</font></span> <span style="font-family: Courier; color: olive;"><font size="2">F1</font></span><span style="font-family: Courier; color: blue;"><font size="2">,</font></span><span style="font-family: Courier; color: black;"><br> </span><span style="font-family: Courier; color: blue;"><font size="2">Grouping</font></span> <span style="font-family: Courier; color: blue;"><font size="2">Sets(Rollup(</font></span><span style="font-family: Courier; color: black;"><font size="2">F9</font></span><span style="font-family: Courier; color: blue;"><font size="2">,</font></span><span style="font-family: Courier; color: black;"><font size="2"> F10</font></span><span style="font-family: Courier; color: blue;"><font size="2">),</font></span> <span style="font-family: Courier; color: blue;"><font size="2">Rollup(</font></span><span style="font-family: Courier; color: black;"><font size="2">F9</font></span><span style="font-family: Courier; color: blue;"><font size="2">,</font></span><span style="font-family: Courier; color: black;"><font size="2"> F11</font></span><span style="font-family: Courier; color: blue;"><font size="2">))</font></span><span style="font-family: Courier; color: black;"><br> </span><span style="font-family: Courier; color: blue;"><font size="2">Having</font></span> <span style="font-family: Courier; color: blue;"><font size="2">GROUP_ID()</font></span> <span style="font-family: Courier; color: blue;"><font size="2">=</font></span> <span style="font-family: Courier; color: maroon;"><font size="2">0</font></span><span style="font-family: Courier; color: black;"><br> </span><span style="font-family: Courier; color: blue;"><font size="2">And</font></span> <span style="font-family: Courier; color: blue;"><font size="2">Not(</font></span><span style="font-family: Courier; color: black;"><font size="2"> F10 </font></span><span style="font-family: Courier; color: blue;"><font size="2">Is</font></span> <span style="font-family: Courier; color: blue;"><font size="2">Null</font></span> <span style="font-family: Courier; color: blue;"><font size="2">And</font></span> <span style="font-family: Courier; color: blue;"><font size="2">Grouping(</font></span><span style="font-family: Courier; color: olive;"><font size="2">X</font></span><span style="font-family: Courier; color: blue;"><font size="2">.</font></span><span style="font-family: Courier; color: black;"><font size="2">F10</font></span><span style="font-family: Courier; color: blue;"><font size="2">)</font></span> <span style="font-family: Courier; color: blue;"><font size="2">=</font></span> <span style="font-family: Courier; color: maroon;"><font size="2">0</font></span><span style="font-family: Courier; color: blue;"><font size="2">)</font></span><span style="font-family: Courier; color: black;"><br> </span><span style="font-family: Courier; color: blue;"><font size="2">And</font></span> <span style="font-family: Courier; color: blue;"><font size="2">Not(</font></span><span style="font-family: Courier; color: black;"><font size="2"> F11 </font></span><span style="font-family: Courier; color: blue;"><font size="2">Is</font></span> <span style="font-family: Courier; color: blue;"><font size="2">Null</font></span> <span style="font-family: Courier; color: blue;"><font size="2">And</font></span> <span style="font-family: Courier; color: blue;"><font size="2">Grouping(</font></span><span style="font-family: Courier; color: olive;"><font size="2">X</font></span><span style="font-family: Courier; color: blue;"><font size="2">.</font></span><span style="font-family: Courier; color: black;"><font size="2">F11</font></span><span style="font-family: Courier; color: blue;"><font size="2">)</font></span> <span style="font-family: Courier; color: blue;"><font size="2">=</font></span> <span style="font-family: Courier; color: maroon;"><font size="2">0</font></span><span style="font-family: Courier; color: blue;"><font size="2">);</font></span><font size="2"><font face="Courier, Courier New, monospace"><font color="#000000"><br></font></font></font><br> </p> </td> </tr> </tbody></table> <p class="western" style="margin-bottom: 0in;"><br>One last thing: The 3 "Grouping" statements in the <i>select list</i> are not required. They are only there as a visual aid.<br>to use during the debugging phase of developing the rollup. When you know that you are getting the desired results<br>you can remove them as follows:</p> <p class="western" style="margin-bottom: 0in;"> <br><br> </p> <p style="margin-top: 0.08in; page-break-after: avoid;"><font size="2"><b>Table 10</b></font></p> <table border="1" bordercolor="#000000" cellpadding="8" cellspacing="0" width="617"> <col width="599"> <tbody><tr> <td height="90" valign="top" width="599"> <p class="western"><span style="font-family: Courier; color: blue;"><font size="2">Select</font></span> <span style="font-family: Courier; color: olive;"><font size="2">X</font></span><span style="font-family: Courier; color: blue;"><font size="2">.</font></span><span style="font-family: Courier; color: black;"><font size="2">F9</font></span><span style="font-family: Courier; color: blue;"><font size="2">,</font></span><span style="font-family: Courier; color: black;"><br> </span><span style="font-family: Courier; color: olive;"><font size="2">X</font></span><span style="font-family: Courier; color: blue;"><font size="2">.</font></span><span style="font-family: Courier; color: black;"><font size="2">F10</font></span><span style="font-family: Courier; color: blue;"><font size="2">,</font></span><span style="font-family: Courier; color: black;"><br> </span><span style="font-family: Courier; color: olive;"><font size="2">X</font></span><span style="font-family: Courier; color: blue;"><font size="2">.</font></span><span style="font-family: Courier; color: black;"><font size="2">F11</font></span><span style="font-family: Courier; color: blue;"><font size="2">,</font></span><span style="font-family: Courier; color: black;"><br> </span><span style="font-family: Courier; color: blue;"><font size="2">Count(</font></span><span style="font-family: Courier; color: black;"><font size="2">*</font></span><span style="font-family: Courier; color: blue;"><font size="2">)</font></span><span style="font-family: Courier; color: black;"><font size="2"> Cnt<br> </font> </span><span style="font-family: Courier; color: blue;"><font size="2">From</font></span> <span style="font-family: Courier; color: olive;"><font size="2">Testdata</font></span> <span style="font-family: Courier; color: olive;"><font size="2">X</font></span><span style="font-family: Courier; color: black;"><br> </span><span style="font-family: Courier; color: blue;"><font size="2">Group</font></span> <span style="font-family: Courier; color: blue;"><font size="2">By</font></span> <span style="font-family: Courier; color: olive;"><font size="2">F1</font></span><span style="font-family: Courier; color: blue;"><font size="2">,</font></span><span style="font-family: Courier; color: black;"><br> </span><span style="font-family: Courier; color: blue;"><font size="2">Grouping</font></span> <span style="font-family: Courier; color: blue;"><font size="2">Sets(Rollup(</font></span><span style="font-family: Courier; color: black;"><font size="2">F9</font></span><span style="font-family: Courier; color: blue;"><font size="2">,</font></span><span style="font-family: Courier; color: black;"><font size="2"> F10</font></span><span style="font-family: Courier; color: blue;"><font size="2">),</font></span> <span style="font-family: Courier; color: blue;"><font size="2">Rollup(</font></span><span style="font-family: Courier; color: black;"><font size="2">F9</font></span><span style="font-family: Courier; color: blue;"><font size="2">,</font></span><span style="font-family: Courier; color: black;"><font size="2"> F11</font></span><span style="font-family: Courier; color: blue;"><font size="2">))</font></span><span style="font-family: Courier; color: black;"><br> </span><span style="font-family: Courier; color: blue;"><font size="2">Having</font></span> <span style="font-family: Courier; color: blue;"><font size="2">GROUP_ID()</font></span> <span style="font-family: Courier; color: blue;"><font size="2">=</font></span> <span style="font-family: Courier; color: maroon;"><font size="2">0</font></span><span style="font-family: Courier; color: black;"><br> </span><span style="font-family: Courier; color: blue;"><font size="2">And</font></span> <span style="font-family: Courier; color: blue;"><font size="2">Not(</font></span><span style="font-family: Courier; color: black;"><font size="2"> F10 </font></span><span style="font-family: Courier; color: blue;"><font size="2">Is</font></span> <span style="font-family: Courier; color: blue;"><font size="2">Null</font></span> <span style="font-family: Courier; color: blue;"><font size="2">And</font></span> <span style="font-family: Courier; color: blue;"><font size="2">Grouping(</font></span><span style="font-family: Courier; color: olive;"><font size="2">X</font></span><span style="font-family: Courier; color: blue;"><font size="2">.</font></span><span style="font-family: Courier; color: black;"><font size="2">F10</font></span><span style="font-family: Courier; color: blue;"><font size="2">)</font></span> <span style="font-family: Courier; color: blue;"><font size="2">=</font></span> <span style="font-family: Courier; color: maroon;"><font size="2">0</font></span><span style="font-family: Courier; color: blue;"><font size="2">)</font></span><span style="font-family: Courier; color: black;"><br> </span><span style="font-family: Courier; color: blue;"><font size="2">And</font></span> <span style="font-family: Courier; color: blue;"><font size="2">Not(</font></span><span style="font-family: Courier; color: black;"><font size="2"> F11 </font></span><span style="font-family: Courier; color: blue;"><font size="2">Is</font></span> <span style="font-family: Courier; color: blue;"><font size="2">Null</font></span> <span style="font-family: Courier; color: blue;"><font size="2">And</font></span> <span style="font-family: Courier; color: blue;"><font size="2">Grouping(</font></span><span style="font-family: Courier; color: olive;"><font size="2">X</font></span><span style="font-family: Courier; color: blue;"><font size="2">.</font></span><span style="font-family: Courier; color: black;"><font size="2">F11</font></span><span style="font-family: Courier; color: blue;"><font size="2">)</font></span> <span style="font-family: Courier; color: blue;"><font size="2">=</font></span> <span style="font-family: Courier; color: maroon;"><font size="2">0</font></span><span style="font-family: Courier; color: blue;"><font size="2">);</font></span><font size="2"><font face="Courier, Courier New, monospace"><font color="#000000"><br></font></font></font><br> </p> </td> </tr> </tbody></table> <p class="western" style="margin-bottom: 0in;"><a name="_PictureBullets"></a> <br>In the next post, part 2 of this article, we will add on more bells and whistles to this basic rollup. That's where "combine the features of SQL" part comes in. This is only the beginning of what will become a much larger, much more complex SQL statement. <br><br></p> Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4228170808530538594.post-48422393491851949732007-09-25T10:46:00.000-07:002007-09-28T14:03:56.360-07:00 <div class="Section1"> <h1>Using a Function Based Index to enforce complex unique constraints</h1> <p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0"><br> Sometimes there is a need to enforce different rules for uniqueness depending on <br> the type of record. Using a Function Based Index is one way to accomplish this.<br> </span> <br> EXAMPLE: <br> <span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <span class="GramE">Lets</span> start with a preview of our table</span></p> <p class="MsoNormal"><br> <br> </p> <table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="margin-left:2.6pt;border-collapse:collapse;border:none"> <tr style="height:47.25pt"> <td style="width:447.0pt;border:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;height:47.25pt" valign="top" width="596"> <p class="MsoNormal"><code><span style="font-size:9.0pt"> PRIM_KEY A REC_CLASS DLR_FK DLR_SER_FK WHERE_CLAUSE FIELD_FK<br> ---------- - --------------- ---------- ---------- ------------------ ----------<br> 70 Y PRODUCT 2202 number-Floors=2 1111<br> 80 Y PRODUCT 2202 number_floors = 1 1111<br> 90 <span style="color:red">N</span> DEALER_SERVICE <span style="color:red">2202</span> <span style="color:red">3333</span><br> 100 <span style="color:red">Y</span> DEALER_SERVICE <span style="color:red">2202</span> <span style="color:red">3333</span><br> 110 Y DEALER <span style="color:red">1000</span> <span style="color:red">3333</span><br> 10 Y DEALER <span style="color:red">1000</span> <span style="color:red">1111</span><br> 20 Y DEALER <span style="color:red">1000</span> <span style="color:red">2222</span><br> 30 <span style="color:red">Y</span> DEALER_SERVICE <span style="color:red">2202</span> <span style="color:red">1111</span><br> 40 <span style="color:red">N</span> DEALER_SERVICE <span style="color:red">2202</span> <span style="color:red">1111</span><br> 50 Y PRODUCT 2200 number_floors = 1 1111<br> 60 Y PRODUCT 2200 number-Floors=2 1111<br> <br> Figure 1.</span></code><span style="font-size:9.0pt"> Uniqueness <br> <br> </span></p> </td> </tr> </table> <p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> Figure 1 shows in red the columns that must be unique for each of the three types of<br> records. Each type of record requires the the following combinations be unique.</span></p> <p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:black"> </span></p> <ol start="1" style="margin-top:0in" type="1"> <li class="MsoNormal" style="color:#0000F0"><span style="font-size:10.0pt;font-family:"Courier New";color:black">DEALER_SERVICE</span></li> <ol start="1" style="margin-top:0in" type="a"> <li class="MsoNormal" style="color:#0000F0"><span style="font-size:10.0pt;font-family:"Courier New";color:black">Active_Flag</span></li> <li class="MsoNormal" style="color:#0000F0"><span style="font-size:10.0pt;font-family:"Courier New";color:black">DEALER_SER2DEALER_SERVICE</span></li> <li class="MsoNormal" style="color:#0000F0"><span style="font-size:10.0pt;font-family:"Courier New";color:black">PLAYING_FIELD2PLAYING_FIELD </span></li> </ol> <li class="MsoNormal" style="color:#0000F0"><span style="font-size:10.0pt;font-family:"Courier New";color:black">DEALER</span></li> <ol start="1" style="margin-top:0in" type="a"> <li class="MsoNormal" style="color:#0000F0"><span style="font-size:10.0pt;font-family:"Courier New";color:black">DEALER2DEALER</span></li> <li class="MsoNormal" style="color:#0000F0"><span style="font-size:10.0pt;font-family:"Courier New";color:black">PLAYING_FIELD2PLAYING_FIELD</span></li> </ol> <li class="MsoNormal" style="color:#0000F0"><span style="font-size:10.0pt;font-family:"Courier New";color:black">PRODUCT</span></li> <ol start="1" style="margin-top:0in" type="a"> <li class="MsoNormal" style="color:#0000F0"><span style="font-size:10.0pt;font-family:"Courier New";color:black">none<br> <br> <br> </span></li> </ol> </ol> <table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="background:#F2F2F2;border-collapse:collapse;border:none"> <tr style="height:539.5pt"> <td nowrap="" style="width:513.0pt;border:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;height:539.5pt" valign="top" width="684"> <p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">DROP</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">TABLE</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> LIMITS_AND_TOTALS</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">CREATE</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">TABLE</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> LIMITS_AND_TOTALS<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> LIMITS_AND_TOTALS_KEY </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">NUMBER</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">10</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">NOT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">NULL,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> ACTIVE_FLAG </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">1</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">DEFAULT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'Y'</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">NOT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">NULL,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> REC_CLASS </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">30</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">NOT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">NULL,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> CAP_LIMIT </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">NUMBER</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">10</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">NOT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">NULL,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> CURRENT_CNT </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">NUMBER</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">10</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">NOT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">NULL,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> DEALER2DEALER </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">NUMBER</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">10</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">),</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> DEALER_SER2DEALER_SERVICE </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">NUMBER</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">10</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">),</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> WHERE_CLAUSE </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">4000</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">BYTE</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">),</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> PLAYING_FIELD2PLAYING_FIELD </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">NUMBER</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">10</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">ALTER</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">TABLE</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> LIMITS_AND_TOTALS </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">ADD</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">CONSTRAINT</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> LIMITS_AND_TOTALS_PK<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">PRIMARY</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">KEY</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">LIMITS_AND_TOTALS_KEY</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">));</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">--ALTER TABLE LIMITS_AND_TOTALS ADD (</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- CONSTRAINT DEALER_FK</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- FOREIGN KEY (DEALER2DEALER)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- REFERENCES DEALER (DEALER_KEY)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- );</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">--ALTER TABLE LIMITS_AND_TOTALS ADD (</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- CONSTRAINT DEALER_SER_FK</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- FOREIGN KEY (DEALER_SER2DEALER_SERVICE)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- REFERENCES DEALER_SERVICE (DEALER_SERVICE_KEY)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- );</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">--ALTER TABLE LIMITS_AND_TOTALS ADD (</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- CONSTRAINT PLAYING_FIELD_FK</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- FOREIGN KEY (PLAYING_FIELD2PLAYING_FIELD)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- REFERENCES PLAYING_FIELD (PLAYING_FIELD_KEY));</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">CREATE</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">OR</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">REPLACE</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">FUNCTION</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> flimit_unique </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> rec_class </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> dealer_key </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">INTEGER</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> dealer_service_key </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">INTEGER</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> playing_field_key </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">INTEGER</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> active_flag </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> limits_and_totals_key </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">INTEGER</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">RETURN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> DETERMINISTIC<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">AS</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> class_str </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">CHAR</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">30</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> key_str </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">CHAR</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">10</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> playing_field_str </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">CHAR</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">10</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> unique_str </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">CHAR</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">10</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> result_str </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">90</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> active_str </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">CHAR</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">1</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">BEGIN</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> class_str </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">:=</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> rec_class</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- copy the playing field FK or use 0 (zero) in the even of null</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> playing_field_str </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">:=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">COALESCE</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> TO_CHAR </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> playing_field_key </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">),</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'0'</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> active_str </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">:=</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> active_flag</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IF</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> class_str </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'PRODUCT'</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">OR</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> class_str </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'DEALER_SERVICE'</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">AND</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> active_str </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'N'</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">THEN</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- append the primary key</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> unique_str </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">:=</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> TO_CHAR </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> limits_and_totals_key </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">--</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- doing this forces the generation of a unique index key</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- so THIS will always be unique</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">ELSE</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> unique_str </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">:=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">0</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">END</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IF;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- pick the FK that is relevant to the current REC_CLASS type.</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- Only one of these FKs will have a non null value</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> key_str </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">:=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">COALESCE</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> TO_CHAR </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> dealer_key </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">),</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> TO_CHAR </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> dealer_service_key </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> result_str </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">:=</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> RPAD </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> RTRIM </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> class_str </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">),</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">30</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'*'</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> || LPAD </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> RTRIM </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> key_str </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">),</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">10</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'#'</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> || LPAD </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> RTRIM </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> playing_field_str </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">),</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">10</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'+'</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> || LPAD </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> RTRIM </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> unique_str </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">),</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">10</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'@'</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">RETURN</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> result_str</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">END;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">/</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">CREATE</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">UNIQUE</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INDEX</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> limits_and_totals_ix </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">ON</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> limits_and_totals<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">flimit_unique </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:red">"REC_CLASS"</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">"DEALER2DEALER"</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">"DEALER_SER2DEALER_SERVICE"</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">"PLAYING_FIELD2PLAYING_FIELD"</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">"ACTIVE_FLAG"</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">"LIMITS_AND_TOTALS_KEY"</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">));</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INSERT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INTO</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> limits_and_totals<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> limits_and_totals_key</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> active_flag</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> rec_class</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> cap_limit</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> current_cnt<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> dealer_ser2dealer_service</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> where_clause</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> playing_field2playing_field<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">VALUES</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">70</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'Y'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'PRODUCT'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">4</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">1</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">2202</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'number-Floors=2'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">1111</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INSERT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INTO</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> limits_and_totals<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> limits_and_totals_key</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> active_flag</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> rec_class</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> cap_limit</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> current_cnt<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> dealer_ser2dealer_service</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> where_clause</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> playing_field2playing_field<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">VALUES</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">80</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'Y'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'PRODUCT'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">5</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">2</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">2202</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'number_floors = 1'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">1111</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INSERT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INTO</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> limits_and_totals<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> limits_and_totals_key</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> active_flag</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> rec_class</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> cap_limit</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> current_cnt<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> dealer_ser2dealer_service</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> playing_field2playing_field<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">VALUES</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">90</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'N'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'DEALER_SERVICE'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">22</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">5</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">2202</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">3333</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INSERT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INTO</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> limits_and_totals<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> limits_and_totals_key</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> active_flag</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> rec_class</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> cap_limit</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> current_cnt<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> dealer_ser2dealer_service</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> playing_field2playing_field<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">VALUES</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">100</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'Y'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'DEALER_SERVICE'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">14</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">3</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">2202</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">3333</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INSERT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INTO</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> limits_and_totals<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> limits_and_totals_key</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> active_flag</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> rec_class</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> cap_limit</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> current_cnt<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> dealer2dealer</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> playing_field2playing_field<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">VALUES</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">110</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'Y'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'DEALER'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">20</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">6</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">1000</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">3333</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INSERT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INTO</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> limits_and_totals<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> limits_and_totals_key</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> active_flag</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> rec_class</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> cap_limit</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> current_cnt<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> dealer2dealer</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> playing_field2playing_field<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">VALUES</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">10</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'Y'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'DEALER'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">25</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">5</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">1000</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">1111</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INSERT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INTO</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> limits_and_totals<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> limits_and_totals_key</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> active_flag</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> rec_class</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> cap_limit</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> current_cnt<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> dealer2dealer</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> playing_field2playing_field<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">VALUES</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">20</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'Y'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'DEALER'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">20</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">6</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">1000</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">2222</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INSERT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INTO</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> limits_and_totals<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> limits_and_totals_key</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> active_flag</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> rec_class</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> cap_limit</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> current_cnt<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> dealer_ser2dealer_service</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> playing_field2playing_field<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">VALUES</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">30</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'Y'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'DEALER_SERVICE'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">14</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">3</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">2202</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">1111</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INSERT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INTO</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> limits_and_totals<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> limits_and_totals_key</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> active_flag</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> rec_class</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> cap_limit</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> current_cnt<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> dealer_ser2dealer_service</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> playing_field2playing_field<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">VALUES</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">40</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'N'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'DEALER_SERVICE'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">22</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">5</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">2202</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">1111</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INSERT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INTO</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> limits_and_totals<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> limits_and_totals_key</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> active_flag</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> rec_class</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> cap_limit</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> current_cnt<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> dealer_ser2dealer_service</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> where_clause</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> playing_field2playing_field<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">VALUES</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">50</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'Y'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'PRODUCT'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">5</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">2</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">2200</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'number_floors = 1'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">1111</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INSERT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INTO</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> limits_and_totals<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> limits_and_totals_key</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> active_flag</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> rec_class</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> cap_limit</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> current_cnt<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> dealer_ser2dealer_service</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> where_clause</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> playing_field2playing_field<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">VALUES</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">60</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'Y'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'PRODUCT'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">4</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">1</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">2200</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'number-Floors=2'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">1111</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">COMMIT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> <br> </span></p> </td> </tr> </table> <p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0"><br> <br> <br> <br> SET</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> DEFINE </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">OFF<span class="GramE">;</span></span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> col where_clause format a18<br> col rec_class format a15<br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">SELECT</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> limits_and_totals_key prim_key</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> active_flag af</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> rec_class<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> dealer2dealer dlr_fk</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> dealer_ser2dealer_service dlr_ser_fk</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> where_clause<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> playing_field2playing_field field_fk<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">FROM</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> limits_and_totals</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><br> <br> <br> </p> <table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="margin-left:2.6pt;border-collapse:collapse;border:none"> <tr style="height:47.25pt"> <td style="width:447.0pt;border:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;height:47.25pt" valign="top" width="596"> <p class="MsoNormal"><code><span style="font-size:9.0pt"> PRIM_KEY A REC_CLASS DLR_FK DLR_SER_FK WHERE_CLAUSE FIELD_FK<br> ---------- - --------------- ---------- ---------- ------------------ ----------<br> 70 Y PRODUCT 2202 number-Floors=2 1111<br> 80 Y PRODUCT 2202 number_floors = 1 1111<br> 90 <span style="color:red">N</span> DEALER_SERVICE <span style="color:red">2202</span> <span style="color:red">3333</span><br> 100 <span style="color:red">Y</span> DEALER_SERVICE <span style="color:red">2202</span> <span style="color:red">3333</span><br> 110 Y DEALER <span style="color:red">1000</span> <span style="color:red">3333</span><br> 10 Y DEALER <span style="color:red">1000</span> <span style="color:red">1111</span><br> 20 Y DEALER <span style="color:red">1000</span> <span style="color:red">2222</span><br> 30 <span style="color:red">Y</span> DEALER_SERVICE <span style="color:red">2202</span> <span style="color:red">1111</span><br> 40 <span style="color:red">N</span> DEALER_SERVICE <span style="color:red">2202</span> <span style="color:red">1111</span><br> 50 Y PRODUCT 2200 number_floors = 1 1111<br> 60 Y PRODUCT 2200 number-Floors=2 1111<br> <br> Figure 1.</span></code><span style="font-size:9.0pt"> Uniqueness <br> <br> </span></p> </td> </tr> </table> <p class="MsoNormal" style="text-autospace:none"><br> <br> First we try to insert a duplicate DEALER record.<br> <br> </p> <table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse:collapse;border:none"> <tr style="height:126.4pt"> <td style="width:453.75pt;border:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;height:126.4pt" valign="top" width="605"> <p class="MsoNormal" style="margin-left:4.5pt;text-autospace:none"><br> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INSERT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INTO</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> LIMITS_AND_TOTALS<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">LIMITS_AND_TOTALS_KEY</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> ACTIVE_FLAG</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> REC_CLASS</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> CAP_LIMIT</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> CURRENT_CNT</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> DEALER2DEALER</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> PLAYING_FIELD2PLAYING_FIELD</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">VALUES</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">150</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <b><span style="font-size:10.0pt;font-family:"Courier New";color:red">'Y'</span></b><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'DEALER'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">20</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">6</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <b><u><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">1000</span></u></b><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <b><u><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">3333</span></u></b><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">COMMIT;<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">ORA-00001: UNIQUE CONSTRAINT (LIMITS_AND_TOTALS_IX) violated<br> <br> </span></p> </td> </tr> </table> <p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><br> Try changing the active flag TO 'N'<br> <br> </p> <table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse:collapse;border:none"> <tr style="height:111.75pt"> <td style="width:454.5pt;border:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;height:111.75pt" valign="top" width="606"> <p class="MsoNormal" style="margin-left:3.0pt"><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INSERT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INTO</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> LIMITS_AND_TOTALS<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">LIMITS_AND_TOTALS_KEY</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> ACTIVE_FLAG</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> REC_CLASS</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> CAP_LIMIT</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> CURRENT_CNT</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> DEALER2DEALER</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> PLAYING_FIELD2PLAYING_FIELD</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">VALUES</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">150</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'N'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'DEALER'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">20</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">6</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <b><u><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">1000</span></u></b><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <b><u><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">3333</span></u></b><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">COMMIT;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">ORA-00001: UNIQUE CONSTRAINT (LIMITS_AND_TOTALS_IX) violated<br> <br> </span></p> </td> </tr> </table> <p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span>The problem is still the same<span class="GramE">..</span> Remember, on <i>DEALER</i> records, active flag does NOT<br> matter for the purpose of uniqueness.<br> <br> Next, try the same thing with REC_CLASS = DEALER_SERVICE</p> <table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse:collapse;border:none"> <tr style="height:107.25pt"> <td style="width:458.25pt;border:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;height:107.25pt" valign="top" width="611"> <p class="MsoNormal" style="margin-left:6.75pt"><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INSERT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INTO</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> LIMITS_AND_TOTALS<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">LIMITS_AND_TOTALS_KEY</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> ACTIVE_FLAG</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> REC_CLASS</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> CAP_LIMIT</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> CURRENT_CNT</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> DEALER_SER2DEALER_SERVICE</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> PLAYING_FIELD2PLAYING_FIELD</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">VALUES</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">140</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <b><u><span style="font-size:10.0pt;font-family:"Courier New";color:red">'Y'</span></u></b><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'DEALER_SERVICE'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">14</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">3</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <b><u><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">2202</span></u></b><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <b><u><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">3333</span></u></b><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">COMMIT;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">ORA-00001: UNIQUE CONSTRAINT (LIMITS_AND_TOTALS_IX) violated</span></p> </td> </tr> </table> <p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><br> AS expected, that <i>DEALER_SERVICE</i> for that <i>PLAYING_FIELD </i>already exists.<br> <br> Now lets see what happens if we set the active flag to 'N'<br> <br> </p> <table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse:collapse;border:none"> <tr style="height:78.25pt"> <td style="width:459.75pt;border:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;height:78.25pt" valign="top" width="613"> <p class="MsoNormal" style="margin-left:5.25pt;text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INSERT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INTO</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> LIMITS_AND_TOTALS<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">LIMITS_AND_TOTALS_KEY</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> ACTIVE_FLAG</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> REC_CLASS</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> CAP_LIMIT</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> CURRENT_CNT</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> DEALER_SER2DEALER_SERVICE</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> PLAYING_FIELD2PLAYING_FIELD</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">VALUES</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">140</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <b><u><span style="font-size:10.0pt;font-family:"Courier New";color:red">'N'</span></u></b><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'DEALER_SERVICE'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">14</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">3</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <b><u><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">2202</span></u></b><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span> <b><u><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">3333</span></u></b><b><u><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span></u></b><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">COMMIT;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span></p> </td> </tr> </table> <p class="MsoNormal"><span style="color:black"><br> </span><b>This time, no Error! This is because we allow any number of DEALER_SERVICE type<br> records provided that the active flag = 'N'.<br> <br> <br> <br> </b></p> </div> Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4228170808530538594.post-51622061097204529452007-09-24T09:08:00.000-07:002007-09-25T10:25:00.017-07:00 <div class="Section1"> <h1><tt><span style="font-family:Arial">Basics of PL/SQL Package Structures</span></tt></h1> <p class="MsoNormal"><tt><span style="font-size:10.0pt"> </span></tt></p> <p class="MsoNormal"><tt><span style="font-size:10.0pt"> This article covers some of the basics of PL/SQL package structure.</span></tt><br> <tt><span style="font-size:10.0pt">There is much that is left out including package cursors and exception</span></tt><br> <tt><span style="font-size:10.0pt">structures. Beginners should learn a lot from following the code logic.</span></tt><br> <tt><span style="font-size:10.0pt">Intermediate programmers may pick up a couple of things. Advanced</span></tt><br> <tt><span style="font-size:10.0pt">programmers will probably already know everything presented here.</span></tt><br> <tt><span style="font-size:10.0pt">If you attempt to follow the code logic, don’t expect the code to do</span></tt><br> <tt><span style="font-size:10.0pt">anything meaningful. The point of the code is to illustrate some</span></tt><br> <tt><span style="font-size:10.0pt">structural components. </span></tt><br> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0"><br> CREATE</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">OR</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">REPLACE</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">PACKAGE</span> <span style="font-size:10.0pt;font-family:"Courier New";color:olive">Demo</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">AS</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- This is a package specification (not a package body). It exists to define the</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- public interface to this packages. </span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> my_package_string </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">2000</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">:=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'Read or Write from any scope'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- my_package_string can be read or written from any where in this package</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- or from other packages or stand-alone procedures or functions.</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> my_package_integer </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">CONSTANT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">PLS_INTEGER</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">:=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">1234</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- my_package_integer can be read but not written from any where in this</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- package or from other packages or stand-alone procedures or functions.</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> my_package_date </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">DATE</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">--===================================================================</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- fun_2 is an 'overloaded' function. When fun_2 is called, the datatypes</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- of the parameter list and the return type (aka, the signature) will be</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- evaluated and the appropriate fun_2 will be called. Each fun_2 can do</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- entirely different things as defined by the corresponding function</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- in the BODY of the package.</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- ADVICE - Use overloading judiciously. Beginning programmers often</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- discover function and procedure overloading and seriously abuse the</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- ability. Make sure that overloaded functions actually perform the </span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- same task. It is possible to create a package with a single overloaded</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- function or procedure that does everything based on user defined </span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- data types. Don't do it.</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">FUNCTION</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> fun_2 </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> first_name </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">RETURN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- This function declaration says that there will be a function by the same </span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- name and same signature define in the body of this package. Furthermore, </span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- the fact that it is defined in this package specification allows it to be</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- called by other packages, procedures and functions.</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">FUNCTION</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> fun_2 </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> first_name </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">last_name </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">RETURN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">FUNCTION</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> fun_2 </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> first_name </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">RETURN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">INTEGER</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">FUNCTION</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> fun_2 </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> first_name </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">CLOB</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">RETURN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- This over load using a clob is particularly nasty.</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- This package and body will sucessfully compile as long</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- as there is no call to fun_2 using a varchar2 input parameter.</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- If you try to code " my_varchar := fun_2('FRED');" or</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- "my_varchar := fun_2(input_varchar);" the compile will fail because</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- both "(first_name IN clob)" and "(first_name IN varchar2)" are </span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- suitable signatures and the compiler can not assume which one</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- you intend to use. Worse yet is if you do not attempt to call</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- fun_2 within this procedure and the compile is successful because</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- later when an external process attempts to use this package's fun_2</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- with the varchar2 signature, a run_time error will be thrown!</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- PLS-00307: too many declarations of 'FUN_2' match this call</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">--==================================================================</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">PROCEDURE</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> demo_path_selector </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">path_choice </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IN</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">INTEGER</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> the_result </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">OUT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">NOCOPY</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">END</span> <span style="font-size:10.0pt;font-family:"Courier New";color:olive">Demo</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">/</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><br> <br> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">CREATE</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">OR</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">REPLACE</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">PACKAGE</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">BODY</span> <span style="font-size:10.0pt;font-family:"Courier New";color:olive">Demo</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">AS</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> body_level_string_2 </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">200</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">DEFAULT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'Hi there'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- this is a body level global variable. It can be accessed </span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- from any function or procedure defined in this body, but it</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- can not be accessed from other packages or stand-alone procedures</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- and functions. </span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">FUNCTION</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> fun_2 </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> first_name </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">RETURN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">AS</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">BEGIN</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">RETURN</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> SUBSTR</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">first_name</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">END</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> fun_2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- This fun_2 is defined in the package spec. Therefor, other packages</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- that use this function will be executing this process. </span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">FUNCTION</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> fun_2 </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> first_name </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">last_name </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">RETURN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">AS</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">BEGIN</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">RETURN</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> first_name||</span><span style="font-size:10.0pt;font-family:"Courier New";color:red">' '</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">||last_name</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">END</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> fun_2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">FUNCTION</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> fun_2 </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> first_name </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">RETURN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">INTEGER</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">AS</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">BEGIN</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">RETURN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">123</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">END</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> fun_2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">FUNCTION</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> fun_2 </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> first_name </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">CLOB</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">RETURN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">AS</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> temp_str </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">2000</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">:=</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> first_name</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">BEGIN</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">RETURN</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> temp_str</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">END</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> fun_2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> <br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">FUNCTION</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> fun_3 </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> first_name </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">RETURN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">AS</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> temp_string </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">200</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> name_str </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">CLOB</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">:=</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> first_name || <br> body_level_string_2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span> <span style="font-size:10.0pt;font-family:"Courier New";color:green">-- defined at the body level</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">BEGIN</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> temp_string </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">:=</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> fun_2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">name_str</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> temp_string </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">:=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:olive">Demo</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">.</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">fun_2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">name_str</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">RETURN</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> temp_string</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">END</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> fun_3</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- fun_3 is not defined in the package spec. It is a body level</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- function. This means that only procedures, functions, or</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- the initialization section defined in this package body</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- will have access to fun_3</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">PROCEDURE</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> demo_path_selector </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">path_choice </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IN</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">INTEGER</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> <br> the_result </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">OUT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">NOCOPY</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">AS</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">FUNCTION</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> local_fun_2 </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">first_name </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">RETURN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">AS</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> temp_string </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">4</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">:=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'Mr. '</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">BEGIN</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">RETURN</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> temp_string||first_name</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">END</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> local_fun_2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- local_fun_2 is a subprogram function. This means that is available only</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- to code running in the same procedure/function. Subprograms </span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- can themselves contain subprograms nested</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- to an undetermined number of levels. </span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">BEGIN</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- ====== main code logic ======</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IF</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> path_choice </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">1</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">THEN</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> the_result </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">:=</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> local_fun_2<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:olive">Demo</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">.</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">my_package_string</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span> <span style="font-size:10.0pt;font-family:"Courier New";color:green">-- defined and initialized in package spec</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">ELSE</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> the_result </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">:=</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> fun_3</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:red">'Abdul'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">END</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IF;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">END</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> demo_path_selector</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- In the procedure above 'demo_path_selector' you have seen how to create</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- subprogram functions and procedures. The unfortunate result of doing this</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- is that it drives the main code logic to the bottom. If you want your </span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- code to be on top, and your local functions and procedures on the bottom</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- you can use 'forward declaration'. Basically, you take your local function</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- and divide it into two parts, a function spec, and a function body.</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- Below is the same procedure as</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- above, but this time with a forward declaration and with the </span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- main body turned into a subprogram procedure call</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- The down side of this approach is that it makes procedure somewhat</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- convoluted and perhaps that is too high of a price to pay for having</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- the main code logic on top.</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- Note that within the demo_path_selector2 procedure, there is a</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- a subprogram with the same name. We can get away with this because</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- of the way subprogram calls are resolved. The compiler walks up the </span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- scope until a match is found on the called procedure name. However,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- just because it can be done does not mean that it should be done. </span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- It would be less confusing if the sub program had a different name.</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">PROCEDURE</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> demo_path_selector2 </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">path_choice </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IN</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">INTEGER</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> <br> the_result </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">OUT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">NOCOPY</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">AS</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">FUNCTION</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> local_fun_2 </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">first_name </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- forward declaration</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">RETURN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">PROCEDURE</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> demo_path_selector2 </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">path_choice </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IN</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">INTEGER</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> <br> the_result </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">OUT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">NOCOPY</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">AS</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">BEGIN</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- ====== main code logic ======</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IF</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> path_choice </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">1</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">THEN</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> the_result </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">:=</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> local_fun_2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:red">'Smith'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">ELSE</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> the_result </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">:=</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> fun_3</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:red">'Abdul'</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">END</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IF;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">END</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> demo_path_selector2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">FUNCTION</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> local_fun_2 </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">first_name </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span> <span style="font-size:10.0pt;font-family:"Courier New";color:green">-- body of forward declaration</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">RETURN</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">AS</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> temp_string </span><span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">4</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">:=</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">'Mr. '</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">BEGIN</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">RETURN</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> temp_string||first_name</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">END</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> local_fun_2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">BEGIN</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> demo_path_selector2 </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">path_choice</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> <br> the_result</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">);</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">END</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> demo_path_selector2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">BEGIN</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- this is the initialization section. Any executable code placed in this</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- section will be run the first time the package is loaded for a given session.</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:green">-- </span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">SELECT</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">SYSDATE</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">+</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">1</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">INTO</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> my_package_date </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">FROM</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> DUAL</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> <br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">END</span> <span style="font-size:10.0pt;font-family:"Courier New";color:olive">Demo</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">/</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><br> <br> </p> </div> Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4228170808530538594.post-35436687356068621702007-09-22T17:04:00.000-07:002007-09-25T10:25:11.604-07:00 <div class="Section1"> <p class="MsoNormal"><span class="Heading1Char"><span style="font-size:16.0pt">Using Model for generating CSV by Partition</span></span><br> <br> </p> <p class="MsoNormal">This example assumes that "thedate"can not be NULL.<br> CUSTTAB<br> CUST THEDATE<br> ---------- ----------<br> 5 234<br> 5 333<br> 5 336<br> 6 111<br> 6 222<br> 6 333<br> 5 100<br> <br> col csv format a30<br> <br> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">SELECT</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> cust</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">SUBSTR</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">csv</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> csv </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">FROM</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> custtab<br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">MODEL</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">RETURN</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> updated </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">ROWS</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">PARTITION</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">BY</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">cust</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">DIMENSION</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">BY</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">row_number</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">()</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> over </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(PARTITION</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">BY</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> cust </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">ORDER</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">BY</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> thedate</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">AS</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> therow</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">MEASURES</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> thedate</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">,</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">cast </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(NULL</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">AS</span> <span style="font-size:10.0pt;font-family:"Courier New";color:red">VARCHAR2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">400</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">))</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">AS</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> csv</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">RULES</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">UPDATE</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">ITERATE(</span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">9999</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">)</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">UNTIL</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> thedate</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">[</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">ITERATION_NUMBER </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">+</span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">2</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">]</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">IS</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">NULL</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">csv</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">[</span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">1</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">]</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">=</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> csv</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">[</span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">1</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">]</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">||</span><span style="font-size:10.0pt;font-family:"Courier New";color:red">','</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">||thedate</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">[</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">ITERATION_NUMBER </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">+</span><span style="font-size:10.0pt;font-family:"Courier New";color:maroon">1</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">])</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><br> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">ORDER</span> <span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">BY</span> <span style="font-size:10.0pt;font-family:"Courier New";color:maroon">1</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0000F0">;</span><br> <br> CUST CSV<br> ---------- ------------------------------<br> 5 100,234,333,336<br> 6 111,222,333 <br> <br> 2 rows selected.<br> <br> Other model to CSV solution can be found at<br> <a href="http://forums.oracle.com/forums/message.jspa?messageID=1815489#1815489" title="Oracle Forums">http://forums.oracle.com/forums/message.jspa?messageID=1815489#1815489</a><br> and<br> <a href="http://www.sqlsnippets.com/en/topic-12092.html" title="sqlsnippets">http://www.sqlsnippets.com/en/topic-12092.html</a><br> <br> In contrast to the example at the above URL, note the use of<br> UPDATE instead of UPSERT and the lack of a need for the "presentv" function.<br> The reference to a non-existent cell in "until thedate[ITERATION_NUMBER +2] is null"<br> returns NULL;<br> <br> Intuition tells me that UPDATE should run faster than UPSERT,<br> but I've not actually tested it.<br> <br> <br> </p> </div> Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4228170808530538594.post-23415097994530376732007-09-22T15:26:00.000-07:002007-09-22T16:22:42.505-07:00Using Dynamic Sql to work around PL/SQL bugs<p>A coworker encountered this problem. We search the Internet for a solution, but nothing was found. I am hoping that by posting this, others having the same problem will quickly find a solution. Furthermore, this example illustrates a more general principle which is that sometimes things work in SQL which do not work in PL/SQL and a simple solution is to use dynamic sql. </p> <p>This problem is encountered when trying to access an NVARCHAR2 using a TABLE function in PL/SQL.</p> <p>ORA-12714: invalid national character set specified<br /><code><br /></code></p> <p><tt>Originally written as:</tt></p> <p style="color: rgb(0, 102, 0);"><tt> FOR c IN ( SELECT * FROM TABLE (p_question_tab_i) ) LOOP</tt></p> <p style="color: rgb(0, 102, 0);"><tt> Processing….</tt></p> <p style="color: rgb(0, 102, 0);"><tt> END LOOP;</tt></p> <p><tt> Raises error: ORA-12714: invalid national character set specified</tt></p> <p><tt>Then re-written using dynamic SQL: </tt></p> <p style="color: rgb(0, 102, 0);"><tt> OPEN que_cursor FOR 'SELECT * FROM TABLE (:question_tab)'</tt></p> <p style="color: rgb(0, 102, 0);"><tt> USING p_question_tab_i;</tt></p> <p><tt>The above example works correctly…</tt></p> <span style="font-family: courier new;">question_tab TABLE OF QUESTION_OBJ<br />is</span><span style="font-family: courier new;"></span><br /><span style="font-family: courier new;">SELECT_TYPE VARCHAR2(10)</span><br /><span style="font-family: courier new;">DISPLAY_TEXT NVARCHAR2(4000)</span><br /><span style="font-family: courier new;">PROMPT_TYPE_CODE VARCHAR2(50)<br /><br /><span style="color: rgb(153, 0, 0);">Technically, this is not a PL/SQL bug. It is, however, a feature that is supported in SQL but not PL/SQL. This often happens with new SQL features where PL/SQL has not 'caught up' yet.</span><br /></span>Unknownnoreply@blogger.com3