How to use execute statement? Getting error: syntax error at or near "USING"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • osman7king
    New Member
    • Sep 2010
    • 61

    #1

    How to use execute statement? Getting error: syntax error at or near "USING"

    I use the EXECUTE statement in a procedure which has 2 parameters, one is to hold the query, and the other for the value used in the query
    Code:
    create or replace function delete_from_table1(character varying , integer ) 
    RETURNS void as '
    DECLARE
    query ALIAS FOR $1;
    id  ALIAS FOR $2;
    
    BEGIN
    EXECUTE query 
    USING id ;
    
    END;'
    
    language 'plpgsql';
    but I have an error:
    ERROR: syntax error at or near "USING"

    may any one solve this problem?

    THANKS.
  • rski
    Recognized Expert Contributor
    • Dec 2006
    • 700

    #2
    What postgres version do you use.

    Comment

    • osman7king
      New Member
      • Sep 2010
      • 61

      #3
      Postgres 8.3 for windows

      Comment

      • rski
        Recognized Expert Contributor
        • Dec 2006
        • 700

        #4
        Code:
        EXECUTE .. USING
        appeared in 8.4 version.
        See here http://www.postgresql.org/docs/8.4/s...lease-8-4.html

        Comment

        Working...