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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:59:39+00:00 2026-06-14T04:59:39+00:00

In a MySQL procedure, I want to set current_timestamp+0 to a variable and use

  • 0

In a MySQL procedure, I want to set current_timestamp+0 to a variable and use this variable in queries.

Edited:
I need @P_version to stay the same value during the whole procedure. I would like to get the current timestamp at the begining and use this value in all the queries.

I tried:

BEGIN
    DECLARE P_version float;
    SET P_version = current_timestamp +0;

    insert INTO reports_4.Items(id, version, itype)
    Select I.id, P_version, I.itype from Items where I.live = 1;
    .....
END;

And:

    BEGIN
      BEGIN
        SET @P_version = 'select current_timestamp +0 from dual';
            PREPARE query from @P_version;
            EXECUTE query;
            DEALLOCATE prepare query;
        END;    
      insert INTO reports_4.Items(id, version, itype)
      Select I.id, P_version, I.itype from Items where I.live = 1;
      .....
END;

If I use the following, when I call my procedure a second time the value of @P_version has the same value that the first time I ran the procedure.

BEGIN
  select @P_version = current_timestamp +0 from dual;

  insert INTO reports_4.Items(id, version, itype)
  Select I.id, @P_version, I.itype from Items where I.live = 1;
  .....
END;

Do you have an idea?

  • 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-14T04:59:40+00:00Added an answer on June 14, 2026 at 4:59 am

    set @p = now();? mysql doesn’t require selecting from dual for this sort of thing.

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

Sidebar

Related Questions

I have a MYSQL stored procedure SP1() that returns a result set. I want
I use the following mysql procedure, DROP PROCEDURE IF EXISTS `allied`.`GetRegistrationData`$$ CREATE DEFINER=`allied`@`%` PROCEDURE
I have a mysql stored procedure from this ( google book ), and one
I want to be able to get some output from mysql stored procedure within
Hi I'm having problems getting this to work in mysql. DELIMITER $$ DROP PROCEDURE
i want to execute a mysql stored procedure from mysql command prompt in phpmyadmin.stored
I want to convert a days-since-last-activity value in my SQL Server stored procedure to
I have a MySQL stored procedure with a few cursors. I want to print
I am writing a Stored Procedure in MySQL to get a set of management
I need to add a new stored procedure on our company's MySQL server. Since

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.