Adobe Dreamweaver Forums



Last 10 THreads :         Attach file in dynamic web template (Last Post : Murray *ACE* - Replies : 3 - Views : 4 )           »          Counting in Hex (Last Post : Andrei1 - Replies : 2 - Views : 3 )           »          Trouble with SQL Query Tool on Leopard (Last Post : Daverms - Replies : 1 - Views : 2 )           »          How do I open te files in older versions of Director? (Last Post : Mike Blaustein - Replies : 1 - Views : 2 )           »          Exporting csv or xmal from database (Last Post : Andy - Replies : 0 - Views : 1 )           »          Change html page image by the month (Last Post : Michael White - Replies : 10 - Views : 11 )           »          Beginner help - PUT confusion (Last Post : anynick32 - Replies : 6 - Views : 7 )           »          Flash Player 10 Crash (Last Post : saurabhgsl - Replies : 0 - Views : 1 )           »          Re: LingoWorkshop slider menu (Last Post : openspark - Replies : 0 - Views : 1 )           »          Capture full URL with CF CGI variable (Last Post : Azadi - Replies : 2 - Views : 3 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Cold Fusion > Database Access
 
Tags:



Reply
  #1 (permalink)  
Old 10-10-2008, 03:03 PM
anglisa
 
Posts: n/a
Diggs:
Default Calling Oracle stored procedure

The following codes executed correctly when it was run in sqlplus.

DECLARE
P_COM_ID VARCHAR2(30);
P_STATION VARCHAR2(30);
P_TYPE VARCHAR2(99);
P_YEAR NUMBER;
P_MONTH NUMBER;
P_DAY NUMBER;
P_HOUR NUMBER;
P_MINUTE NUMBER;
P_RECEIVED DATE;

BEGIN
P_COM_ID := 'XOX';
P_STATION := '4064149';
P_TYPE := 'SA';
P_YEAR := 2006;
P_MONTH := 1;
P_DAY := 2;
P_HOUR := 0;
P_MINUTE := 0;
P_RECEIVED := to_date('2006-01-02 08:01:10','yyyy-mm-dd hh:mi:ss') ;

INGEST.REINSERT_OLD_HLY_INGEST_ROW ( P_COM_ID, P_STATION, P_TYPE, P_YEAR,
P_MONTH, P_DAY, P_HOUR, P_MINUTE, P_RECEIVED );
COMMIT;
END;

However, when I called the procedure in coldfusion mx7, nothing seemed to
happen.
The coldfusion codes are:

<cffunction name="f_reinsertOldHlyIngest" display="f_reinsertOldHlyIngest"
access="public" returntype="string" output="false">
<cfargument name="raw_com_id" required="true" type="string">
<cfargument name="raw_station" required="true" type="string">
<cfargument name="raw_struct_type" required="true" type="string">
<cfargument name="raw_Year" required="true" type="numeric">
<cfargument name="raw_Month" required="true" type="numeric">
<cfargument name="raw_Day" required="true" type="numeric">
<cfargument name="raw_Hour" required="true" type="numeric">
<cfargument name="raw_minute" required="true" type="numeric">
<cfargument name="date_time_received" required="true" type="date">

<!--- Catch any data base error that might occure --->
<!--- Declare a bunch of variables when needed --->
<!--- Catch any data base error that might occure --->
<!--- change arguments.date_time_received to string --->
<cfset date_time_received = "to_date('" & arguments.date_time_received &
"','yyyy-mm-dd hh:mi:ss')">
<cftry>

<cfset DB_ERROR_MSG="">

<!--- SQL/PL statement that inserts a name record is called --->
<cfstoredproc procedure="INGEST.reinsert_old_hly_ingest_row"
datasource="#this.datasource#"
username="#this.username#" password="#this.password#" returncode="no">
<cfprocparam type="in" cfsqltype="cf_sql_varchar" maxlength="30"
value="#arguments.raw_com_id#" null="yes">
<cfprocparam type="in" cfsqltype="cf_sql_varchar" maxlength="30"
value="#arguments.raw_station#" null="no">
<cfprocparam type="in" cfsqltype="cf_sql_varchar" maxlength="9"
value="#arguments.raw_struct_type#" null="no">
<cfprocparam type="in" cfsqltype="cf_sql_numeric"
value="#arguments.raw_year#" null="no">
<cfprocparam type="in" cfsqltype="cf_sql_numeric"
value="#arguments.raw_month#" null="no">
<cfprocparam type="in" cfsqltype="cf_sql_numeric"
value="#arguments.raw_day#" null="no">
<cfprocparam type="in" cfsqltype="cf_sql_numeric"
value="#arguments.raw_hour#" null="no">
<cfprocparam type="in" cfsqltype="cf_sql_numeric"
value="#arguments.raw_minute#" null="no">
<cfprocparam type="In" cfsqltype="CF_SQL_VARCHAR"
value="#preservesinglequotes(date_time_received)#" null="no">
<!--- <cfprocparam type="In" cfsqltype="CF_SQL_DATE"
value="#CreateODBCDateTime(arguments.date_time_rec eived)#" null="no"> --->
</cfstoredproc>

<cfcatch type="DATABASE">
<cfset DB_ERROR_MSG = "#CFCATCH.DETAIL#">

</cfcatch>

</cftry>
<cfif DB_ERROR_MSG neq "">

<cfset BD_ERROR_MSG = "Update to the database failed!">


<cfelse>

</cfif>
<cfreturn DB_ERROR_MSG>
</cffunction>

Any help would be much appreciated. Thanks.




Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-10-2008, 06:13 PM
paross1
 
Posts: n/a
Diggs:
Default Re: Calling Oracle stored procedure

Try using cfsqltype="CF_SQL_TIMESTAMP" for your P_RECEIVED DATE parameter, and
you may want to avoid using CreateODBCDateTime() to create your "date" unless
you are actually using an ODBC connection to Oracle. Perhaps CreateDateTime().

Also, your "procedure" looks more like an anonymous block that you would call
directly in SQL Plus, rather than a stored PL/SQL procedure, which would be
created with a CREATE OR REPLACE PROCEDURE statement... or even within a CREATE
OR REPLACE PACKAGE. I suppose what I am trying to say is, how are you executing
an anonymous block from within ColdFusion?

Phil

Reply With Quote
  #3 (permalink)  
Old 10-10-2008, 07:14 PM
anglisa
 
Posts: n/a
Diggs:
Default Re: Calling Oracle stored procedure

Thanks Phil,

The stored procedure can be called in sqlplus with appropriate logon.

In coldfusion, the stored procedure is called by a cfc function. The values of
all the parameters are passed into the stored procedure via coldfusion function
arguments. The value of date comes into the function is

'2006-01-02 08:01:10'.

Since the stored procedure use the date_time_received in the where clause

where date_time_received = p_date_time

I change the value of date to contain to_date before using the value.

<cfset date_time_received = "to_date('" & arguments.date_time_received &
"','yyyy-mm-dd hh:mi:ss')">

Coldfusion gave me an error when it saw the to_date when cf_sql_type equal
cf_sql_timestamp was used.


Reply With Quote


  #4 (permalink)  
Old 10-10-2008, 08:29 PM
paross1
 
Posts: n/a
Diggs:
Default Re: Calling Oracle stored procedure

OK, I see what you did in SQL*Plus. All that yoi did to test it there was to
enclosed your stored procedure call within an anonymous block so that you could
set the proc parameters, execute the proc, commit the changes, then quit. It
might be interesting to see what your actual PL/SQL looks like.

This
<cfset date_time_received = "to_date('" & arguments.date_time_received &
"','yyyy-mm-dd hh:mi:ss')">

makes no sense.

to_date is an Oracle function, not a ColdFusion one, so how can you
possibly be setting a CF variable to that value? Even if you pass this "string"
to your procedure, how do you "execute" the string within your PL/SQL without
using dynamic SQL, especially since P_RECEIVED is probabl still a date datatype.

You should set date_time_received to an actual date/time object instead of a
string, then you should be able to use a cfsqltype of CF_SQL_TIMESTAMP.

Reply With Quote
  #5 (permalink)  
Old 10-27-2008, 04:34 PM
anglisa
 
Posts: n/a
Diggs:
Default Re: Calling Oracle stored procedure

Thanks Phil,

We coded to_date('" & arguments.date_time_received & "','yyyy-mm-dd
hh:mi:ss')" in the pl/sql procedure and simply passed the date_time_received in
CF_SQL_TIMESTAMP format and the problem is solved. Thanks.

Lisa

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 12:32 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk