Skip to main content
Participating Frequently
May 9, 2006
Question

Stored Procedures with Date data types and Oracle

  • May 9, 2006
  • 2 replies
  • 7212 views
This should be easy.... But i keep getting the error:

[Macromedia][Oracle JDBC Driver][Oracle]ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'RETRIEVE_TS' ORA-06550: line 1, column 7: PL/SQL: Statement ignored

And I got it worked out to where i know it is a problem with the way i am using the date data types in a stored procedure....

In the past i usually avoided calling procedures in Oracle with date as the in type.... It is always easiest to let oracle convert the string to a date.... Unfortunately now i am stuck with having a date type in the procedure call.... So the question is:

WHAT IS THE PROPER WAY TO SUBMIT DATE/TIME STAMP IN A STORED PROCEDURE?

The Oracle Procedure looks like this:

PROCEDURE retrieve_ts (
p_at_tsv_rc IN OUT sys_refcursor,
p_units IN OUT VARCHAR2,
p_officeid IN VARCHAR2,
p_timeseries_desc IN VARCHAR2,
p_start_time IN DATE,
p_end_time IN DATE,
p_timezone IN VARCHAR2 DEFAULT 'GMT',
p_trim IN NUMBER DEFAULT false_num,
p_inclusive IN NUMBER DEFAULT NULL,
p_versiondate IN DATE DEFAULT NULL,
p_max_version IN NUMBER DEFAULT true_num
)

AND the stored procedure call looks like this:

<cfset ed = Now()>
<cfset sd = #DateAdd("d",-lbt,Now())#>

<cfstoredproc datasource="CWMS"
procedure="cwms.cwms_ts.retrieve_ts"
returncode="no">
<cfprocparam type="inout" variable="unit" value="#unit#"
dbvarname="@p_units"
cfsqltype="cf_sql_varchar">

<cfprocparam type="in" value="MVS"
dbvarname="@p_officeid"
cfsqltype="cf_sql_varchar">

<cfprocparam type="in" value=#id.cwms_ts_id#
dbvarname="@p_timeseries_desc"
cfsqltype="cf_sql_varchar">

<cfprocparam type="in" value="#sd#"
dbvarname="@p_start_time"
cfsqltype="cf_sql_date">

<cfprocparam type="in" value="#ed#"
dbvarname="@p_end_time"
cfsqltype="cf_sql_date">

<cfprocparam type="in" value="#tz#"
dbvarname="@p_time_zone"
cfsqltype="cf_sql_varchar">

<cfprocparam type="in" value="0"
dbvarname="@p_trim"
cfsqltype="cf_sql_numeric">

<cfprocparam type="in" value=""
null = "yes"
dbvarname="@p_inclusive"
cfsqltype="cf_sql_numeric">

<cfprocparam type="in" value=""
null="yes"
dbvarname="@p_versiondate"
cfsqltype="cf_sql_date">

<cfprocparam type="in" value="1"
dbvarname="@p_max_version"
cfsqltype="cf_sql_numeric">

<cfprocresult name="ts_dat">

</cfstoredproc>


Text
This topic has been closed for replies.

2 replies

Participating Frequently
May 9, 2006
Hmmm, try moving p_at_tsv_rc IN OUT sys_refcursor to being the last parameter in your stored procedure declaration (don't forget to move it in the package spec as well as in the body!) Plus, if you are using ThinClient JDBC drivers for your Oracle datasource, you can NOT use ref cursors to return result sets.

Here are two posts that I found regarding the date/timestamp issue.

CFMX and Oracle 10G JDBC no longer retrieves timestamp with date
Oracle Date/Timestamp issue

Phil
jasun123Author
Participating Frequently
May 10, 2006
I will try moving the refference cursor to the end, but am afraid that isn't going to work either.... Let me try to clarify why i know it is a date datatype problem....

What i did was right a similar pl/sql procedure that accepts all the same variable types as the package cwms_ts.retrieve_ts with one exception.... I send the start and endtimes as varchar to the stored procedure and convert them to dates inside Oracle.... It worked fine....

Hence it is something with sending dates through the stored procedure....

I think the links you show is the right direction to try.....

Participating Frequently
May 9, 2006
First of all, you can get rid of the dbvarname parameters, as they have been deprecated in MX and serves absolutely no purpose. You must still match up each cfprocparam with its stored procedure parameter in number, type, and order.

the dbvarname attribute behavior:...is now ignored for all drivers. ColdFusion MX uses JDBC 2.2 and does not support named parameters.

What version of Oracle are you on? There have been some issues with recent versions of Oracle and date/time verses timestamp data types (10g for sure, later 9i as well), but assuming that this isn't the case, try using cfsqltype="CF_SQL_TIMESTAMP" instead of CF_SQL_DATE for Oracle date/time data types.

Phil
jasun123Author
Participating Frequently
May 9, 2006
Phil -

We are running Oracle 9.2.0.6.....

Tried timestamp... same error....