FAQ
Hello
If you use Perl (like me) I have made a very nice set of small programs to access any database, any table and add, change or delete data.
I like it better than using Webmin or PgAdmin because I can easily customize the screens.

To get all database names and encoding:
my $dbh = DBI->connect("dbi:Pg:dbname=template1", "postgres", "postgres");
my $select = $dbh->selectall_arrayref("select datname,encoding from pg_database ORDER BY datname ") or die $DBI::errstr;

To get all tables in a base:
my $dbh = DBI->connect("dbi:Pg:dbname=$base", "postgres", "postgres");
my @tnames = $dbh->tables('');

To get the field names in a table (nice for updates):
my @header = @{$sth->{'NAME'}};
my @types = @{$sth->{'TYPE'}};

Hope somebody can use them

Search Discussions

  • Selvakaruppiah s-TLS,Chennai at Aug 5, 2008 at 2:54 am
    Hi all,

    I am using Postgres 8.1.4 version (Windows native) server and
    PSQLODBC.dll version 7.3.2.0.

    It seems SetQueryTimeOut is not implemented in Postgres 8.1.4.

    Hence my application hangs sometimes if the database server machine goes
    down abnormally.

    While browsing the application log, I noticed that it hangs in
    ExecuteSql method or Record set open functions.

    Any help is appreciated to solve this problem.

    Thanks in advance.

    Regards,

    Selva







    DISCLAIMER:
    -----------------------------------------------------------------------------------------------------------------------

    The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only.
    It shall not attach any liability on the originator or HCL or its affiliates. Any views or opinions presented in
    this email are solely those of the author and may not necessarily reflect the opinions of HCL or its affiliates.
    Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of
    this message without the prior written consent of the author of this e-mail is strictly prohibited. If you have
    received this email in error please delete it and notify the sender immediately. Before opening any mail and
    attachments please check them for viruses and defect.

    -----------------------------------------------------------------------------------------------------------------------
  • Selvakaruppiah s-TLS,Chennai at Aug 11, 2008 at 5:47 am
    Hi All



    I am facing a problem with Postgres 8.1.4 Windows native version.

    I am writing a simple application that executes an update query in a
    postgres database.

    This query execution will be called in a loop for 500 times.

    After starting the execution of the exe, I am switching off the Postgres
    server machine (say abrupt shutdown of the machine happened).

    In this scenario, my sample application hangs.



    Application code snippet would be like the below.



    DBObj.Open (NULL, FALSE, FALSE, ConnectionString);

    SQL = "Update mytable set sno=1 where sno=1";

    for(int n=0; n<500; n++)

    {

    Try

    {

    WriteLog("Start");

    DBObj.ExecuteSQL (strSql);

    WriteLog("End");

    }

    Catch Exceptions...{}

    }





    Application hangs in the ExecuteSql statement itself.



    This problem is not happening with Postgres 7.2.4 that runs on top of
    Cygwin.

    And also this problem is not happening if I shutdown the server alone
    from Services

    Instead of machine shutdown.



    Any help is appreciated.

    Thanks in advance.



    Regards,

    Selva





    DISCLAIMER:
    -----------------------------------------------------------------------------------------------------------------------

    The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only.
    It shall not attach any liability on the originator or HCL or its affiliates. Any views or opinions presented in
    this email are solely those of the author and may not necessarily reflect the opinions of HCL or its affiliates.
    Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of
    this message without the prior written consent of the author of this e-mail is strictly prohibited. If you have
    received this email in error please delete it and notify the sender immediately. Before opening any mail and
    attachments please check them for viruses and defect.

    -----------------------------------------------------------------------------------------------------------------------

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppgsql-novice @
categoriespostgresql
postedJul 10, '08 at 2:38p
activeAug 11, '08 at 5:47a
posts3
users2
websitepostgresql.org
irc#postgresql

People

Translate

site design / logo © 2022 Grokbase