Monday, February 14, 2011

Generating test data using PL/SQL

Here's a fun little PL/SQL package, part of the Alexandria library for PL/SQL, that you can use to generate semi-random test data.

The package is called RANDOM_UTIL_PKG. At the time of writing it contains the following functions:

  • GET_AMOUNT
  • GET_BUSINESS_CONCEPT
  • GET_BUZZWORD
  • GET_DATE
  • GET_EMAIL_ADDRESS
  • GET_ERROR_MESSAGE
  • GET_FILE_NAME
  • GET_FILE_TYPE
  • GET_INTEGER
  • GET_MIME_TYPE
  • GET_PASSWORD
  • GET_PERSON_NAME
  • GET_TEXT
  • GET_VALUE
  • GET_WAIT_MESSAGE


These should all be fairly self-explanatory, but let's look at some examples of how you could use these to fill your database with "realistic" test data.


A list of users





An email archive




A list of orders (and order items)





A list of uploaded files (or files in a folder)




A list of errors (an error log)




A list of business concepts or strategies

This is for those times when a struggling company needs to re-focus its strategy and define a new vision. No need to hire expensive management consultants, just fire up SQL*Plus and execute the following query:



Here are some of my favorites from the concepts I generated just now:


  • Quickly innovate sticky products with resource-maximizing portals.
  • Credibly plagiarize robust opportunities using timely architecture.
  • Dynamically reinvent dynamic leadership for end-to-end web services.
  • Appropriately empower front-end human capital via error-free web services.
  • Globally plagiarize stand-alone ideas after next-generation alignment.


2 comments:

Steven said...

Hey man, don't you have a dayjob? Perhaps I should whisper in your bossman's ear how you're skiving off work to bring PL/SQL goodies to the masses, instead of putting your shoulder to the wheel of corporate drugdgery...!!

Morten Braten said...

@Steven: Sure, I have a day job, but with PL/SQL and Apex I'm so productive that I get everything done, AND have time for blogging about it! :-)

- Morten