当前位置: 代码迷 >> 其他数据库 >> sqlite 有变量不?解决办法
  详细解决方案

sqlite 有变量不?解决办法

热度:6263   发布时间:2013-02-26 00:00:00.0
sqlite 有变量不?
SQL code
-- 交易视图插入时触发器CREATE TRIGGER Trade_V_T_I    INSTEAD OF INSERT ON Trade_V    FOR EACH ROWBEGIN    INSERT INTO Trade (        C_Id,        P_Id,        Price,        Count,        "Date",        Note    )    VALUES (        (            SELECT Id            FROM Client_V            WHERE                City = NEW.City                AND                Unit = NEW.Unit                AND                Name = NEW.Client        ),        (            SELECT Id            FROM Product_V            WHERE                Factory = NEW.Factory                AND                "Type" = NEW.Product        ),        -- 首次        (            CASE WHEN NEW.Price ISNULL THEN                (                    SELECT Price                    FROM Product_V                    WHERE                        Factory = NEW.Factory                        AND                        "Type" = NEW.Product                )            ELSE                NEW.Price            END        ),        NEW.Count,        NEW."Date",        NEW.Note    );    UPDATE Client_V SET        Arrear = Arrear            + (                -- 再次                (                    CASE WHEN NEW.Price ISNULL THEN                        (                            SELECT Price                            FROM Product_V                            WHERE                                Factory = NEW.Factory                                AND                                "Type" = NEW.Product                        )                    ELSE                        NEW.Price                    END                )                * NEW.Count            )    WHERE        City = NEW.City        AND        Unit = NEW.Unit        AND        Name = NEW.Client;END;

有没有复用手段?比如赋给一个临时局部变量。

------解决方案--------------------------------------------------------
不支持 变量
  相关解决方案