Memory not being freed with DBD::ODBC

2015-04-20 Thread Mike Martin
I have the following script (extremley simplified)

foreach my $key (sort {$a=$b} keys %run){
my $inp;
$inp=$dbh-selectall_arrayref(select id, [description] from
Kaonix_import_base where idint between ? and ? ,undef,$run{$key}-[0],
$run{$key}-[1]) ;


addrec($inp); -- sub to run very heavy regexs against the select and insert
into another table
undef($inp);

}

The problem is that memory is not being freed against the statement handle
on each iteration and eventually the script stalls due lack of memories

any ideas?


Issue with DBD::ODBC (SQLServer) and bcp

2015-05-18 Thread Mike Martin
Hi

Is it a known issue with running bcp while an active db connection

I have a script that basically

opens a db connection
selects some data
parses/transforms the data
writes to a text file
--
runs bcp to import the data into same database
--
does some updates in SQLServer

The issue is that if I dont disconnect before running bcp, the op just
hangs (with no output).

If I disconnect before bcp and then reconnect everything is fine. Is
this a known issue

Platform Windows 7
SQLServer 2012
DBD::ODBC=1.609


Wierd issue with printf and DBD::Pg

2018-10-01 Thread Mike Martin
HI
If I use printf to round a numeric value before inserting into postgres
table it is altered to 1 rather than the value when it is put into a table

example
CREATE TABLE public.chksize
(
size numeric(10,2), #does not matter what field type
path1 character varying COLLATE pg_catalog."default"
)

this creates a value of 1 for every value

my $ins=$dbh->prepare("INSERT into chksize (size,path1) VALUES (?,?) ");
open my $list ,'chksizer.txt';
no strict 'refs';
my @list=(<$list>);
foreach my $k (@list){
chomp $k;
my ($size,$path)=split /,/,$k;
my $size1=printf('%.1f',$size/(1024*1024));
$ins->bind_param(1,$size1);
$ins->bind_param(2,$path);
$ins->execute;
}

without printf this inserts proper value

my $ins=$dbh->prepare("INSERT into chksize (size,path1) VALUES (?,?) ");
open my $list ,'chksizer.txt';
no strict 'refs';
my @list=(<$list>);
foreach my $k (@list){
chomp $k;
my ($size,$path)=split /,/,$k;
my $size1=$size/(1024*1024);
$ins->bind_param(1,$size1);
$ins->bind_param(2,$path);
$ins->execute;
}

Any ideas what is happening here?

thanks

Mike


Translate between DBI and SQL

2019-02-08 Thread Mike Martin
Has anyone done any work on converting SQL queries between RDBMS and perl?

My particular interest is DBD::Pg but anything would be of use

It would be very useful when I am testing complex SQL, it's very easy to
miss a \ or quote between the two

Thanks
Mike