Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.

MariaDB10 Stored Procedure Select with variable TableName

Franky's profile image Franky posted 2 months ago in General Permalink

Sorry for my stupid question, but i didn't understand the problem.

My stored procedure: (Editable part of HeidiSql)

BEGIN DECLARE NewId TINYTEXT; DECLARE tbTab TINYTEXT;

SET tbTab = 'tbHouse';      

FOR i IN REVERSE 0..(SELECT COUNT(*) FROM tbTab) DO
   SET NewID = (CONCAT ('ID-', (CONVERT (i USING UTF8))));
   IF (SELECT COUNT(*) FROM tbHouse WHERE HouseID = NewId) = 0 THEN RETURN NewID; END If;
END FOR;

RETURN 'ID-0000';

END

FOR i IN REVERSE 0..(SELECT COUNT(*) FROM tbHouse) DO =>> work's fine

ImmoDB_Kastrup.tbHouse exists and function works fine ImmoDB_Kastrup.tbTab does not exist - Yes, it is correct

I have to signal, that tbTab is a variable --- but how ???

Declaration with @ or $ or %% does not work ...

please can you help me - i'm searchig in the net for some hours, and i often found your page ...

Franky's profile image Franky posted 2 months ago Permalink

Sorry for the question ...

I think it is a misunderstood from my side. I expect it is a better way to reffer directly the database table. I believe MariaDb analyse the code at import. So they can't reffer to a databse.table. Therefor i have create dynamicly the code at runtime ... create procedure or execute. I believe that not a good way for performance ...

It is no problem of HeidiSQL, it is a layer8 problem ;-) = stupid user

Please login to leave a reply, or register at first.




Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.