#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    5
    Rep Power
    0

    Current_timestamp in plpgsql did not return the exact time


    Hi,

    I am used the current_timestamp in plpgsql to output the time value when different phases of program units are processing. I used in my code as
    create or replace function execute_f1() returns void as
    $$
    begin
    --- to display the timestamp value the beginning of the f1
    raise notice ' the f1 starts executing at time %',current_timestamp;
    select f1();
    --- to display the timestamp at the end of f1
    raise notice ' the f1 ends execution at time %', current_timestamp;
    return;
    end;
    $$
    language plpgsql;

    But the current_timestamp value is not changing, though executing f1() takes few minutes.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,788
    Rep Power
    349
    Please read the documentation on current_timestamp:

    http://www.postgresql.org/docs/current/static/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT

    pay attention to the sentence: "these functions return the start time of the current transaction"
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags.
    http://forums.devshed.com/misc.php?do=bbcode#code

    Tips on how to ask better questions:
    http://tkyte.blogspot.de/2005/06/how-to-ask-questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    5
    Rep Power
    0
    thank you,
    I used clock_timestamp() in my scenario, gives the current clock time.

IMN logo majestic logo threadwatch logo seochat tools logo