Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2006
    Posts
    16

    Unanswered: how to declare a variable

    hi i m trying to declare a variable in postgre but it's giving an error

    Declare var smallint;
    var := 4;

    but it is giving an error syntax error near or at smallint

    please help me out

    thanks in advance

  2. #2
    Join Date
    Nov 2006
    Posts
    82
    Where do u try to declare variable, in plpgsql function? (if so it should be done in Declare section, see postgresql doc on postgresql.org).

  3. #3
    Join Date
    Aug 2006
    Posts
    16
    i m trying to Declare variable only not in function or not in store procedure , my query is like that

    Declare var Smallint;
    var := 4
    Begin
    Select * from OperandTest where Id = var

    but i m getting an error
    syntax error near or at smallint
    error 42601

  4. #4
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    PostgreSQL only supports variables in stored procedures. Not in SQL.
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


Posting Permissions

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