0
DECLARE FoundCount INT;
DECLARE db_Name VARCHAR(255);
SET @Project_List_val = CONCAT(Project_Number_val, '_List');
SET @db_Name='test_rs';
SET @sql1 = CONCAT('SELECT COUNT(1) INTO', @FoundCount ,'
FROM information_schema.tables
WHERE table_schema =',@db_Name,'
AND table_name =', @Project_List_val);
PREPARE stmt FROM @sql1;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
IF FoundCount = 1 THEN
SET @sql = CONCAT(' INSERT INTO test (Panel_Id)
SELECT Panel_Id
FROM ', @Project_List_val);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END IF;
這個存儲過程執行得很好。但是當試圖運行它時,它顯示的是錯誤。mysql表存在存儲過程邏輯
1064 - 您的SQL語法錯誤;檢查與您的MySQL服務器版本相對應的手冊,以便在第1行的'NULL'附近使用正確的語法。
如果指定的表(@Project_List_val)存在,我需要運行第二個查詢。這樣@ FoundCount = 1這樣
沒有區別。同樣的錯誤? – user1597811 2013-02-12 10:35:27
還有更多建議嗎? – user1597811 2013-02-12 10:39:05
同樣的錯誤。我使用了上述修改後的代碼 – user1597811 2013-02-12 10:47:14