MySQL Forums
Forum List  »  Stored Procedures

cannot call a stored procedure from within another stored procedure
Posted by: Sherril Blackmon
Date: October 23, 2021 12:11PM

I have created a stored procedure to help debug stored procedures

CREATE PROCEDURE `WRITE_TO_LOG`(_STRING VARCHAR(5000))
BEGIN
START TRANSACTION;
INSERT INTO logging (LOG_STRING) VALUES (_STRING);
COMMIT;
END

but I am unable to use it:
CREATE DEFINER=`root`@`localhost` FUNCTION `Prepare_values_string`(valueString TEXT) RETURNS varchar(5000) CHARSET latin1
BEGIN
DECLARE _val TEXT;
DECLARE _pos INT;
DECLARE _TAB CHAR;
DECLARE _COMMA CHAR;
DECLARE _len INT;
DECLARE _return_ TEXT;

SET _TAB = x'0009';
SET _COMMA := x'0044';

IF ENDS_WITH(valueString) <> _TAB THEN
SET valueString := CONCAT(valueString, _TAB);
END IF;

SET _return_ := '';
SET _len = LENGTH(valueString);
aWhileLoop : WHILE _len <> 0 DO
SET _pos = locate(_TAB, valueString);
SET _val = substring(valueString, 1, _pos -1);
SET _val = quote(_val);
SET _return_ := concat(_return_, _COMMA, _val);
SET valueString := substring(valueString, _pos +1);
CALL WRITE_TO_LOG(valueString);
SET _len := LENGTH(valueString);
END WHILE aWhileLoop;

RETURN concat('(', _return_, ')');
END

I tried an example where a script created three stored procedures where the third called the first two and it worked like it should.
And, I was able to call the WRITE_TO_LOG proc from a sql script but not from another stored procedure.

Thank you for your help.

Options: ReplyQuote


Subject
Views
Written By
Posted
cannot call a stored procedure from within another stored procedure
968
October 23, 2021 12:11PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.