User function

To get the user id in the current session, I can normally do this in a stored procedure:
select user into parm_user_ID from dual;
But now I need to do the following, instead:
1) A user id p_uid is passed as a parameter from the "front end" such as from the browser;
2) Set the user id to the session or a global variable holder
3) Get the user id from any function in the current session
4) Use it in a SQL such as:
select user_name into username from user_table where user_id = p_uid;
If this is in the same procedure where the p_uid is passed, then it would not be a problem. But I want to access the p_uid from ANY function in the current session when in need. That is why I need to set it either in the session or a global variable. I prefer to set it to the session, then retrieve it from the session later in need. But how to do it?
Thanks

>
But now I need to do the following, instead:
1) A user id p_uid is passed as a parameter from the "front end" such as from the browser;
2) Set the user id to the session or a global variable holder
3) Get the user id from any function in the current session
4) Use it in a SQL such as:
select user_name into username from user_table where user_id = p_uid;
If this is in the same procedure where the p_uid is passed, then it would not be a problem. But I want to access the p_uid from ANY function in the current session when in need. That is why I need to set it either in the session or a global variable. I prefer to set it to the session, then retrieve it from the session later in need. But how to do it?
>
That's what CONTEXTs are designed for.
See CREATE CONTEXT in the SQL Language doc
http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_5002.htm
The example at the end shows how to create and use them. It refers you to this link for how to create the requisite procedure.
http://docs.oracle.com/cd/B28359_01/network.111/b28531/app_context.htm#DBSEG66353
You can create a CONTEXT that is SESSION specific or one that is GLOBAL and whose variables can be accessed by any session.
http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_5002.htm
You could also create a LOGON trigger that sets any standard set of variables into the context for you.

Similar Messages

  • User Function Name wrong resultset in Oracle Apps Query

    Hi,
    I am using the below query to extarct the user function names alonng with responsilibity .But doing so i am getting a User Function Name for eg 'Cross Validation Rules' under Order Management User.But thats wrong.Cross validation rules should exists in Receivables,GL and Payables.
    select distinct frv.menu_id, frv.responsibility_id, frv.responsibility_name, fff.function_name, ffft.user_function_name
    from
    fnd_responsibility_vl frv,
    fnd_responsibility frp,
    fnd_form_functions fff,
    fnd_form_functions_tl ffft,
    fnd_resp_functions resp,
    fnd_menu_entries mnu,
    fnd_menus fmn
    where
    fff.function_id = ffft.function_id
    and mnu.menu_id=frp.menu_id
    and mnu.menu_id=fmn.menu_id
    and frv.responsibility_id=resp.responsibility_id
    and mnu.function_id=ffft.function_id
    and resp.rule_type='M'
    and frv.menu_id in (select me.menu_id
    from fnd_menu_entries me
    start with me.function_id = fff.function_id
    connect by prior me.menu_id = me.sub_menu_id )
    and (frv.responsibility_name like '%Order%')
    order by 1
    Kindly any help will be helpful for me

    What is your application release?
    I am using the below query to extarct the user function names alonng with responsilibity .But doing so i am getting a User Function Name for eg 'Cross Validation Rules' under Order Management User.But thats wrong.Cross validation rules should exists in Receivables,GL and Payables.Please try the queries in these docs.
    Script To Extract Submenu And Function Information About A Menu [ID 458701.1]
    HOW TO GENERATE MENU TREE FOR A MENU ATTACHED TO A RESPONSIBILITY IN ORACLE APPLICATIONS 11i ? [ID 312014.1]
    Thanks,
    Hussein

  • Problem while using a user function

    Hi,
    I just want to learn how a user function in ODI works.
    I have created a user function(for Oracle technology).
    In Definition Tab, I gave bfun($(branchc))
    In implementation I gave
    if ($(branchc) = 'it' || 'cse') then
    return('IT')
    else
    return('Non-IT')
    end if
    In a mapping rule i am using it as BFUN(STUDENT.BRANCH)
    I am getting the following error...
    Bad Query: ORA-00904: "BFUN": Invalid Identifier
    select BFUN('STUDENT.BRANCH') from EX.STUDENT STUDENT where (1=2).
    EX is my source schema.
    Please help me in resolving this.

    Hi,
    That is a common error on ODI.
    The ODI function, (as ODI variable) is to "substitute words", it means, ODI is a code generator and a function are made to substitute code, not to "execute" that action coded.
    For instance: If there are a "case when" instruction that is necessary be typed over and over again, at several places just change the column to be evaluate, you can create a ODI function to substitute this code avoiding type it several times and better, let the same code in just one place.
    Is a way to have “Object Orientation” coding (OO) to code generation...
    Does it make any sense to you?
    Cezar Santos

  • Incorrect Results When Using an In-Line View and User Function in 10g

    My developers are complaining of incorrect Select statement results when using an in-line view along with a user defined function. Below is the statement:
    select test_f(wo1)
    from
    (SELECT a.WORK_ORDER_NBR, b.work_order_nbr wo1/*, facility_f(A.FACILITY),
    A.PLANNER, A.WO_STATUS, mil_date(A.WO_STATUS_DATE)*, A.WORK_ORDER_TYPE,
    A.WO_DESCRIPTION
    FROM TIDWOWRK A, TIDWOTSK B
    WHERE B.WORK_ORDER_NBR(+) = A.WORK_ORDER_NBR))
    where wo1 is null;
    Test_f() is a user defined function and the above query returns thousands of rows. It should return 308 rows. It is apparent that the target database is not evaluating the "where wo1 is null;" clause.
    select to_char(wo1)
    from
    (SELECT a.WORK_ORDER_NBR, b.work_order_nbr wo1/*, facility_f(A.FACILITY),
    A.PLANNER, A.WO_STATUS, mil_date(A.WO_STATUS_DATE)*, A.WORK_ORDER_TYPE,
    A.WO_DESCRIPTION
    FROM TIDWOWRK A, TIDWOTSK B
    WHERE B.WORK_ORDER_NBR(+) = A.WORK_ORDER_NBR))
    where wo1 is null;
    In the above query return 308 rows. The user function was replaced by an Oracle function. The Where clause is now evaluated correctly.
    The query is executed from an Oracle 10g R2 database and retrieves data from a 9.2.0.6 database.
    I've seen a little information on Metalink. It appears that there was some trouble in 9i, but were fixed in a 9.2.0.6 patch. I don't see any information about a 10.2.0.2 database.
    Anyone have any experiences or a successful solution. I suspect that I will need to report this to Oracle and wait for a patch.
    Thanks,
    John

    I can only think of two reasons for this behaviour:
    1) You are executing these two queries from two different users and there is some policy on the table.
    2) The function doesn't do an upper, but returns null a lot of times, even when the input is a not null value, like this:
    SQL> create table tidwowrk
      2  as
      3  select 1 id, 'A' work_order_nbr, 'DST' facility from dual union all
      4  select 2, null, 'TRN' from dual union all
      5  select 3, 'C', 'DST' from dual
      6  /
    Tabel is aangemaakt.
    SQL> create table tidwotsk
      2  as
      3  select 'A' work_order_nbr from dual union all
      4  select 'B' from dual
      5  /
    Tabel is aangemaakt.
    SQL> create or replace function test_f (a in varchar2) return varchar2
      2  is
      3  begin
      4    return case a when 'A' then null else a end;
      5  end;
      6  /
    Functie is aangemaakt.
    SQL> select count(*)
      2    from ( SELECT a.WORK_ORDER_NBR
      3                , test_f(b.work_order_nbr) wo1
      4             FROM TIDWOWRK A
      5                , TIDWOTSK B
      6            WHERE B.WORK_ORDER_NBR(+) = A.WORK_ORDER_NBR
      7              and a.facility in ('DST', 'TRN', 'SUB')
      8         )
      9   where wo1 is null
    10  /
                                  COUNT(*)
                                         3
    1 rij is geselecteerd.
    SQL> select count(*)
      2    from ( SELECT a.WORK_ORDER_NBR
      3                , to_char(b.work_order_nbr) wo1
      4             FROM TIDWOWRK A, TIDWOTSK B
      5            WHERE B.WORK_ORDER_NBR(+) = A.WORK_ORDER_NBR
      6              and a.facility in ('DST', 'TRN', 'SUB')
      7         )
      8   where wo1 is null
      9  /
                                  COUNT(*)
                                         2
    1 rij is geselecteerd.Regards,
    Rob.

  • Using the Dollar($) Sign in a User Function Implementation

    Hi All,
    Just a quick question: how could you use a dollar($) sign in the implementation (Oracle) of a user function? I'm asking because the table name that I'm using in the implementation happens to contain the dollar sign (I$_FACT_SALES) and from the results I'm getting now, ODI reads the $ as reference to a variable, therefore removing the $-sign from my table name upon execution (I_FACT_SALES). Is there something like a backslash or some other character that could be inserted before the $ so it would register as part of the table name?
    Any response would be greatly appreciated.
    Thanks very much,
    Marco

    You may have 3 options:
    1.) Try using the tablename in quotes "MY$TABLE" or may be MY$$TABLE using double $ symbol
    or
    2.) I found this code snippet : odiRef.getInfo( \\u0022DEST_WORK_SCHEMA\\u0022 )+\\u0022.\\u0022,\\u0022\\u0022)?. So on these lines you can use \\u0022 as a symbol for "
    You can see similar problem/solution/explanation in
    Re: Regular Expression wierdness - problem with $ character
    or
    3.) Change the Work Tables Prefix in Topology Manager > Physical Schema > Your_Schema
    from E$_ , C$_ , I$_ to something like ERR_ , SRC_ , INT_
    Edited by: Ace2 on Dec 2, 2009 9:57 AM

  • Using PL/SQL code in ODI User Functions

    Is it possible to write PL/SQL code (with multiple in params and one out param) in ODI User Function ?
    Actually I need to use this user functions in my interface mapping.
    I know it can be done using ODI Procedures but Procedures cannot be used within interfaces when mapping columns.

    Hi Anurag Ambasta,
    You can use the ODI user functions and choose the Linked technology as 'Oracle' where you can implement and use oracle syntax .
    And the user functions can receive the multiple parameters and it returns the single value to the function cal, which use are expecting right?
    Thanks,
    Yellanki

  • Calling user function from Interface mapping

    I am getting error "Bad query:ORA-00904: invalid identifier" while calling function in the mapping of an interface.
    Can some one provide the syntax of calling user function from interface mapping.
    Thanks,
    RP

    user452108 wrote:
    Can some one provide the syntax of calling user function from interface mapping.Oracle's Call Iinterface, the OCI, does not work differently when coding using a Dvorak keyboard, or writing code using a pretty pink font in the editor.. or coding the call from an interface mapping (whatever the hell that that is).
    You have 2 types of calls. SQL and PL/SQL.
    To call a function via SQL, it can be done using a the standard cursor interface. E.g.
    select MyFunkyFunction from dualIt will return the function value via a single row with a single column. The standard cursor fetch and close cursor calls are used.
    To call it via PL/SQL, an anonymous PL/SQL block is needed, and the caller needs to use a bind variable to receive the value from the function. The anon block will look as follows:
    begin
      :bindVar := MyFunkyFunction;
    end;Refer to your client's abstract layer for interfacing with the Oracle Call Interface, on how to deal with bind variables.

  • User function code not substituted

    Hi
    I have a user function (getCode(...)) of the form
    case
    when exists (select * from ...)
    then '!Ok!'
    else '!None!'
    end
    When I use this function in a interface mapping (getCode(a,b,c)), the code is not substituted in the generated query (as seen in the operator):
    insert /*+ APPEND */ into ...
         Z_CODE,
         RUN_NR,
         REC_ID
    select     
         getCode( NAME, 'ZIV', 'G' ),
         RUN_NR,
         REC_ID
    from     ...
    where     (1=1)
    and the execution results in an ORA-00904 exception: Invalid column name.
    How come?
    Thanks

    First of all, thanks for your answers!
    The problem was lying in the definition of the function's syntax:
    I'm using the possibility to specify the data_type of the arguments: getCode($(run_nr)n, $(tabi)s, $(code)s).
    Unfortunately, I put a space between the arg_name and the data_type! This causes the function not to be substituted into the query ...
    Once again thanks to all.
    Cheers, Benno

  • How to create user function in Data Functions in Query Designer?

    Could someone tell me how to create user function in Data Functions in Query Designer?
    I mean function like "NDIV0" in Data Functions.
    SAP BW 3.x.
    Query Designer (SAP BW 3.x)

    Hi check the following URL, it gives how to add in Formulas in formula Builder, not in DataFunctions.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f095592f-42f7-2a10-6ab1-c836a559b48f
    Thanks
    Reddy

  • The user function manager DLL (ufmanager.dll) could not be found.

    Hi Everyone,
    I just spent two horrible days getting a Windows 2003 server to run our .net 2008 asp Crystal report.  It was all because of the unknown.rpt error.  The final answer was to give the NETWORK SERVICE account full control to the C:\ and then remove that permission. 
    Now, I'm up to my next challenge:
    Error in File C:\WINDOWS\TEMP\CrystalReport {2A76C903-674A-4A7B-AA04-44FC7E206C3F}.rpt:
    The user function manager DLL (ufmanager.dll) could not be found.
    That dll is there on the server.  What should I do?
    Please help!!!!
    Thanks,
    Ed

    Ok, here is where the fun begins as the issue you are getting is not something I've run into before. A few clarifications and suggestions re. troubleshooting.
    I used the latest runtime.msi
    - confirm this was CRRedist2008_x86.msi (just want to be sure)
    pdf about the unknown.rpt.
    - do you have a link or name of the pdf?
    To troubleshoot let's do this:
    1) Download the depends utility. I want to see if there is a missing dependency. depends is here:
    http://www.dependencywalker.com/
    open the ufmanager.dll in depends and see what it reports.
    2) Run Process Monitor utility. ProcMon can be downloaded from here:
    http://technet.microsoft.com/en-ca/sysinternals/bb896645.aspx
    Make sure you filter ProcMon for your process as this will shrink the log file. Then look for ufmanager.dll and see where the app is trying to load it from.
    3) Check this registry entry:
    HKLM\software\business objects\10.5\crystal reports
    See that CommonFiles is pointing to c:\program files\business objects\common\2.8\bin.
    4) Copy the ufmanager.dll from c:\program files\business objects\common\2.8\bin to your app directory (this is just a test as I want to see if we can load the dll from anywhere...)
    Ludek

  • Use of user function

    Hello,
    Does someone know if it is possible to create an ODI Sequence where the filter to extract only a single record is an user function ?
    Cause it seems to not work on my devlopment.
    I can't do it without user function cause the query in my sequence is more than 255 characters.
    Else I'm trying to do the same thing with a variable and a user function but it doesn't work better.
    So does someone know if in a mapping we can execute a user function based on a variable ??
    Thanks in advance.
    BM

    Hi BM,
    how are you?
    Did you solve this one? If not I will try to help you....

  • User Function Library for Crystal Reports 10 doesn't work on Win2K3 SP2

    Hi,
    Recently, we have been facing problem with Crystal Reports 10 developer edition on Windows Server 2003 R2 Service Pack2.
    The user function library concept doesnu2019t seem to be working on Windows Server 2003. We had installed CR10 Service Pack 6.
    We have a UFL written in VB 6.0 and this UFL is used in a formula in one of our reports.
    Whenever this report is invoked, the application crashes with a page fault. Dr Watson log files points to a crash occurring in Crystal Reports component.
    To reproduce this problem:
    1) Create a UFL in VB 6.0
    2) Use the UFL in a formula in a report
    3) Create a VB 6.0 application and use CR 10 Report Viewer control
    4) Invoke the report from the application
    5) The application crashes on Windows Server 2003 (SP2).
    This is a high priority issue.
    Is there any other alternative to User Function Library?
    Any help on this will be very much appreciated.
    Thanks in advance.

    Hi,
    Recently, we have been facing problem with Crystal Reports 10 developer edition on Windows Server 2003 R2 Service Pack2.
    The user function library concept doesnu2019t seem to be working on Windows Server 2003. We had installed CR10 Service Pack 6.
    We have a UFL written in VB 6.0 and this UFL is used in a formula in one of our reports.
    Whenever this report is invoked, the application crashes with a page fault. Dr Watson log files points to a crash occurring in Crystal Reports component.
    To reproduce this problem:
    1) Create a UFL in VB 6.0
    2) Use the UFL in a formula in a report
    3) Create a VB 6.0 application and use CR 10 Report Viewer control
    4) Invoke the report from the application
    5) The application crashes on Windows Server 2003 (SP2).
    This is a high priority issue.
    Is there any other alternative to User Function Library?
    Any help on this will be very much appreciated.
    Thanks in advance.

  • Calling User Functions in ODI Procedure

    Hi All,
    Can anyone pass me the syntax in which i can call a ODI User Function in ODI Procedure?
    Thanks,
    Ritika

    Hi,
    just use
    function("parameter_char", parameter_number)
    Does it help you?
    Cezar Santos
    (www.odiexperts.com)

  • End user functional difference between Cognos ReportNet -VS - OBI EE

    Hi all.
    Are there any real difference Cognos ReportNet -VS - OBI EE from an end user functionality point of view? I have created a laundry list of end user functionality we are interested in and I can't see the differences. The end user functionality is implemented differently but they all seem to be there.
    Thanks in advance for any help.

    Hi
    I do believe your statement is correct in that there is little to choose between Cognos and BI EE. They both cost a lot of money too.
    Personally I'm waiting on the interface for Discoverer to BI Publisher. When this comes out during the next few months we'll see Discoverer getting another boost.
    Best wishes
    Michael

  • Global User Functions not replaced in Check Contraint

    Hi all,
    we just moved from ODI 11.1.7 to ODI 12.1.2 an have the following problem. Our global user functions which are used in several Check Conditions are no longer replaced during code generation.
    They worked like a charm in ODI 11.1.7. Any ideas?
    Kind regards,
    Jens

    We are running Scenarios and Mappings from Designer using Local and Remote Agents (Simulation and Execution Mode). No difference at all.
    Global User Functions are replaced in Filters and Target Expressions but not in ODI Constraints.

  • Change User Function Name

    Hi all,
    I'm trying to create menus & responsibilities using data loader so that I don't need to recreate it manually but data loader crashed because some of the user function name are the same.
    For example, open Sysadmin -> Application -> Menu -> AP_PAYMENTS_ENTRY_GUI12 in Vision. In Seq. 3 we have Payments menu with AP_APXPAWKB_CHECK_MENU submenu and Payments functions. Tried to search in Functions LOV and we'll get some User Function Name equal to Payments but different Function Name.
    I'd tried to change some User Function Name and all the menus that directed to it changed too, the referential integrity worked I think :P but I want to ask whether it will caused any trouble if I changed it in Test & Production environment?
    Thx.

    I don't consider those to be "hacks" in my book
    They are just bad design approaches:
    In the first case, you will loose the audit trail to the caller.
    In the second case you will be forced to grant authority to the end user to open a step in another user's context. That will open another backdoor for them as well in SM37 etc...
    > PS: If the real problem is just that you cannot grant the authorization on a certain function module as it is used in different standard applications so the authorization for your program would result in to powerful authorizations in sap standard transactions, the I would copy the function module and use it. This Z fm could be authorized bypassing this problem.
    A better option with less coding involved, would be to use SU24. This way you keep the audit trail and isolate the transaction as being an exception to the standard checks for one specific object. An auditor might wonder why a user can release a PO when they don't have one of the required objects, but they will easily find it if they know where to look.
    It is also easy to do this in a secure way, such that you can document it for the auditor and give it to them upfront to understand. A good auditor should understand and appreciate that.
    If you achieve this programmatically with tricks, you will have a tough time... (as will the auditor).
    I have done many audits and also hunted down some dodgey coding in my time. The idea should not be to run away from the auditors, but rather expect that they know what they are talking about and make your design compliant with their and your client's control requirements.
    This should be the approach regardless of whether or not you can change sy-uname as a developer.
    The original question might also have been: "Can I pass a backdated authority-check against a user who once had the authorizations way back when?" Same thing... bad idea...
    Cheers,
    Julius

Maybe you are looking for

  • Email xls to text as email

    Hi, has anybody done this? Can PI read specific outlook emails based on a user Can PI read the Excel attachment (in outlook email) and convert to text file Can PI email the text file to SAP user Inbox (ECC) Thanks!

  • Message alert when Invoice date preceds Purchase order date

    Hi all, I want to define message alert, when Invoice date precedes Purchase order date. Is there any standard message type is there, If yes please let me know. Otherwise how can i define this, please. Thanks CS..

  • Visa Error in MAX for Compact RIO

    Hi, I have a compact rio I haven't used in a few months. In Labview 7.1 and since upgrading to 7.1.1, I can't connect to the compact rio. In MAX, I can see the crio device. When I open up the device, I get a VISA error under Devices and Interfaces .

  • Hide Active Query

    Hi All, We have installed Buyer business package on portal . In Transaction processing view currently the POWL view shows all the active queries given below:- 1. My Purchase Requisitions 2. Purchase Requisitions to be created 3. Purchase orders with

  • OAM 11g start up error - MicroSMImpl

    All, One of our clustered oam members is not starting up cleanly. Get the following exceptions, cleaned up tmp files and restarted several time with no luck. Has anyone seen this error before? Everything was working before for a long time and no chan