Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6868125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:23:44+00:00 2026-05-27T03:23:44+00:00

I have been recently porting a Perl application form Oracle to Postgres (my first

  • 0

I have been recently porting a Perl application form Oracle to Postgres (my first time with Postgres) and I am stumped by a small issue which I was able to reduce to the following sample code:

use strict;
use warnings;
use DBI;

my @db_params = qw (dbi:Pg:host=127.0.0.1;database=test test test);

my $dbh = DBI->connect(@db_params, {AutoCommit => 0 } ) or die ;
while (1) {
    my $sth = $dbh->prepare_cached('SELECT localtimestamp ') or die;
    $sth->execute() or die;
    my $result = $sth->fetchall_arrayref();
    print $result->[0][0] , "\n";
    sleep(5);
}

This outputs :

2011-11-27 16:46:25.94291
2011-11-27 16:46:25.94291
2011-11-27 16:46:25.94291

I am getting the same time stamp all the time unless I disconnect and reconnect to the database.

How can I make sure that ever time I select localtimestamp from the database I get the value corresponding to the time when the sql is executed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:23:45+00:00Added an answer on May 27, 2026 at 3:23 am

    Because you are not using autocommit, you are always in the same transaction, and localtimestamp gets the timestamp at the start of that transaction in Postgres. I.e. you will need to create individual transactions for your queries, using $dbh->begin_work and $dbh->commit.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been recently running into an issue in which my web application will
I am working on a Spring MVC application in which I have recently been
We have recently been faced with the problem of porting our C++ framework to
Have recently been given a project to complete which uses XML quite extensively.Am looking
I have recently been put in charge of debugging two different programs which will
I have recently been developing a website which relies a large part on the
I have recently been trying ot write code to add and delete content form
I have been recently assigned a task in which I need to create a
I have recently been messing with form submission and I was making a Python
I have recently starting porting a small app of mine to Facebook as a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.