7

次のように、ストアド プロシージャの結果を一時テーブルに挿入したいと考えています。

CREATE temporary TABLE NEWBalance (VendorAmount NUMERIC(15,2),   
                                   UserBalanceAmount NUMERIC(15,2));  

INSERT NEWBalance call SP VenAccNo,PeopleId;

しかし、それはエラーを生成します:

Error Code: 1064. You have an error in your SQL syntax; check 
the manual that corresponds to your MySQL server version for 
the right syntax to use near 'call SP VenAccNo,PeopleId' at line 1

これを行う方法はありますか?

4

1 に答える 1

9

残念ながら、MySql ではまだそれを行うことはできません。

考えられる解決策は、SP を変更して一時テーブルに INSERT を実行させることです。

CREATE PROCEDURE your_sp(...)
BEGIN
    -- do your processing
    ...
    -- insert results into a temporary table
    INSERT INTO NEWBalance ...
    SELECT ...;
END

次に、あなたの流れは次のようになります

CREATE temporary TABLE NEWBalance 
(
 VendorAmount NUMERIC(15,2),
 UserBalanceAmount NUMERIC(15,2)
);

CALL your_sp (...);

-- do your processing on data in a temporary table
...

DROP TEMPORARY TABLE NEWBalance;
于 2013-08-06T05:36:19.820 に答える