Re: Display view equations?

  • From: "Rumpi Gravenstein" <rgravens@xxxxxxxxx>
  • To: jkstill@xxxxxxxxx
  • Date: Thu, 12 Jun 2008 23:33:51 -0400

Here's another choice.

If you create the view with parsable tokens embedded within comments and
then use regular expression to get what you want.

e.g.

create view test_view as
SELECT /*|*/ 1+2 /*|*/ calc FROM DUAL;

Now the following SQL can be used to retrieve the calculation:

SELECT regexp_substr( 'SELECT /*|*/ 1+2 /*|*/ calc FROM DUAL;', '[^|]+,1,2)
FROM DUAL;

which returns
*/1+2/*

You could then remove the first and last two letters in the substr to get at
what you want.

One comment with this type of an approach.  The USER_VIEWS presents the
"text" as a LONG column.  Regular expressions don't function on LONG
columns.  So the view you create might need to be a pipelined table function
that handles the conversion to a string.

Other related posts: