Oracle Stored functions and @Prompt at table owner level

Has anyone successfully utilized a stored funciton call from Oracle in a universe that utilizes the @Prompt at the table-owner level?

We are using an @Prompt function at the table-owner level to point the universe to multiple schemas. The Oracle stored function is used to determine the start of the fiscal year. It is used as a condition in reporting.

The problem we have encounter deals with the fact that BO returns an error message of ‘ORA-00904: invalid column name: -904’ when reporting from the universe that utilizes the @Prompt functions at the table owner level. Here’s the SQL from BO that generates the error message.

SELECT
  @Prompt('Business Unit','N','support\LOV',,).ENC_REG.NAME_L || ',  '|| @Prompt('Business Unit','N','support\LOV',,).ENC_REG.NAME_F || '  ' || @Prompt('Business Unit','N','support\LOV',,).ENC_REG.NAME_MI,
  @Prompt('Business Unit','N','support\LOV',,).ENC_REG.MR_NBR,
  (case when ENC_REG_ADMIT_DATE.ADM_DT= '11/11/1111' then '' else ENC_REG_ADMIT_DATE.ADM_DT end )
FROM
  IN300.PERIOD  ENC_REG_ADMIT_DATE,
  @Prompt('Business Unit','N','support\LOV',,).ENC_REG
WHERE
  (@Prompt('Business Unit','N','support\LOV',,).ENC_REG.ADM_DT_KEY=ENC_REG_ADMIT_DATE.DT_KEY  )  AND  (( case when ENC_REG_ADMIT_DATE.ADM_DT= '11/11/1111' then '' else ENC_REG_ADMIT_DATE.ADM_DT end )  >  sf_get_fiscal_year_start(sysdate))    

The Oracle function, which resides in each database schema, is as follows:

create or replace function sf_get_fiscal_year_start
(curr_date   in date
) return date as
   fiscal_year_start  varchar2(10);

begin

   if to_char(curr_date,'mmdd') >= '0701' and
      to_char(curr_date,'mmdd') <= '1231' then
         --Return 7/1/current_year
         fiscal_year_start := '07/01/'||to_char(curr_date,'yyyy');
         return to_date(fiscal_year_start,'mm/dd/yyyy');
   else
         --Return 7/1/prior_year
         fiscal_year_start :=
'07/01/'||to_char(add_months(curr_date,-12),'yyyy');
         return to_date(fiscal_year_start,'mm/dd/yyyy');
   end if;

end sf_get_fiscal_year_start;
/

I believe the issue surrounds the fact that BO doesn’t know where to find the ‘sf_get_fiscal_year_start’ function even though the user is prompted for the schema upon running the report.

Thanks in advance for your help. :crazy_face:


berkeyg :us: (BOB member since 2002-10-17)

I have used @prompts to provide a mechanism for switching between identical schemas, I don’t beleive that it is possible to use an LOV for this causes the error you get.

This is my syntax

EMA@prompt('1 Select Instance','n',,MONO,FREE).CAMPAIGNBASE.CODE

As you can see the LOV parameter is empty. Then it works fine

HTH


Paul Shovlar :uk: (BOB member since 2002-09-05)

Paul,

We actually have been utilizing a LOV in another universe quite successfully. Our LOv is actually a Personal Data source (Excel spreadsheet) that is referenced. The difference in this newer universe is that we are trying to utilize the Oracle stored function in conjunction with the @Prompt.

Also, just a note about your syntax, if you want to pass alphanumerc schema names through @Prompt instead of concantenating the EMA with the numeric portion, try changing the BACK_QUOTE_SUPPORTED=Y line in the .prn file to BACK_QUOTE_SUPPORTED=N. This will remove the quote around the entire table owner name, thus allowing you to pass an alphanumeric through the function.

Thanks


berkeyg :us: (BOB member since 2002-10-17)

Here’s some thoughts …

i) Is it not possible to use a table alias to simplify this a bit …

SELECT
  T1.NAME_L || ',  '|| T1.NAME_F || '  ' || T1.NAME_MI,
  T1.MR_NBR,
  (case when ENC_REG_ADMIT_DATE.ADM_DT= '11/11/1111' then '' else ENC_REG_ADMIT_DATE.ADM_DT end )
FROM
  IN300.PERIOD  ENC_REG_ADMIT_DATE,
  @Prompt('Business Unit','N','support\LOV',,).ENC_REG T1
WHERE
  (T1.ENC_REG.ADM_DT_KEY=ENC_REG_ADMIT_DATE.DT_KEY  )  AND  (( case when ENC_REG_ADMIT_DATE.ADM_DT= '11/11/1111' then '' else ENC_REG_ADMIT_DATE.ADM_DT end )  >  sf_get_fiscal_year_start(sysdate))    

ii) ENC_REG_ADMIT_DATE.ADM_DT= ‘11/11/1111’ would be better as ENC_REG_ADMIT_DATE.ADM_DT= to_date(‘11/11/1111’ ,‘mm/dd/yyyy’) or ENC_REG_ADMIT_DATE.ADM_DT= to_date(‘11/11/1111’,‘dd/mm/yyyy’), whichever is appropriate.

iii) That function call looks like bad practice to me, and you ought to replace it with …



> Add_Months(Trunc(Add_Months(sysdate,6),'YYYY'),-6)

iv) Finally, should that be “>” or “>=” for the start of fiscal year predicate?


slimdave :uk: (BOB member since 2002-09-10)

Gary,
Just a quick note… When dealing with @Prompts where you just want to pass the data along, and not validate it, then ‘N’ will work fine. This will allow either Text or Numeric, not just Numeric data. It’s a solution I’ve used for years on dynamic table names.

This basically tells BO how to handle “multiple” values, so a single value doesn’t have any effect on the way data is returned.

-RM


digpen :us: (BOB member since 2002-08-15)

Gotta love this place! I’m reading this and other threads because I have a universe and need to prompt for schema name. I’m putting the following in the ‘Owner’ box…

@Prompt('Schema','N',,Mono,Free)

but I’m getting a set of double quotes and an interesting alias issue like so…

SELECT
  "@Prompt('Schema','N',,Mono,Free).WKC_UTL_DTL".DTL_TYP
FROM
  "@Prompt('Schema','N',,Mono,Free)"."WKC_UTL_DTL"  Table__19

I’ve also noticed that I can only change the owner in this funky way once. The second time, the objects refuse to update their table names. I’m obviously doing something hideously wrong and I eagerly await the first person who points it out. :wink:


Cindy Clayton :us: (BOB member since 2002-06-11)

More valuable info here


Cindy Clayton :us: (BOB member since 2002-06-11)

Cindy,

Regarding your question on why you are seeing double quotes in your @Prompt statement…Check your prm file for line called BACK_QUOTE_SUPPORTED=N.

This line should be set to N and not Y. That should take care of the double quotes.


berkeyg :us: (BOB member since 2002-10-17)

Thanks Gary! :yesnod: . I read that higher up but I thought that what Rob (digpen) said meant that I wouldn’t have to make that change since using type ‘N’ would allow for both char and numeric and since validation isn’t an issue, I’d be fine. Obviously not :roll_eyes: :rotf: . I must have misunderstood.

Assuming I make your .prm change…what, if any, other issues/changes/problems/impacts might I expect? :?:


Cindy Clayton :us: (BOB member since 2002-06-11)

DRAT! OK so this is an Oracle universe so I checked the ora7en.prm in BO/Data Access/Oracle and it already has BACK_QUOTE_SUPPORTED=Y.

Ahhhh but after that I see TABLE_DELIMITER=". I’ll play with that…


Cindy Clayton :us: (BOB member since 2002-06-11)

I’m back. When I play with the delimiter value I can change the " to $ or % or whatever so I have confirmed that there is a connection to this parameter and my " but TABLE_DELIMETER= still gives me a single quote delimiter. I’m stumped and will keep searching and will welcome help :mrgreen:


Cindy Clayton :us: (BOB member since 2002-06-11)

More good info here


Cindy Clayton :us: (BOB member since 2002-06-11)

Woohoo! Yippee! I got it working. I wound up having to totally comment out…

#BACK_QUOTE_SUPPORTED=Y

and voila! What a waste of a day :roll_eyes: :wink:


Cindy Clayton :us: (BOB member since 2002-06-11)

Sorry all… I must not have really been reading these when I was reading them. I don’t really think that I “fill-in” the OWNER box with a prompt when I need to have dynamic Owners.

I still treat all of it as a Dynamic Table name, but the LOV that I provide is a combination of OWNER and TABLE_NAME from ALL_TABLES. If your Table does not actually have an OWNER associated, passing the OWNER in the tablename works fine.

Then you don’t need to worry about quotes or anything along those lines. It also prevents you from choosing an OWNER where they don’t actually have the table in their schema.

-RM


digpen :us: (BOB member since 2002-08-15)

It wound up working beautifully putting the @prompt in the owner box once I commented out the aforementioned parameter in ora7en.prm :yesnod: . Wonder what else that will impact…hmmmmm. Before I commented that out, I got a single quote I couldn’t get rid of regardless of whether I put the @prompt in the table or owner box. :confused:

Thanks Rob! :yesnod:


Cindy Clayton :us: (BOB member since 2002-06-11)

Ohhhhh set to ‘N’! I got it. :oops: I misread :oops: . Yes! Setting it to ‘N’ did the trick…as well as commenting it out altogether :wink: Now to see if a change to that file on the server will filter down to my Zabo users automatically because it looks like each Zabo server creates an ora7en.prm locally…


Cindy Clayton :us: (BOB member since 2002-06-11)

FYI: It seems to matter what the ora7en.prm value of BACK_QUOTE_SUPPORTED is only when you add the schema/owner prompting to the universe. I tested my schema prompting in Webi and Zabo and on another user’s machine and the sql generates properly regardless of this parameter value. HTH!


Cindy Clayton :us: (BOB member since 2002-06-11)

A little suggestion based on my experience with this. I’d also make sure and keep a parallel unprompted copy of the universe for the purposes of structure checking and refreshing so it will be easy to get a list of table changes.


Cindy Clayton :us: (BOB member since 2002-06-11)