Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2011
    Posts
    2

    Unanswered: Dummy data in postgres gives error

    CREATE OR REPLACE FUNCTION updateWebTransLog() RETURNS TRIGGER AS '
    DECLARE
    transactionType character varying(3);
    BEGIN
    INSERT INTO webtranslog(username,reqtime,transactiontype,descr iption) (SELECT tellerid,date,'CR', mbnumber FROM userreg WHERE mbnumber = NEW.mbnumber);
    RETURN NULL;
    END;

    ' LANGUAGE plpgsql;




    ifollowing is th output::


    ERROR: syntax error at or near "CR"
    LINE 5: ...ansactiontype,description) (SELECT tellerid,date,'CR', mbnum...
    ^


    ********** Error **********

    ERROR: syntax error at or near "CR"
    SQL state: 42601
    Character: 220



    please help!!

  2. #2
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    This error occurs because you are nesting single quotes.

    Quote from the manual for the CREATE FUNCTION statement regarding the function body:
    Quote Originally Posted by Manual
    definition:

    It is often helpful to use dollar quoting (see Section 4.1.2.4) to write the function definition string, rather than the normal single quote syntax. Without dollar quoting, any single quotes or backslashes in the function definition must be escaped by doubling them.
    For details on how to use the dollar quotings, read the mentioned section:

    http://www.postgresql.org/docs/9.0/s...DOLLAR-QUOTING

  3. #3
    Join Date
    Jun 2011
    Posts
    2
    I tried it and it worked. Very thankful to u... shammat

Posting Permissions

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