Thank you Corion for pointing me in the right direction. I have finally solved the problem which was a combination of lack of PostgreSQL ODBC driver and improper format of connection string.

Solution

Remark: I recommend using DBD::ODBC to connect to PostgreSQL on Windows instead of DBD::PgPP (unmaintained and full of bugs, written in Pure Perl) or DBD::Pg (no Windows version on ppm & latest update on http://pgfoundry.org/frs/?group_id=1000199&release_id=1212 is for Perl 5.10 made in late 2008).
1. Install latest version of DBI & DBD-ODBC using ppm.
2. Download & install appropriate psqlodbc driver from http://www.postgresql.org/ftp/odbc/versions/msi/ (don't forget to upgrade using the batch file).
3. Go to Control Panel -> Administrative Tools. Choose Data Sources shortcut. In the ODBC Data Source Administrator dialog box, click Add, then select the driver (e.g.: PostgreSQL Unicode) you want from the Installed ODBC Drivers list and choose OK.
4. Use the appropriate connection string (http://connectionstrings.com/postgre-sql#p51), e.g.:

my $dbh = DBI->connect("dbi:ODBC:driver={PostgreSQL Unicode};Server=12 +7.0.0.1;Port=5432;Database=database;Uid=username;Pwd=password;", user +name, password, {PrintError => 1, RaiseError => 1}) || die "Error $DB +I::err [$DBI::errstr]";
5. Using telepathy, thank the person who compiled this little manual for you so that you don't have to go through the cycle of frustration, disillusionment and apathy.


In reply to Re: Cannot connect Perl to PostgreSQL using ODBC (SQL-IM002) by lr3p
in thread Cannot connect Perl to PostgreSQL using ODBC (SQL-IM002) by lr3p

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.