MySQL Forums
Forum List  »  Newbie

Prepare statement aparent crash
Posted by: Fernando Davidovsky
Date: February 06, 2015 06:10AM

Hello everyone,

I'm writing a stored procedure that needs to return a string cotaining information from serveral records retrieved from a SELECT (in ORACLE, I would use a REF-CURSOR and return it, but this is not feasible in MySql).

In this procedure, I'm trying to use PREPARE STATEMENT to populate a temporary table with the results of a select, something like:

CREATE TEMPORARY TABLE IF NOT EXISTS TTT_Tempo_Table AS ( select A , B , C from MyTable where...).

A varchar string is used to hold the statement since its contents depends on the parameters received by the stored procedure. so, the code would look like:

:

set @The_Statement = l_Tempo_Statement ;

PREPARE STATEMENT FROM @The_Statement ;

:

IN parallel, I deployed calls to a debug function that inserts information into a debug table.

I tried running the generated statement (i.e. contents of the variable l_Tempo_Statement) in a query sheet and it works perfectly.

When executing the "PREPARE STATEMENT" line, the procedure appears to complete but neither data nor debug information can be found within the debug table.

Also tried to wrap the PREPARE STATEMENT in a BEGIN-END exeception handler catching ANY error (i.e. "DECLARE EXIT HANDLER FOR SQLEXCEPTION") and printing debug information whenever an exception is raised, but nothing happens.

Questions:

1) Am I attempting to do something that is not supported?
2) Can anyone suggest how to catch the error?
3) Can anyone suggest an alternative implementation?

Thanks in advance,

Fernando.

Options: ReplyQuote


Subject
Written By
Posted
Prepare statement aparent crash
February 06, 2015 06:10AM


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.