我希望能够支持此查询:
select first_name from
employees
where hire_date between x and y;
我创建了以下过程,没有错误。
CREATE OR REPLACE PROCEDURE pr_show_col_table(
col IN VARCHAR2,
tab IN VARCHAR2,
date_col IN VARCHAR2,
dt2 IN VARCHAR2,
dt1 IN VARCHAR2)
IS
--
type typ_ref_cur IS ref CURSOR;
cur typ_ref_cur;
type l_record IS record (first_name employees.first_name%type);
l_rec l_record;
BEGIN
--
OPEN cur FOR
' Select '|| col || ' from ' || tab || ' where ' || date_col ||
' Between TRUNC(:startdt) and TRUNC(:enddt) '
USING dt2, NVL(dt1,dt2+1);
--
LOOP
FETCH cur INTO l_rec;
EXIT WHEN cur%notfound;
dbms_output.put_line('Name is '|| l_rec.first_name);
END LOOP;
CLOSE cur;
--
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line
('Error at line '||dbms_utility.format_error_backtrace|| chr(10)
|| 'Error Message '||dbms_utility.format_error_STACK);
END pr_show_col_table;
/
但是当我尝试运行此程序时:
BEGIN
pr_show_col_table (
'first_name',
'employees',
'hire_date',
to_Date('30-DEC-1995','DD-MON-YYYY'),
TO_DATE('01-JAN-1995','DD-MON-YYYY'));
END;
我收到以下错误:
ORA-06512行的错误:“HR.PR_SHOW_COL_TABLE”,第13行
错误消息ORA-06502:PL / SQL:数字或值错误:字符到数字转换错误
我该如何解决这个问题?
答案 0 :(得分:1)
原因是您将日期值传递给varchar参数。将dt2,dt1参数的数据类型设置为class TestItem < ActiveRecord::Base
belongs_to :test
attr_accessor :main_text, :position, :kind
def wrapped_object
klass = kind.constantize
klass.new(_needed_params)
end
end
class TrueFalseQuestion # DO NOT INHERIT
attr_accessor :kind, :position
def print
...
end
end
而不是DATE