Re: perl dbi postgresql uppercase problem

From: "Arguile" <arguile(at)lucentstudios(dot)com>
To: "Marco Kienzle" <M(dot)Kienzle(at)marlab(dot)ac(dot)uk>, <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: perl dbi postgresql uppercase problem
Date: 2002-03-15 15:13:41
Message-ID: LLENKEMIODLDJNHBEFBOIEGLEGAA.arguile@lucentstudios.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Thomas Lockhart 2002-03-15 17:11:34 Re: ecpg weird behavior
Previous Message Marco Kienzle 2002-03-15 09:37:28 perl dbi postgresql uppercase problem