Archiwum kategorii: PL/SQL

Oracle’s Procedural Language extension for Structured Query Language.

Answer to Quiz #1: Package Dependency

Packages and Dependent Objects

In my last post, I’ve challenged you with a quiz about package dependency. The question was about when a dependent object will be invalidated by Oracle when the package on which it depends is recreated.

The choices which give the „INVALID” status are:
Czytaj dalej

Quiz #1: Package Dependency

Packages and Dependent Objects

I’ve got the following quiz for you today:

After running which of the following code snippets will the 'INVALID’ status be returned?

Assumptions:

  • Version of Oracle: 11g R2.
  • Before each snippet is run, both dummy_pkg and print_message objects do not exist.

I’ll provide the answer in my next post.

The choices:
Czytaj dalej

Returning BLOB From Embedded Java

Returning a BLOB from a Java Method Embedded in a Database

You’re about to learn your future

Oracle supports embedding Java classes in its database. Different SQL types are mapped to corresponding Java classes to allow us to make the most of this feature. Author of the following question on StackOverflow:

create-java-sql-blob-instance-in-java-stored-procedure

had an issue with returning a BLOB object from Java method back to PL/SQL context. In the beginning, I didn’t even think you could return a new BLOB object from an embedded class. Fortunately, there was a BLOB in my Java, too. Czytaj dalej

How to Pass an Array of Object Type
To Static Function of That Type

Array of an Object Type Argument in a Function of That Object Type

Interesting question regarding Object Types was asked not a long ago on StackOverflow:

How to Pass a Nested Table of Object Type to a Function of That Object Type?

What author was trying to accomplish was to declare a static function in an object type which would take as a parameter an array of objects of the object type in which it was declared.

Is that even possible? (dramatic pause) Czytaj dalej

Three-valued Boolean Logic

Shortly about chickens and roads…

Why did the chicken cross the road?
Because 1 > NULL AND cross_the_road()

I bet you have heard about the chicken and you know at least a dozen reasons why it had crossed the road. I wouldn’t bet, though, that you have heard about the three-valued logic. And this one is interesting, it even makes the chicken cross the road. The answer to the above question could also be given as: Because it (the chicken) didn’t short-circuit evaluate. What does it all mean? Czytaj dalej