APEX ORACLE - 将多个参数插入到从顶点到数据库表的多列中

问题描述

- APEX APP 的结构:

Apex Oracle > 页面> 表单> 内容正文> 项目 > p14_surname,p14_name,p14_birth_date,p14_gender,p14_city,P14_check

  • pkg_cf.cod_fiscale 是一个 pl/sql 过程。

  • pkg_cf = 包名。

  • cod_fiscale = 程序名称

  • V_STR_C 到 V_comune = 是函数和插入参数。

  • V_controllo = 将所有参数和 根据插入的参数生成/创建 ID。

  • employee_list = 表名。

  • employee_list columns = surname,name,birth_date,gender,city,ID ( In 此列,将自动生成/创建的 ID 放入 本专栏)。

**我在 Apex 操作中尝试执行的操作 - 执行服务器端代码

if the p14_check = 1 (true) will execute the package
else p14_check = 0(false) will return an error message,for example 
dbms_output.put_line("there is an error in the ID created/generated")**

顶级页面的结构:

区域按钮 > 创建 > 动态操作 > CLICK_CREATE(动态操作的名称)> TRUE > PL/sql 代码

begin
 pkg_cf.cod_fiscale ( V_STR_C    => :P14_surname,V_STR_N    => :P14_name,V_DATA     => :P14_birth_date,V_SESSO    => :P14_gender,V_COMUNE   => :P14_city,v_controllo => :P14_check);   
if P14_CHECK = 1 then insert into employee_list(name of the table) set surname = :P14_surname,set name = :P14_name,set birth_date = :P14_birth_date,set gender = :P14_gender,set city = :P14_city
else P14_CHECK = 0 then dbms.output.put_line ("there is an error in the ID created/generated");   

我写的代码给了我一个错误: ORA-00926: 缺少 VALUES 关键字

set surname= :P14_surname,

解决方法

您不使用内置表单区域功能的任何原因?这比创建自己的包要简单得多。它还具有手动编码需要大量工作的功能,例如丢失更新检测。看起来您正在尝试重新发明轮子。

您看到的错误是因为插入语句的语法不正确。这是您的代码:

...
if P14_CHECK = 1 then insert into employee_list(name of the table) set surname = :P14_surname,set name = :P14_name,set birth_date = :P14_birth_date,set gender = :P14_gender,set city = :P14_city

但是插入语句的语法是

  INSERT INTO employee_list (surname,name,birth_date,gender,city) VALUES
    (:P14_surname,:P14_name,:P14_birth_date,:P14_gender,:P14_city);

旁白:如果您在 sqlcl、sqlplus 或 sqldeveloper(或 apex 中的研讨会)等客户端工具中运行它,则仅在您的 pl/sql 中使用 dbms_output。在无法使用输出并可能导致意外缓冲区溢出错误的应用中。