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?
set @p = now();? mysql doesn’t require selecting from dual for this sort of thing.