Re: DBD::Oracle 1.80 & Oracle client 19c Segfaults on Destroy

2020-06-23 Thread Peter Vanroose
Actually, I did exactly this a few years ago.
Only problem: NULLs show up as blanks ...
Apart from that, it works like a charm!

-- Peter Vanroose.

Op 23 jun. 2020 22:10, om 22:10, "Fennell, Brian"  schreef:
>Another idea . . .
>
>You could also wrap Oracle SQLPlus in perl using qx
>
>How-to SQLPLUS and XML here:
>
>https://asktom.oracle.com/pls/apex/f?p=100:11:0P11_QUESTION_ID:3512822500346787661
>
>That and a little perl text parsing could get you a long way - split ,
>grep, map, s and tr.
>
>This pure-perl module can parse the XML:
>https://metacpan.org/pod/XML::SAX::PurePerl
>
>It would be great to have an Oracle DBD driver using pure-perl and
>sqlplus only.   No C complier needed, no buffer overflows to chase
>down, no jvm and no "other" languages (except SQL).
>
>(no time for this kind of perl-uber-hacking myself but anyone looking
>for a fun project . . . )
>
>Another hack is to use perl with qx with jisql (and JDBC drivers) - I
>have used this to access Microsoft SQLServer from perl with little
>work.
>
>https://github.com/stdunbar/jisql
>
>Brian Fennell
>
>
>
>
>The information contained in this electronic mail transmission is
>intended only for the use of the individual or entity named in this
>transmission. If you are not the intended recipient of this
>transmission, you are hereby notified that any disclosure, copying or
>distribution of the contents of this transmission is strictly
>prohibited and that you should delete the contents of this transmission
>from your system immediately. Any comments or statements contained in
>this transmission do not necessarily reflect the views or position of
>Radial or its subsidiaries and/or affiliates.


Re: Translate between DBI and SQL

2019-02-12 Thread Peter Vanroose
Short answer, assuming you are including hard-coded SQL into a Perl script:
Place the textual SQL, without any additional backslashes or extra quotes or 
whatsoever,
within the following:

my $sql_text = q(

);

Unless you have a closing ")" without a preceding opening "(" in that SQL text
(which would normally be invalid SQL)
the above should be valid Perl, resulting in a valid SQL statement in $sql_text
(to be passed to a DBI prepare or so).

In the unlikely event that you would have unbalanced quoted parentheses in your 
SQL,
you can replace the delimiters for the q operator by something else, viz. 
something not occurring in your SQL text, e.g.:

my $sql_text = q#
SELECT ')', "col_a"
FROM tblc
ORDER BY "col_a"
#;


-- Peter.


8 februari 2019 23:37:17 +01:00, skrev 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
>
>



Re: Generic way of fetching a list of databases

2018-11-17 Thread Peter Vanroose
IMHO, listing databases is not well-defined in a cross-RDBMS context, since the 
definition of database largely differs between RDBMS products. As an example, 
"database" even has different definitions between Db2 for Linux/Unix/Windows on 
the one hand, and Db2 for z/OS on the other hand!

What should be well-defined, and maybe that's what you want, is listing schema 
names. For some RDBMS (e.g. MySQL) schemas coincode with databases. On most 
platforms they coincode with users.
But the definition of a schema is clear: it's the (explicit) table prefix 
(dot-separated) you need to specify when referring tables in an other than your 
default schema.
As some answers were suggesting, just look at the list of tables 
(information_schema.tables or the like) and return the distinct values from the 
column called schema (or user or creator or the like).

Your example with PostgreSQL seems to suggest that your definition of database 
is the "connection entity"; but listing all "connection entities" is 
intrinsically impossible since you first need to connect (to a database) before 
you can start asking it for the objects it knows, and by definition it only 
knows about itself ...

-- Peter Vanroose,
ABIS Training & Consulting,
Leuven, Belgium.


On 16 november 2018 03:09 Daniel Kasak <> wrote:

> [... ]
> I've done quite a bit of search, but can't find any docs that mention 
> fetching *databases* - either in ODBC docs or in Perl/DBI docs. The closest 
> I've found that *might* have worked was DBI's tables() method:
> <https://metacpan.org/pod/DBI#tables>
> 
> ... but:
> - this doesn't work in cases where there is a separation between hierarchies 
> at the database level ( eg postgres only lists schemas and tables in the 
> current database )
>



Re: Wierd issue with printf and DBD::Pg

2018-10-01 Thread Peter Vanroose
Use sprintf instead of printf.

-- Peter Vanroose.


On 1 october 2018 12:13 Mike Martin <> wrote:

> 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
> 
>
>