oracle 如何使用 Form Builder 和 PL/SQL 插入记录?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/595495/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I insert a record using Form Builder and PL/SQL?
提问by Ronnie
I'm slowly learning SQL and how to use form builder 6. The situation is I have a simple table named 'players' within the table I have three columns:
我正在慢慢学习 SQL 以及如何使用表单生成器 6。情况是我在表中有一个名为“玩家”的简单表,我有三列:
- player_no (primary key)
- position
- goals
- player_no(主键)
- 位置
- 目标
Within form builder 6 I have created a very simple form using these three fields. The form is named 'TEAM'. At at the foot of the form I have a button labelled 'Add'. The goal is for the user to enter a player_no, position and goals and then to click 'Add'. This information is then to go into my table.
在表单生成器 6 中,我使用这三个字段创建了一个非常简单的表单。该表格被命名为“团队”。在表单的底部,我有一个标记为“添加”的按钮。目标是让用户输入 player_no、位置和目标,然后单击“添加”。然后将这些信息放入我的表中。
All attempts so far have failed miserably. I have set up a trigger on the button (WHEN_MOUSE_CLICK). I have then entered the following code:
迄今为止的所有尝试都以惨败告终。我在按钮 (WHEN_MOUSE_CLICK) 上设置了触发器。然后我输入了以下代码:
BEGIN
INSERT INTO players ( player_no )
VALUES ( :TEAM.player_no )
END
For the purpose of testing it out I have only been using the one (player_no) field. This then compiles with no errors yet when I run the form and enter a player_no and hit the button I get the following error in the status bar:
为了测试它,我只使用了一个 (player_no) 字段。然后,当我运行表单并输入 player_no 并点击按钮时,编译时没有错误,我在状态栏中收到以下错误:
frm-40735: WHEN-MOUSE-CLICK trigger raised unhandled exception ORA-01400
frm-40735:WHEN-MOUSE-CLICK 触发器引发未处理的异常 ORA-01400
Am I doing something horribly wrong? I am very much new to SQL and Form Builder so any help would be greatly appreciated.
我做错了什么吗?我对 SQL 和 Form Builder 非常陌生,所以任何帮助将不胜感激。
采纳答案by Maksym Gontar
ORA-01400: cannot insert Nullseems like one of your fields are not null and you omited them on insert. or value :TEAM.player_no is null during insert.
ORA-01400: 无法插入 Null似乎您的字段之一不为空,并且您在插入时省略了它们。或值 :TEAM.player_no 在插入期间为空。
Also, somewhere from web:
另外,来自网络的某个地方:
FRM-40735: ON-INSERT trigger raised unhandled We have had similar problem since 11.5.9. We clear Jinitiator cache, and temporary internet files (tools>internet options then under temporary internet files the clear files button). Seems to work.
FRM-40735:未处理的 ON-INSERT 触发器从 11.5.9 开始我们遇到了类似的问题。我们清除 Jinitiator 缓存和临时 Internet 文件(工具> Internet 选项,然后在临时 Internet 文件下的清除文件按钮)。似乎工作。
回答by Jeffrey Kemp
One of the benefits of using Form Builder is that you almost always don'tneed to write the DML statements yourself.
对使用窗体生成器的好处是,你几乎总是没有需要自己编写DML语句。
Just make the block based on the table - then the user can add and modify as many records as they like, then when they save (i.e. COMMIT), the Forms runtime automatically works out what INSERTs and UPDATEs are required to save the changes.
只需根据表制作块 - 然后用户可以添加和修改任意数量的记录,然后当他们保存(即提交)时,Forms 运行时会自动计算出需要哪些 INSERT 和 UPDATE 来保存更改。