Tuesday, August 24, 2010

Feedback on idea for comments and tracing from newsletter

In my latest PL/SQL newsletter (if you don't yet receive it, visit www.stevenfeuerstein.com and enter your email in the yellow box on the left side of the home page), I passed on a tip I got during a training, namely:

Tech Tip: A New Place for Your Comments?

I just gave a two-day, "Best of Oracle PL/SQL" training to a team of developers in Winona, MN, home of the Sugar Loaf Bluff, which I climbed after the first day of training.

One of the development managers, Jason McClellen of Fastenal, offered the following suggestion when I talked about the importance of application tracing or instrumentation:

Comments are usually added to code as "static" text, visible only when you open up and look at your source code. Instead of hiding away your comments, include them in the calls to your tracing mechanism. That way, whenever tracing is enabled, you not only see values of data being manipulated by the program, you also read information that informs your understanding of that data.

I think this is a fantastic idea, and I plan to start doing this in my own code. In Quest Code Tester for Oracle, I use a variation on the Quest Error Manager to do my tracing, so a trace call (preceded by a comment) might look like this:

/*
Simple datatypes require an initial value. This "value"
includes the assignment operator to simplify template construction.
*/
IF qu_runtime.trace_enabled
THEN
   qu_runtime.
    trace (
      'set_placeholders typename'
    , outcome_in.result.attribute.datatype_declare
   );
END IF;

In the future (in fact, right now - I will "refactor" this code), my tracing will look like this:

IF qu_runtime.trace_enabled
THEN
   qu_runtime.
    trace (
      'set_placeholders'
    , 'Simple datatypes require an initial value. This "value" '||
        'includes the assignment operator to simplify template construction.'
   );
   qu_runtime.
    trace (
      'set_placeholders typename'
    , outcome_in.result.attribute.datatype_declare
   );
END IF;

I then asked readers to tell me what they thought. Several people wrote in and I will post this in a reply. Feel encouraged to add your own thoughts.

Monday, August 23, 2010

PL/SQL Challenge players finds doc bug in STANDARD package

The PL/SQL Challenge recently (6 August) offered a quiz on the INSTR function. I showed everyone the header of this function from the STANDARD package in which it is defined:

-- Find nth occurrence of str1 in str2 starting at pos
function INSTR(STR1 VARCHAR2 CHARACTER SET ANY_CS,
   STR2 VARCHAR2 CHARACTER SET STR1%CHARSET,
   POS PLS_INTEGER := 1,
   NTH POSITIVE := 1) return PLS_INTEGER;

Jean Xu reported a problem with the comment above the header. It should say "of str2 in str1"! I'd never noticed this, with all the times I've looked at the STANDARD package. I let Bryn Llewellyn, PL/SQL Product Manager, know about this, so hopefully the next release of Oracle will include a correction.

Yet another benefit of playing the PL/SQL Challenge: you can help improve the quality of the PL/SQL language itself!

So if you are not yet one of the more than 2400 developers who have been taking the quiz in the last month, register and start playing today!

Tuesday, August 17, 2010

PL/SQL Challenge Live event in Melbourne, Australia

Quest Software and AUSOUG sponsored a PL/SQL Challenge Live quiz at the Insync 2010 conference on 16 August (which took place just 3 hours after I arrived from a very long odyssey from Chicago). This is the second live quiz I have done (the first was at ODTUG's Kaleidoscope conference in June), and it went much smoother than the first, since I built a PL/SQL procedure to automatically compute winners (manual processes really are things to avoid whenever possible!).

Forty-two developers played the quiz and I am pleased to announce that Jeff Kemp, currently ranked #5 in this quarter on the daily quiz, took first place with a score of 37 points out of a possible maximum score of 43. He wins a $100 giftcard from Westfield Mall. Here is list of the top 20 scorers in the competition:

01 Player JEFF KEMP = 37
02 Player STUART WATSON = 34
03 Player INDU NEELAKANDAN = 33
04 Player TREVOR TRACEY-PATTE = 33
05 Player BRETT MCBRIDE = 32
06 Player MARIA DE MESA = 32
07 Player KHOI NGUYEN = 32
08 Player IAN CORKHILL = 31
09 Player MARC THOMPSON = 31
10 Player ROHAN MILTON = 31
11 Player SWEE KEONG TAN = 31
12 Player RAY FEIGHERY = 31
13 Player GARETH OWEN-CONWAY = 30
14 Player TIM DANIELL = 30
15 Player ASHOK SHOKKANNAA = 30
16 Player THOMAS WENDE = 29
17 Player PANKAJ DADOO = 29
18 Player ROGER SCHNEIDER = 29
19 Player ANTHONY BRUMBY = 29
20 Player R F = 29

Hopefully they will all register at and play the daily quiz of the PL/SQL Challenge as well. They clearly have lots of promise! And if you are not yet playing the daily quiz of the PL/SQL Challenge, well please do join the other 1400 developers who play almost every day, learning more about PL/SQL and winning weekly and monthly prizes.

Finally we were lucky enough to have Tom Kyte in attendance at the live quiz. He was kindly pointed out two subtle problems with the quiz, so I cleaned those up for the other quizzes this week. One point will also result in a minor change in our assumptions.

Thursday, August 12, 2010

Fall 2010 Webinar Series Sponsored by Quest Software


I will be conducting a third series of webcasts for Quest Software that will put you on the fast track to maximizing your understanding and use of Oracle PL/SQL. Here are lots of details and links for registration. I hope to "see" you there!

Session 1: Programming with Collections
Monday, September 27, 2010 at 2:00 p.m. Eastern ($200.00 US
)

Collections (array-like structures in PL/SQL) are critical data structures that are used in some of the most important features of PL/SQL. Every PL/SQL developer should have a deep familiarity with collections and the wide range of features that Oracle has implemented for them over the years. This session introduces collections and quickly moves on to detailed explanations of collection methods, how to leverage string indexing in associative arrays, multi-level collections, set-level operations on nested tables and more. The session will run for approximately two hours. 
Register 

Session 2: Say Goodbye to Hard-Coding in PL/SQL
Wednesday, October 6, 2010 at 2:00 p.m. Eastern ($200.00 US
)

Everyone knows that hard-coding is a bad idea. Too many developers, however, only think in terms of literal values when they think of hard-coding. There are, unfortunately, many ways that hard-coding manifests itself in our programs. This webinar offers a comprehensive look at all the types of hard-coding that can appear in your programs, from literals to explicit declarations to exposed formulas, and offers specific techniques to get rid of the hard-coding. The result is code that is much easier to read and to maintain. The session will last approximately two hours.
Register

Session 3: Dynamic SQL in Oracle PL/SQL
Wednesday, October 20, 2010 at 2:00 p.m. Eastern ($200.00 US
)

Dynamic SQL (construction, parsing and execution of SQL statements and PL/SQL blocks at runtime) has become a common and critical element of most modern applications. PL/SQL offers two distinct methods for dynamic SQL: native dynamic SQL  (NDS) and DBMS_SQL. This webinar focuses primarily on the capabilities of native dynamic SQL: how to use EXECUTE IMMEDIATE to execute dynamic query, DML, and DDL statements. We will also go beyond the basics and delve into when to use DBMS_SQL (method 4 dynamic SQL), and new Oracle Database 11g features for dynamic SQL (most importantly, interoperability between DBMS_SQL and NDS.  The session will last approximately two hours.
Register

Friday, August 06, 2010

Update: Eli as Programmer

Almost three weeks ago, my son Eli started working for me as an APEX programmer - with absolutely no background in software. He'd focused mainly on being a musician for the last five+ years (guitar, songwriting, etc.). So: minimal mathematics education; no knowledge of SQL or PL/SQL; no experience with HTML, Javascript....what were we getting ourselves into?

I am very pleased to report that Eli has made rapid progress. He is now building basic APEX applications, writing queries and other SQL statements, making changes to the PL/SQL Challenge application (very simple changes for now!), learning HTML.

He whips through APEX design pages so quickly, I start to get dizzy trying to follow him. It looks like this is going to work out very, very well.

Eli told me that while he hadn't written software, he had lots of experience with creating and manipulating music in his head. We agreed that this would likely help with programming and I would say that this is now well established. While Eli had not experience with SQL syntax, his brain seems to be very nicely trained to work with a large number and highly complex abstractions. So the switch from music to logic/code seems to be a smooth one.

In addition, while Eli is not video game fanatic, he has certainly spent time on various game consoles from a relatively early age. I think back to a 10 year old Eli playing a game that involved choosing and arming characters for a quest, solving puzzles on the screen, quickly paging through menus and options....and then I look at him "playing with" the APEX interface.

I realize that for a person who has trained his or her brain to work with a rich UI found in video games, in which most of your activity is point-and-click rather than typing, an environment like APEX is "child's play" - a relatively crude and simplified interface.

So I now declare myself happy that Eli played video games, to prepare himself for the "real world."

Eli, it has been a real pleasure to work with you and I look forward to lots more of it in the future!