Oracle 10G表格。检查数据库中是否存在值
问题1:
在插入如何检查您在该文本框中输入的值是否确实与数据库中的值相匹配。 我的榜样和方法不起作用。显示的错误是:
表,视图在此上下文中不允许。
按下按钮[添加按钮]
//blockname compare //database table DRINK, column drink_id
IF (:RESERVATION_BLOCK.DRINK_ID<>DRINK.DRINK_ID) THEN
MESSAGE('IF PART');
ELSE
MESSAGE('ELSE PART');
END IF;
问题2:
使用if语句添加数据库 显示的不工作错误是按按钮按下扳机升高时
未经处理的异常ORA-00001。
我的示例不起作用:按下按钮时[保存按钮]无需if语句即可完美地工作,但这不是一个好练习
IF (:RESERVATION_BLOCK.DRINK_ID is null) THEN
MESSAGE('No Drink Ordered');
ELSIF (:RESERVATION_MENU_DRINK_BLOCK.DRINK_ID is not null) THEN
INSERT INTO RESERVATION_DRINK
VALUES(
:RESERVATION_BLOCK.RESERVATION_ID, //comes from previous tab pane block
:RESERVATION_MENU_DRINK_BLOCK.DRINK_ID,
:RESERVATION_MENU_DRINK_BLOCK.QUANTITY);
COMMIT;
MESSAGE('DRINK ORDER SAVED SUCCESSFULLY!');
END IF;
Question 1 :
while inserting how will you check whether the value you entered in that textbox does matched with that in the database.
My example and approach not working. error displayed is:
table, view does not allow in this context.
when button pressed[Add button]
//blockname compare //database table DRINK, column drink_id
IF (:RESERVATION_BLOCK.DRINK_ID<>DRINK.DRINK_ID) THEN
MESSAGE('IF PART');
ELSE
MESSAGE('ELSE PART');
END IF;
QUESTION 2:
Using if statement to add in database
not working error displayed is when button pressed trigger raised
unhandled exception ORA-00001.
My example not working: when button pressed [SAVE button] code works perfectly without if statement but that's not a good practice when having null
IF (:RESERVATION_BLOCK.DRINK_ID is null) THEN
MESSAGE('No Drink Ordered');
ELSIF (:RESERVATION_MENU_DRINK_BLOCK.DRINK_ID is not null) THEN
INSERT INTO RESERVATION_DRINK
VALUES(
:RESERVATION_BLOCK.RESERVATION_ID, //comes from previous tab pane block
:RESERVATION_MENU_DRINK_BLOCK.DRINK_ID,
:RESERVATION_MENU_DRINK_BLOCK.QUANTITY);
COMMIT;
MESSAGE('DRINK ORDER SAVED SUCCESSFULLY!');
END IF;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题的第一部分:您不能在中引用
中的
表>表示您尝试插入重复值,该值受唯一索引限制(可能是主要或唯一的密钥约束)。
该怎么办?
ID
值;我没有如何将其填充到块中,但是您做到了错误。考虑使用序列,以确保值始终是唯一id
)The first part of the question: you can't reference table in
IF
, do it before it:As of your second question:
ORA-00001
means that you tried to insert a duplicate value which is restricted by unique index (might be a primary or unique key constraint).What to do?
ID
value; I don't have how you populated it into the block, but you did it wrong. Consider using a sequence so that Oracle would make sure that values are always uniqueID
)