Skip to main content

Posts

Showing posts from November, 2018

Reduce the volume of PL/SQL code you write with these tips

I'm not known for being concise. I'm best known in the world of Oracle Database for my "magnum opus" Oracle PL/SQL Programming , which checks in at 1340 pages (the index alone is 50 pages long). But I've picked up a few tips along the way for writing PL/SQL code that is, well, at least not as long, as verbose, as it could have been. And certainly shorter than my books. :-) You probably have some ideas of your own; please offer them in comments and I will add them to the post. Qualified Expressions (new to 18c) In the bad old days before Oracle Database 18c was released (and is now available for free in its "XE" form ), if you wanted to initialize an associative array with values, you had to do in the executable section as follows: DECLARE TYPE ints_t IS TABLE OF INTEGER INDEX BY PLS_INTEGER; l_ints ints_t; BEGIN l_ints (1) := 55; l_ints (2) := 555; l_ints (3) := 5555; FOR indx IN 1 .. l_in