Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9183285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:45:55+00:00 2026-06-17T18:45:55+00:00

Does the function that returns the trigger automagically have the ability to reference the

  • 0

Does the function that returns the trigger automagically have the ability to reference the NEW and OLD pseudo-rows in a before-update trigger designated for each row?

 CREATE TRIGGER foo_trigger BEFORE UPDATE ON emp
    FOR EACH ROW EXECUTE PROCEDURE foo();

   CREATE FUNCTION foo() RETURNS trigger AS $foo_trigger$
    BEGIN  
        NEW.taxrate := 5.5;        
        RETURN NEW;
    END;
    $foo_trigger$ LANGUAGE plpgsql;

And must the string inside $....$ in the final line of the function $foo_trigger$ LANGUAGE plpgsql; exactly match the name of the trigger in the CREATE TRIGGER statement, or is it just a placeholder?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:45:56+00:00Added an answer on June 17, 2026 at 6:45 pm

    automagically have the ability to reference the NEW and OLD pseudo-rows in a before-update trigger designated for each row

    Yes.

    Quote from the manual http://www.postgresql.org/docs/current/static/plpgsql-trigger.html

    When a PL/pgSQL function is called as a trigger, several special variables are created automatically in the top-level block.

    Must the string […] exactly match the name of the trigger in the CREATE TRIGGER statement, or is it just a placeholder

    No.

    The $..$ thing is called “dollar quoting” and simply replaces single quotes to make handling large strings (with embedded quotes) easier. The only requirement is that you use the same “key” at the start and at the end. You can use $body$ (which is very common) or anything you like.

    See the manual for details: http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-DOLLAR-QUOTING

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function that does a long task and I want to update
Does somebody know a module, which has a function that returns ( for example
Does Actionscript have a built-in function that accepts a number and can return a
I have the following function that does string splitting: on splitText(aString, delimiter) set retVal
Say I have a function that does the following in Vb.net For i as
I have this Trigger in Postgresql that I can't just get to work (does
As topic suggested, how can I unit test a function that does not return
Does the entrySet() function that is called from a treemap instance return a TreeSet
ive a function that does calculations on a table using jquery when any input
Is there any function that does the inverse operation of array_diff() ? I mean,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.