0

在 asp 中将 oracle 日期提供给 oracle 函数时,我在 Classic ASP 中遇到错误。我的代码:

dim startDate, endDate
startDate = rs1.fields("oraDate1") 'field is oracle field. Gets with oracle to_char('30.10.203','dd/mm/yyyy')
endDate = rs1.fields("oraDate2") 'oraDate2 is like oraDate1

if IsDate(startDate) Then
Set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = conn
cmd.CommandText = "find_business_day" 'oracle function
cmd.CommandType = 4
dim date1, date2
set date1 = cmd.CreateParameter("start_date",135,1)
cmd.Parameters.Append date1
date1.value = startDate 
set date2 = cmd.CreateParameter("end_Date", 135, 1)
cmd.Parameters.Append date2
date2.value = endDate 
cmd.Execute

报错就cmd.Execute行了,报错信息是:

 Microsoft OLE DB Provider for ODBC Drivers hata '80004005' 

 [Microsoft][ODBC driver for Oracle]Invalid parameter type

我的预言机功能:

 CREATE OR REPLACE FUNCTION find_business_day (my_trh1 date,my_trh2 date) return number is
my_isgunu number(2);
begin
select count(*)  into my_isgunu from takvim where tatil=1 and tarih between my_trh1 and  my_trh2;
Return(my_isgunu);
exception
When others then return(0); 
end find_business_day;
/
4

1 回答 1

0

我通过更改 oracle 函数参数类型解决了这个问题。这是我的解决方案:

dim startDate, endDate
        startDate = rs1.fields("mail_gon_trh")
        endDate = rs1.fields("olur_trh")
if IsDate(startDate) 
Set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = conn
cmd.CommandText = "find_business_day"
cmd.CommandType = 4

set returnval = cmd.CreateParameter("my_isgunu",131,4,100)
cmd.Parameters.Append returnval

set date1 = cmd.CreateParameter("my_trh1",201,1,100)
cmd.Parameters.Append date1
cmd.parameters(1).value = startDate
set date2 = cmd.CreateParameter("my_trh2", 201, 1,100)
cmd.Parameters.Append date2
cmd.parameters(2).value = endDate
cmd.Execute
result = cmd.Parameters(0)
end if

我的预言机功能:

  CREATE OR REPLACE FUNCTION TUBORTAK.ISGUNU_BUL_TRH2 (my_trh1 varchar,my_trh2 varchar)    return number is
my_isgunu number(3);
my_trh1_date date;
my_trh2_date date;
begin
my_trh1_date:=to_date(my_trh1,'dd/mm/yyyy');
my_trh2_date:=to_date(my_trh2,'dd/mm/yyyy');
select count(*)  into my_isgunu from takvim where tatil=1 and tarih between my_trh1_date and my_trh2_date;
Return(my_isgunu);
exception
When others then return(0); 
end ISGUNU_BUL_TRH2;
/
于 2013-11-01T12:36:04.910 回答