Hello.
I use inline editing quite a lot, and in some cases to save time I want to create one procedure - like the following:
DROP PROCEDURE IF EXISTS
sp_DBR_update_translation
$$
CREATE PROCEDURE sp_DBR_update_translation
(inId int, inText varchar(255), inAction varchar(16))
BEGIN
IF (inAction) = 'translation' THEN UPDATE innflutningur.translations SET translation = (inText) WHERE id = (inId) LIMIT 1; ELSEIF (inAction) = 'original' THEN UPDATE innflutningur.translations SET original = (inText) WHERE id = (inId) LIMIT 1; ELSEIF (inAction) = 'delete' THEN DELETE FROM innflutningur.translations WHERE id = (inId) LIMIT 1; ELSE -- Debug SELECT concat("Error: ", (inId), " ", (inText), " ", (inAction)); END IF;
END
This way I can use the same procedure for different actions. However, how can I pass a fixed string parameter to the inAction in the following code.
select 'dbr.editable', 'orig', 'sp_DBR_update_translation', 'inId=id', 'inText=orig', 'inAction="original"'; select 'dbr.editable', 'orig', 'sp_DBR_update_translation', 'inId=id', 'inText=translation', 'inAction="translation"'; select 'dbr.editable', 'orig', 'sp_DBR_update_translation', 'inId=id', 'inText=orig', 'inAction="delete"'; select id, original as orig, translation from innflutningur.translations;
In short, I want to be able to use the same stored procedure to handle all updates for a table.