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 に答える