0

ここでは、mysql関数を使用して通貨変換を行いました。以下にお願いします、

CREATE  FUNCTION anycurrency_inr(book_id INT,pub_id INT) RETURNS DOUBLE
DETERMINISTIC
BEGIN
DECLARE publisher_currency VARCHAR(60);
DECLARE org_amount DOUBLE;
DECLARE inr_amount DOUBLE;
DECLARE convert_base DOUBLE;
DECLARE convert_current DOUBLE;
 select publishers.currency into publisher_currency from publishers,books where    publishers.user_id=pub_id and books.id=book_id;
select publisher_currency into org_amount from books where user_id=pub_id;
IF (publisher_currency ='inr_price') THEN
set inr_amount=org_amount;
ELSE
select base_value into convert_base from currencys where base_currency='publisher_currency';
select current_value into convert_current from currencys where base_currency='publisher_currency';
set inr_amount=org_amount * (convert_current/convert_base);
RETURN inr_amount;
END IF;
END

上記のpublisherテーブルは、通貨値をpublisher_currencyに返します(inr_priceまたはdoller_priceまたはpound_priceまたはeuro_price)。私の疑問は、別のクエリで戻り値を渡す方法です。ここでは、publisher_currency値を通貨テーブルに渡します。結果が複数の行で構成されているため、エラーが表示されます。

4

1 に答える 1

0

This error is throwed because more than one row is returned by your request :

select base_value into convert_base from currencys where base_currency='publisher_currency';

And it is not possible to insert more than one value into convert_base variable

于 2013-02-22T15:05:51.470 に答える