1

全部,

我想在托管变量中使用提示;实际上,我们需要使用一个动态的提示值(Hint 应该在运行时被赋值)。我们可以从这里写一个 sql 语句:

SELECT /*+ ORDERED INDEX (b, jl_br_balances_n1) USE_NL (j b) 
           USE_NL (glcc glf) USE_MERGE (gp gsb) */
 b.application_id ,
 b.set_of_books_id ,
 b.personnel_id,
 p.vendor_id Personnel,
 p.segment1 PersonnelNumber,
 p.vendor_name Name
FROM  jl_br_journals j,
      jl_br_balances b,
      gl_code_combinations glcc,
      fnd_flex_values_vl glf,
      gl_periods gp,
      gl_sets_of_books gsb,
      po_vendors p
WHERE 

至 :

SELECT /*+ :hosted_hintp */
 b.application_id ,
 b.set_of_books_id ,
 b.personnel_id,
 p.vendor_id Personnel,
 p.segment1 PersonnelNumber,
 p.vendor_name Name
FROM  jl_br_journals j,
      jl_br_balances b,
      gl_code_combinations glcc,
      fnd_flex_values_vl glf,
      gl_periods gp,
      gl_sets_of_books gsb,
      po_vendors p
WHERE 

hosts_hintp 包含我们在运行时需要的提示值。

谢谢

4

1 回答 1

1

您的查询必须使用动态 SQL 执行。像这样的东西:

CREATE OR REPLACE PROCEDURE query_emp (a_hint VARCHAR2)
AS
    TYPE cur_typ IS REF CURSOR; c cur_typ;
BEGIN
    OPEN c FOR 'SELECT ' || a_hint || ' empno, ename, sal, job
                FROM emp WHERE empno = 7566';

    -- process
END;
/
于 2015-05-27T01:56:22.180 回答