Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2012
    Posts
    30

    Unanswered: Is It Possible To Make a Query That Autogenerate The Data?

    Hi to All,

    i make a query in a file :
    Code:
    SELECT * FROM orders WHERE week=6;
    then I executed the query by the command
    Code:
    \i file;
    Is it possible to make a psql function that autogenerates the week number(1-53) taking it from the system(O.S)?

    If yes, which will be the sintax, and how tho execute the function?

    Tanks in advance.
    Gianni Pinna.

  2. #2
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Use
    Code:
    extract(week from current_date)
    More details in the manual: http://www.postgresql.org/docs/current/static/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

  3. #3
    Join Date
    Dec 2012
    Posts
    30
    Hi Shammat,
    have You the same attention X100, to every Your question.
    Tanks again for Your promt replay.
    Gianni Pinna.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •