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 8049501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:48:12+00:00 2026-06-05T06:48:12+00:00

In my schema I have many tables with common fields that I need to

  • 0

In my schema I have many tables with common fields that I need to fill. This are basicaly control fields like this ones:

id_db_user
date_creation
date_last_update

I have done two triggers to fill this fields:

-- Trigger DDL Statements
delimiter |
CREATE TRIGGER control_insert BEFORE INSERT ON EZT_SOCIETIES

  FOR EACH ROW BEGIN

    SET NEW.id_db_user    = current_user;

    SET NEW.date_creation = current_timestamp;

  END;
| delimiter ;


delimiter |
CREATE TRIGGER control_update BEFORE UPDATE ON EZT_SOCIETIES

  FOR EACH ROW BEGIN

    SET NEW.date_last_update = current_timestamp;

  END;
| delimiter ;

My question is: Can I write some function to call the operations inside the trigger? Something like this:

function fn_control_insert
    SET NEW.id_db_user    = current_user;
    SET NEW.date_creation = current_timestamp;

and then call this function in the trigger like:

delimiter |
CREATE TRIGGER control_insert BEFORE INSERT ON EZT_SOCIETIES

  FOR EACH ROW BEGIN

    call fn_control_insert;

  END;
| delimiter ;

This is possible to do in MySQL?

Best Regards,

  • 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-05T06:48:13+00:00Added an answer on June 5, 2026 at 6:48 am

    No, it’s not possible, unfortunately, nor you can pass NEW and OLD as parameters, nor function parameters can be OUT or INOUT (i.e. writable), so the short answer is no.

    You can call a function from a trigger (provided the function doesn’t violate any of the MySQL trigger restrictions such as modifying the table the trigger is attached to), but you’ll have to pass the function every individual NEW or OLD field you need to read, and the function will be unable to write to them — all you can do from a function is return a value.

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

Sidebar

Related Questions

I have a star schema type data base, with fact tables that have many
I have a table which have schema like this id name 1 jack 2
I have many tables that have a [DateCreated] column that also needs a [DateModified]
I have a schema with many related tables. A view let me agglomerate all
I have a MySQL database that contains many tables, some of them created dynamically
I have a tables of Users, Carts, Orders and OrderTransactions. My schema looks like:
I have many tables with identical schemas but different names. Can I create a
Let's say I have a schema where User has many Alerts (many to many).
I have three entities: EntityA, EntityB and EntityC connected with to-many relationships. See schema
I have no control over database schema and have the following (simplified) table structure:

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.