Re: perl dbi postgresql uppercase problem - Mailing list pgsql-interfaces

From Arguile
Subject Re: perl dbi postgresql uppercase problem
Date
Msg-id LLENKEMIODLDJNHBEFBOIEGLEGAA.arguile@lucentstudios.com
Whole thread Raw
In response to perl dbi postgresql uppercase problem  (Marco Kienzle <M.Kienzle@marlab.ac.uk>)
List pgsql-interfaces
Marco Kienzle wrote:
>
> 1.    first, is it possible to store the query in a file and invoke its
> execution from perl (\i file.sql command from     Postgresql) ?

Just slurp in the textfile and $dbh->do() it.

> 2.    second, I want to use PERL variables in an SQL query (for example
> $var='R') but if I use them in the query, the Postgresql server return the
> following error: Attribute 'r' not found ...  I did not ask for 'r'
> attribute but for 'R'. Does any one know how to resolve this
> uppercase/lowercase problem ?

You're encountering case folding. PostgreSQL lower()s all non-quoted
attributes.
SELECT  FOO  FROM table;SELECT  Foo  FROM table;SELECT  foo  FROM table;SELECT "foo" FROM table;

These all use attribute "foo".
SELECT "Foo" FROM table;

This uses attribute "Foo".

Search the archives if you'd like to know standard ways people handle this
and the rational behind it. For using variables in the value side of any
query look up placeholders if you're not already familiar with them.




pgsql-interfaces by date:

Previous
From: Marco Kienzle
Date:
Subject: perl dbi postgresql uppercase problem
Next
From: "Jeroen T. Vermeulen"
Date:
Subject: libpqxx milestone