in reply to Class::DBI Oracle Dates

I haven't tried to set dates with Class::DBI yet, but I will be working that issue shortly on my current project. I've already run into some Oracle specific problems, where I needed to write some custom SQL, so don't be surprized at this. (The custom SQL was for "paging").

In a prior project I used DBI by itself. I ended up writing a single routine to handle writing any generalized data into my tables. Part of the routine handling oracle SQL generation for dates looked like this:

# Note that date data must consist of a date encased in # single quotes followed by a comma, then a date # format string encased in single quotes. For example: # '2002-05-30','YYYY-MM-DD' # or '05/30/2000:18:31','MM/DD/YYYY:HH:MM' foreach $name ( keys (%$r_datedata) ) { $column_str .= $name . ", "; if ( $$r_datedata{$name} eq "SYSDATE" ) { $value_str .= "SYSDATE, "; } else { $value_str .= "to_date(" . $$r_datedata{$name} . "), "; } }
I imagine you'll need to do something similar.

-------------------------------------
Nothing is too wonderful to be true
-- Michael Faraday

Replies are listed 'Best First'.
Re: Re: Class::DBI Oracle Dates
by set_uk (Pilgrim) on Oct 28, 2003 at 22:56 UTC
    Got it working with Class DBI - had to revert to Ima::DBI set_sql in the dbi subclass against the table. Code in the subclass
    SDU::DBI_AJ->set_sql('InsertInfoAJ', 'INSERT into sdu_active_jobs(jobid,job_name,target_device,customer, + start_date,status) VALUES (?,?,?,?,SYSDATE,?)','Main');
    Code in the calling class:-
    $create_job = SDU::DBI_AJ->sql_InsertInfoAJ; $rv = $create_job->execute($cr{jobid}, $cr{job_name}, $cr{target_device}, $cr{customer}, $cr{status});
    This seems too complex - for just wanting to use sysdate.