title: How to use FND_GLOBAL.USER_ID() in sql code for Oracle
body: <p>I wrote some code to extract data from HR tables for a letter to be produced out of Oracle. When I run this code it will prompt for 2 parameters.</p>
  <ol>
  <li>Attribute20 (DFF stored on the HR person record) which stores the a YEAR value (i.e. 2020)</li>
  <li>Review_date which I have set a to_Char on so that the same value gets populated as for the first parameter (i.e. 2020)</li>
  </ol>
  <p>When I run the code out of TOAD I initialize first by running:</p>
  <p>exec fnd_global.apps_initialize(1825, 50648, 800);</p>
  <p>This is the code I run the extract the required data:</p>
  <pre><code>          select          
            pp.person_id,
            fu.EMPLOYEE_ID,
            fu.user_id,          
            pp.EMPLOYEE_NUMBER,
            pp.title,
            pp. first_name,
            pp.middle_names,
            pp.last_name,   
            pp.full_name,  
            paaf.assignment_id, 
            paaf.ass_attribute10 business_unit,    
            dep.description department,
            pp.EMAIL_ADDRESS email,
            peef.ELEMENT_ENTRY_ID,
            peef.EFFECTIVE_START_DATE,
            peef.EFFECTIVE_END_DATE,
            peef.ASSIGNMENT_ID,
            peef.ELEMENT_LINK_ID,
            peef.ELEMENT_TYPE_ID,
            peef.ATTRIBUTE20 financial_year,       
            peef.DATE_EARNED,
            peevf.screen_entry_value bonus_amount,
            to_char(pprv.REVIEW_DATE, 'YYYY') perf_review_Date,
            pprv.RATING_MEANING individual_perf_score,
            pprv.ATTRIBUTE19 organization_perf_score                     
            from 
            per_all_people_f pp,
            fnd_user fu,
            per_all_assignments_f paaf,
            pay_Element_entries_f peef,
            pay_element_entry_Values_f peevf,
            PER_PERFORMANCE_REVIEWS_V pprv,
            gl_code_combinations gcc,
           (select flex_value, description
            from   FND_FLEX_VALUES_VL ffvv
            where  ffvv.flex_value_set_id =  1009629)dep 
            where 
             pp.PERSON_ID = paaf.PERSON_ID(+)   
        and  pp.PERSON_ID = pprv.PERSON_ID(+)
        and  pp.person_id(+) = fu.employee_id
        and  fu.USER_ID(+) = FND_GLOBAL.USER_ID()
        and  paaf.ASSIGNMENT_ID = peef.ASSIGNMENT_ID(+)
        and  peef.ELEMENT_ENTRY_ID = peevf.ELEMENT_ENTRY_ID(+)
        and  paaf.DEFAULT_CODE_COMB_ID = gcc.CODE_COMBINATION_ID
        and  gcc.SEGMENT3 = dep.flex_value     
        and  sysdate between paaf.EFFECTIVE_START_DATE and paaf.EFFECTIVE_END_DATE
        and  sysdate between pp.EFFECTIVE_START_DATE and pp.EFFECTIVE_END_DATE     
        --and  peef.EFFECTIVE_START_DATE and peef.EFFECTIVE_END_DATE
        and  peef.element_link_id in (7064, 7172, 7183, 8103)  ---performance bonus element entry 
        and  peef.ATTRIBUTE20 = :p_fin_year --financial year     --
        and  to_char(pprv.REVIEW_DATE, 'YYYY') = :p_fin_year  --performance review date --
        order by pp.last_name;
  </code></pre>
  <p>The data extracted is correct.</p>
  <p>The code I have populated into Oracle Reports and I have registered both the execution and the concurrent program which points to this oracle report. This report I have defined with two parameters:</p>
  <ol>
  <li>User id which links to a value set with a default type of profile on USER_ID. So basically what this allows for is when a user logs on the system is automatically initialized for user_id, responsibility_id and application_id. So in this case if I log on my user_id (being the FND_GLOBAL.USER_ID()) will pull though and default in as the user id for this report. The correct value is pulling through.</li>
  <li>Financial year which ties back to the code's p_fin_year for user to enter the financial year (i.e. 2020)</li>
  </ol>
  <p>I am at a loss as to why when the report is run out of Oracle it returns no data but the same code does extract data out of Toad??</p>
  <p>Any assistance would be most appreciated.</p>
  <p>Thanks</p>