这个sql给出了像
这样的错误ORA-01733:此处不允许使用虚拟列。
没有GET_PROPERTY
函数,SQL可以工作。怎么解决?
UPDATE (SELECT VALUE, GET_PROPERTY (ORG.ID, 'BenefOperationCode') AS OPERATION_CODE
FROM ORGANIZATION ORG, PROPERTY P
WHERE ORG.EXTERNALKEY = '111' AND P.ID = ORG.ID AND P.IDX = 4)
SET VALUE = 123, OPERATION_CODE = 234;
答案 0 :(得分:3)
编辑:由于ORA-01776错误,以下更新将无效(感谢Vincent)。请参阅新方法的结尾。
您正在尝试更新功能结果。这是不可能的。我假设您正在尝试更新函数检索的基础值。为此,您需要将功能代码与组织和属性之间的连接组合在一起。
我们说GET_PROPERTY是:
CREATE OR REPLACE FUNCTION GET_PROPERTY
(
objectID_in NUMBER,
propertyName_in VARCHAR
)
AS
v_returnValue VARCHAR(32);
BEGIN
SELECT
PropertyValue INTO v_returnValue
FROM
PropertyTable
WHERE
ObjectID = objectID_in
AND PropertyName = propertyName_in;
RETURN v_returnValue;
END
您的更新将成为:
--This wouldn't have worked.
编辑:最好编写一个程序来完成它。
CREATE PROCEDURE UpdateMyTwoTables
(
orgExternalKey_in in VARCHAR,
propertyIdx_in in NUMBER,
propertyName_in in VARCHAR,
newValue_in in VARCHAR,
newPropertyValue_in in VARCHAR
)
AS
BEGIN
UPDATE
(SELECT
ORG.Value
FROM
ORGANIZATION ORG,
PROPERTY P
WHERE
ORG.EXTERNALKEY = orgExternalKey_in
AND P.ID = ORG.ID AND
P.IDX = propertyIdx_in)
SET
Value = newValue_in;
UPDATE
(SELECT
PropertyValue
FROM
PropertyTable,
ORGANIZATION ORG,
PROPERTY P
WHERE
PropertyTable.objectID = ORG.ID
AND ORG.ID = P.ID
AND ORG.EXTERNALKEY = orgExternalKey_in
AND P.Idx = propertyIdx_in
AND PropertyTable.PropertyName = propertyName_in)
SET
PropertyValue = newPropertyValue_in;
END;