简体   繁体   English

在托管变量中使用提示?

[英]using Hint in a hosted variable?

All, 所有,

I want to use a hint in a hosted variable; 我想在托管变量中使用提示; in fact, we need to use a dynamic value of the hint (Hint should be valued at runtime). 实际上,我们需要使用提示的动态值(提示应在运行时赋值)。 can we write an sql statement from this: 我们可以从中编写一条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 

to : 至 :

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 

hosted_hintp contain the value of hint we need at runtime. hosted_hintp包含我们在运行时所需的提示值。

thanks 谢谢

Your query must be executed using dynamic SQL. 您的查询必须使用动态SQL执行。 Something like this: 像这样:

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;
/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM