[英]Oracle Apex 5: Using PL/SQL to insert a value to a page item
I'm trying to create an auto-incrementing Primary Key for a questionnaire created by a wizard. 我正在尝试为向导创建的调查表创建自动递增的主键。 The problem is, that I need the Primary Key to be inserted into the page item P2_ID (which is a hidden item) during the pre-render stage, so that I can have an ARF process run on each section of the questionnaire to allow the employees to go back and change their answers.
问题是,我需要在预渲染阶段将主键插入页面项目P2_ID(这是一个隐藏项目)中,以便我可以在问卷的每个部分上运行ARF流程以允许员工回去改变他们的答案。
I can't seem to use a trigger, as that implements on submit, and I'd like the PK to populate as the session begins. 我似乎无法使用触发器,因为它是在提交时实现的,我希望在会话开始时填充PK。
Currently, I have a process running in the pre-render stage with this PL/SQL code: 当前,我有一个使用以下PL / SQL代码在预渲染阶段运行的进程:
begin
select SEQ_UAT.nextval into :P2_ID from dual;
end;
But no matter what I do, I can't seem to get this very simple PL/SQL code to populate the P2_ID page item! 但是,无论我做什么,我似乎都无法获得这个非常简单的PL / SQL代码来填充P2_ID页面项!
Any ideas? 有任何想法吗?
thanks for answering. 谢谢回答。
I was able to figure it out somehow. 我能够以某种方式弄清楚。 Basically, I removed the ARP I had running and made it a PL/SQL function, this allowed me to create a pre-render PL/SQL process to create a PK using seq.nextval.
基本上,我删除了正在运行的ARP,并使其成为PL / SQL函数,这使我可以创建一个预渲染的PL / SQL进程来使用seq.nextval创建PK。
Not sure why, but it seemed that the ARP just wouldn't work with the seq.nextval! 不知道为什么,但是似乎ARP不能与seq.nextval一起使用!
Not sure why that isn't working, but you could just use MAX(pk_id)+1
. 不知道为什么它不起作用,但是您可以只使用
MAX(pk_id)+1
。 If you use seq.nextval
it will increment every time the user refreshes page etc. 如果使用
seq.nextval
,则每次用户刷新页面等时它将增加。
Edit: couldn't you also just set :P2_id's source to sql query and populate from there? 编辑:您是否也可以只将:P2_id的源设置为sql查询并从那里填充?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.