It was Chen Shapira's idea and here I am making it the official first ever Oracle community contest.

Read on to learn more about the obfuscated SQL code contest.

What does obfuscate mean?

To obfuscate means to make so confused or opaque as to be difficult to perceive or understand.

What are the goals of the contest?

  • To write the most Obscure/Obfuscated SQL query.
  • To show the importance of SQL programming style, in an ironic way.
  • To stress SQL techniques with unusual code.
  • To illustrate some of the subtleties of the SQL language.
  • To provide a safe forum for poor SQL code.

What are the rules of the contest?

  • Your entry must be one SQL script file.
  • The SQL script must contain only one SQL (SELECT) statement.
  • The SQL statement can be as short or as long as you want and may contain an unlimited number of subqueries or inline views.
  • You must provide the database version the script was tested on.
  • The SQL statement must be able to be executed by anyone with a connection to an Oracle database - with at least the same database version as indicated by the author.
  • If needed, the script may include test data or database object creation code required to make the SQL statement execute successfully.
  • The SQL script must be of original work.

Who is eligible to participate?

Any Oracle Community member is eligible to submit one entry.

How do I submit an entry?

Just upload the SQL script file with your reply below. Make sure the file's extension is either sql or txt. In addition to uploading the file, you may also include a link to your entry, if you have published it on your blog or web site.

What else?

April 1st 2008 is the last day you can participate in this contest and submit your entry. After that date, all eligible entries will be voted/commented on. The author of the most popular entry will be declared the winner.

Happy obfuscation and good luck!

Tags: contest, sql

Views: 1607

Replies are closed for this discussion.

Replies to This Discussion

The SQL script must contain only one SQL (SELECT) statement.

So no subqueries are permitted, inculding inline views?
I meant one top level SELECT. You can have an unlimited number of subqueries or inline views. Thanks for the clarification. I have clarified the rules above accordingly.
The scripts requires version 11.1.0.6, because of the pivot operator.
If you don't have that version, you can see the output here
Attachments:
Got my vote! Belongs on a t-shirt ...

does it need to be our own code? I don't think I could win if I had to write something worse than other peoples code that I see everyday.

here's one from OTN. the question was "how to calculate the next YYYYIW in a sequence". but it really was "the next IYYYIW". so if you're currently in 200813, the answer is 200814. but at the end of a year, you wrap around to IYYY+1, and IW goes back to 01. and don't forget to account for years with 53 weeks (like 2009).

The Obfuscated sql statement makes use subquery factoring, generates rows from dual via "connect by level <", and is overall quite the spectacle to look at. and it is truely obfuscated when you consider the same results can be achieved with this simple statement:

to_char( trunc(trunc(to_date( iyyy,'yyyy'),'iyyy'),'iw') + iw*7 ,'IYYYIW') next_iw

(where IYYY and IW represent the year/week value which needs to be incremented).
this came from http://forums.oracle.com/forums/thread.jspa?threadID=633028

I tested it (and my simpler solution) on 10.1.0.2.0
Attachments:
10.1.0.5
here is the code :
tried it on both 10.1.0.2 and 10.2.0.3 and got the following error:

ORA-19202: Error occurred in XML processing
ORA-24333: zero iteration count
ORA-06512: at "SYS.DBMS_XMLGEN", line 176
ORA-06512: at line 1
The only unobfuscated part of Laurent message says 10.1.0.5.
Try there :-)
well if I had that exact version, I'd try it ;)
so instead I tried just a little lower and just a little higher, and neither worked.
so how about someone with 10.1.0.5 try it and post the results so I can at least see what I'm missing.

and since this seems to work on one and only one subversion, it might be the most obfuscated code possible.
--------------------------- Quadruplet Puzzle ---------------------------------

The following Quadruplet Puzzle Query Solution can solve "4" different puzzles in a single ORACLE SQL.

Puzzle 1: Largest Rectangle of Words
find the largest possible rectangle of letters such that every row forms a word (right to left) and every column forms a word (reading top to bottom)

Puzzle 2: blank SUDOKU Solution

Puzzle 3: Impossible_Combinations
What is the smallest number of coins that you can’t make a dollar with? i.e.,for what N does there not exist a set of N coins adding up to a dollar? It is possible to make a dollar with 1 current U.S. coin (a Susan B. Anthony), 2 coins (2 fifty cent pieces), 3 coins (2 quarters and a fifty cent piece), etc. It is not possible to make exactly a dollar with 101 coins.

Puzzle 4: Divisible by 1 to 9
Find a 9-digit number a[1]a[2]a[3]…. containing all the digits 1,2,…,9 such that “K” divides a[1]a[2]a[3]…..a[k] for each k = 1,2,3….9.

Version : Oracle Database 10g Enterprise Edition Release 10.2.0.2.0

Here is the SQL Code :
Attachments:
LOL, pasted it into the code formatter at orafaq, formatter couldn't handle it.

RSS

Oracle Community On

I'm not a fan of advertising, and so I will not be including any advertisements on OracleCommunity.net. However, managing this community does not come without cost! If you are willing to donate to help pay for the monthly community fees and domain services I accept Bitcoin and PayPal donations.

Donate Bitcoins

Badge

Loading…

Blog Posts

Packt Publishing announces "Advanced Oracle PL/SQL Developer's Guide"

My fondness for database development is flaring up again. Gladly I would like to share the announcement of my upcoming book "Advanced Oracle PL/SQL Developer's Guide - Second Edition" by Packt Publishing. The area of the focus is same i.e. Oracle PL/SQL but this version is largely revamped to whisk with Oracle Database 12c features and applications. While the first edition will always remain close to my heart, the second edition is a sheer investment of my experience attained so…

Continue

Posted by Saurabh K. Gupta on July 27, 2015 at 9:41pm — 1 Comment

What Benefits Does an MCSE Certification Carry?

MCSE certifications are the most popular certifications around the world. And, their popularity isn't without reason. In the following post I have highlighted the benefits that you can derive from an MCSE certification, so as to help you gauge how useful it can be for your career. Read on to know.…

Continue

Posted by Michael Warne on May 28, 2015 at 1:32am

Default Login Form customize

Dear All, I want to customize oracle 10g default login page. How can I do this. I attached the login page for better understanding.

Posted by Shakaouth Shanto on May 19, 2015 at 10:00pm

Live SAP Hybris Online Training Classes at VirtualNuggets

Web URL      :  http://www.virtualnuggets.com/sap-hybris.html

Email              :  info@virtualnuggets(dot)com

Contact           :  +1-7076668949(USA)         +91-8885560202(India) 

 

Live SAP Hybris Online Training Classes at VirtualNuggets

 

SAP Hybris is a standout amongst the most widely recognized e-commerce platforms       on the Internet…

Continue

Posted by Vasu Buddi on May 12, 2015 at 11:14pm

© 2015   Created by Steve Karam.

Badges  |  Report an Issue  |  Terms of Service