我是sap hana世界的新人。我试图使用存储过程来更新信息。我想发送一个自定义表类型与字段名称,字段值和行ID。 我创建了这种类型:
CREATE TYPE t_field AS TABLE (
ID INTEGER,
FLD VARCHAR(100),
VAL VARCHAR(100));
我在这个过程中使用它:
PROCEDURE "_SYS_BIC"."Match.procedures::updateAnag" (
in tfield tt_field,
out error tt_error
)
LANGUAGE SQLSCRIPT
SQL SECURITY INVOKER
DEFAULT SCHEMA "_SYS_BIC"
AS
BEGIN
declare _id integer;
declare _field varchar(100);
declare _value varchar(100);
select ID, F_NAME, F_VALUE
into _id, _field, _value
from :tfield;
IF(_field = '' OR _value = '') THEN
error = SELECT 400 AS http_status_code,
'empty field' as error_message,
'All fields must be filled' as detail from dummy;
ELSE
IF (_field = 'name') THEN
UPDATE "_SYS_BIC"."TEST_TABLE"
SET NAME = _value
WHERE ID = _id;
END IF;
IF (_field = 'surname') THEN
UPDATE "_SYS_BIC"."TEST_TABLE"
SET SURNAME = _value
WHERE ID = _id;
END IF;
END IF;
END;
但是当我尝试激活代码时,eclipse会将此错误返回给我: ' sap-ui-core.js:159 2016-07-19 17:45:47.751550出现以下问题:HTTP请求失败400,错误请求,请求包含实体中不存在的属性' anagType&# 39 ;. - '
有人可以帮我解决这个问题或者告诉我更好的方法吗?
答案 0 :(得分:1)
好吧,从SQLSCript代码的角度来看,我要说的一个问题是,当你使用变量(比如_value或_id)时,需要在它们前面加上冒号:
CREATE PROCEDURE "_SYS_BIC"."Match.procedures::updateAnag" (
in tfield tt_field,
out error tt_error
)
LANGUAGE SQLSCRIPT
SQL SECURITY INVOKER
DEFAULT SCHEMA "_SYS_BIC"
AS
BEGIN
declare _id integer;
declare _field varchar(100);
declare _value varchar(100);
select ID, F_NAME, F_VALUE
into _id, _field, _value
from :tfield;
IF(:_field = '' OR _:value = '') THEN
error = SELECT 400 AS http_status_code,
'empty field' as error_message,
'All fields must be filled' as detail from dummy;
ELSE
IF (:_field = 'name') THEN
UPDATE "_SYS_BIC"."TEST_TABLE"
SET NAME = :_value
WHERE ID = :_id;
END IF;
IF (:_field = 'surname') THEN
UPDATE "_SYS_BIC"."TEST_TABLE"
SET SURNAME = :_value
WHERE ID = :_id;
END IF;
END IF;
END;
另一个问题是您没有在IF语句的第二个分支中初始化表变量错误。
不太确定,这与您的错误消息有什么关系。您可能希望首先调用并测试该过程,然后查看与xsjs页面的连接无法正常工作的原因。