select distinct "TEMP_EMP_ATTRIB"."EMP_ID"
  from "RS_EMP_NATURE_ATTRIB", "RS_DEPT", 
       /*01需要做工资的所有人*/
       ( select a_year_month, a1.* /*0101--新入员工*/
         from rs_emp_nature_attrib a1 
         where emp_id not in ( select EMP_ID from rs_history_emp_nature_attrib where year_month = a_year_month )
          
我想问的是,我怎么定义这段代码中的参数a_year_month 并给个初值  ,就可以执行 以上的代码,其中还有个是日期类型的参数,我不会语法,请给个示例
我的目的是想看一下这段代码的执行结果,是想调试

解决方案 »

  1.   


    create or replace function ...
    a_year_month number(6); --定义
    begin
    a_year_month := 201101  --赋值
    select year_month, a1.* /*0101--新入员工*/
      from rs_emp_nature_attrib a1 
      where emp_id not in ( select EMP_ID from rs_history_ emp_nature_attrib where year_month= || to_char(a_year_month) )
      

  2.   


    --日期类型的话,看你传递进来的是什么了
    --用to_date(日期参数)转换后,就可以使用了
      

  3.   


    vsql   varchar2(200);
    begin
    vsql := 你的一大段sql文;
    --如果要看结果的话,你可以使用游标的方式
    Cursor testCursor Is vsql;  --定义游标
    row_Cursor   testCursor%ROWTYPE;--定义行--然后用fetch循环游标
    Fetch testCursor Into row_Cursor;
    EXIT WHEN testCursor%NOTFOUND;
    begin
    ...
    exception
    ...
    end loop;
    close testCursor;--或者,如果你的sql只是查处一条数据的话,你可以用‘into 变量’的方式来得到sql的值
    select  col1... into val12... from ....