Archiwa tagu: PL/SQL

Procedural Language/Structured Query Language

Searching in the source of a view

Let's take a view at it

Once upon a time… I needed to check in the source of which objects a particular character string was included.

LONG (the pun!…) story short, non of the {USER|ALL|DBA}_SOURCE views give you a chance to search in the source of the views.

“Well, why is that a problem?!” – I hear you saying – “Don’t you know the {USER|ALL|DBA}_VIEWS views views (wait, one views too many)?”

O my, but of course! There’s a column named TEXT in them with the source of the views! Let’s try that: 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

- Waiter! There's a BLOB in my 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

Solution shorter than the title

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

The Three-eyed Raven likes it

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