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

  • Home
  • SEARCH
  • 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 8937747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:28:12+00:00 2026-06-15T10:28:12+00:00

I have a trigger that I want to insert the same random value into

  • 0

I have a trigger that I want to insert the same random value into two tables. How do I do this?

CREATE TRIGGER insertTrigger AFTER INSERT ON TableAB 
BEGIN
    INSERT INTO TableA(id, num) VALUES(RANDOM(), 1);
    INSERT INTO TableB(id, num) VALUES(??, 1);
END;

I am not really using Random, but my own custom sqlite function which essentially does the same thing, but I need to remember that value to insert into TableB. How do I do that?

  • 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-15T10:28:13+00:00Added an answer on June 15, 2026 at 10:28 am

    SQLite has no such thing as variables, but you could read the value from the record that you had just inserted into the first table:

    CREATE TRIGGER insertTrigger
    AFTER INSERT ON TableAB
    BEGIN
        INSERT INTO TableA(id, num) VALUES(RANDOM(), 1);
        INSERT INTO TableB(id, num) SELECT id, 1
                                    FROM TableA
                                    WHERE rowid = last_insert_rowid();
    END;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables, that share the same definition. I commonly insert new objects
I have tow tables concept_access and concept_access_log. I want to create a trigger that
I have a trigger that looks something like this: create or replace TRIGGER cluster_check
With sql Server 2005. I have declared a trigger that get fired AFTER INSERT,
here are the 2 tables i have, i want to implement an trigger that
I have an click function that I want to trigger outside of the function
I have a trigger that check data before insert to another table IF NOT
I have a trigger for insert/update/delete. That is working fine. Also, I need the
is is possible in postgres to have a trigger on CREATE TABLE that will
I have written a trigger that I want to use for adding the date

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.