I have been trying to use the following code to update a Sybase table with a TIMESTAMP
column. I first tried not putting the date_stamp column in the insert and the ODBC
driver gave a error. Next, I tried to put the date_stamp TIMESTAMP column in the
query with a valid timestamp in it and the ODBC driver complained with the following
error:
DBD::ODBC::st execute failed: [Sybase][ODBC Driver][Adaptive Server
Anywhere]Restricted data type attribute violation: Cannot convert to a timestamp
(SQL-07006)(DBD: st_execute/SQLExecute err=-1) at Wright_Tools_Object.pm line 170.
What am I doing wrong? I have tried using {ts '$date'} (to signify a time stamp)
instead of '$date' and various other things.
Best Regards,
Mike Lambert
my ($second,$minute,$hour,$dayofmonth,$month,$year,$weekDay,$dayofyear, $isdst) =
localtime(time);
$month++;
$year = $year + 1900;
if ($year < 10) {
$year = "0$year";
}
if ($month < 10) {
$month = "0$month";
}
if ($dayofmonth < 10) {
$dayofmonth = "0$dayofmonth";
}
if ($hour < 10) {
$hour = "0$hour";
}
if ($minute < 10) {
$minute = "0$minute";
}
if ($second < 10) {
$second = "0$second";
}
#'YYYY-MM-DD HH:MM:SS.ssssss'
my $date = "$year-$month-$dayofmonth $hour:$minute:$second.000000";
$database = $self->{wt_db};
$wt_dbh = DBI->connect("dbi:ODBC:$database", $self->{wt_user}, $self->{wt_password})
or return 0;
$wt_dbh->{AutoCommit} = 0;
$sql_query = "INSERT INTO account
(account_number,account_parent,account_name,terms_days1,terms_pct1,terms_days2,terms_pct2,terms_days3,terms_pct3,terms_days4,terms_pct4,terms_days5,terms_pct5,net_days,incentive_days1,incentive_pct1,incentive_days2,incentive_pct2,incentive_days3,incentive_pct3,incentive_days4,incentive_pct4,credit_limit,credit_available,credit_limit_approved_by,date_credit_limit,date_last_pmt,conditions,partial_shipment,shipment_method,fob_point,freight_code,freight_charge,contact_sale_name,contact_sale_title,contact_sale_phone,contact_sale_fax,contact_acct_name,contact_acct_title,contact_acct_phone,contact_acct_fax,process_flag,date_stamp,discount,ext_acctid1,ext_acctid2,user1,user2,user3,user4,user5,user6,user7,user8,credit_outstanding,credit_status,user_name,crossref_part,updated,phone,fax,email,acctgrp_id,note_internal,note_external,account_type,pricebook_file,pricebook_name,costbook_file,costbook_name)
VALUES
('$cust_num','','$cust_name',0,0,0,0,0,0,0,0,0,0,30,0,0,0,0,0,0,0,0,0,0,'','','','','N','','','','','','','','','','','','','','$date',0,'','','','','','','','','','',0,'','','N','N','$phone_number','$fax_number','',0,'','','BU','10','$price_book','','')";
$wt_v_qry = $wt_dbh->prepare($sql_query) or print "Could Not Run Wright Tools SQL:
$sql_query\n";
$wt_v_qry->execute;
Michael S. Lambert
System Administrator
Beta LaserMike Inc.
Phone: 937-233-9936 ext. 180
Fax: 937-233-7284