Anda di halaman 1dari 4

12/6/2018 sql - Understanding Oracle Apex_Application.

G_Fnn and how to use it - Stack Overflow

Understanding Oracle Apex_Application.G_Fnn Ask Question

and how to use it

I am quite confused with how Oracle


apex_application.gfnn works and
whether it only works for standard
SQL reports in Oracle ApEx or only
with SQL (Updateable reports, i.e.
tabular forms).

Basically I am trying to achieve the


following using this sample SQL,
which is just a Standard SQL Report
but I'm unsure if what I am trying to
achieve is possible with this type or
report, i.e.:

select id,
name,
telephone,
apex_item.checkbox2(10,id) as "Tick when Contacted",
apex_item.text(20,my_date) as "Date Contacted",
apex_item.textarea(30,my_comment,5,80) as "Comment"
from my_table

Based on the above SQL, assume


this SQL query returns 10 rows. Now
using checkbox as my driving id, I tick
the checkbox of all odd records/rows,
i.e. rows 1,3,5,7,9 and for each of
these rows, I also enter a date value
(f20) together with a comment (f30)

Keeping this in mind, I then want to


created a page process that is called
when the user presses the "Save"
button that will iterate through these
checked rows and store for each
record, my date and my comment but
only for the rows that I have selected.

So based on the above, I would


expect to have 5 news rows in my
table with the following columns:

ID MY_DATE MY_COMMENT
1 26/08/2012 Comment A
3 27/08/2012 Comment B
5 28/08/2012 Comment C
7 29/08/2012 Comment D
9 30/08/2012 Comment E

By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our
Unfortunately I am unsure how to
Terms of Service.
achieve this using

https://stackoverflow.com/questions/12142143/understanding-oracle-apex-application-g-fnn-and-how-to-use-it 1/4
12/6/2018 sql - Understanding Oracle Apex_Application.G_Fnn and how to use it - Stack Overflow

apex_application.G_F10.COUNT .

I want to be able to access the


content of each of these array
elements (f20) and f(f30) for each row
that I have ticked the checkbox with.

Is this possible or have I


misunderstood how
apex_application.G_Fnn works? If
this is not possible, how I can achieve
this? Do I need a tabular report?

sql oracle11g oracle-apex

edited Aug 26 at 22:24


halfer
14.2k 7 58 106

asked Aug 27 '12 at 12:39


tonyf
12.3k 36 114 186

Tonsils, your new question


stackoverflow.com/q/12163564/81404
8 made me realize i made a very
stupid mistake in my code. I amended
my answer. Sorry about that. – Tom
Aug 29 '12 at 7:30

Hi Tom - no problems. Appreciate that


you amended your answer, also much
clearer now. I will keep this mind when
I need to use a checbox scenario
again. BTW, does this amended
answer relate to a tabular SQL
Updateable SQL report or just a
standard report? – tonyf Aug 29 '12
at 14:27

Depends what you mean with


standard report! For a tabular form:
definitely yes since that is the kind
we're working with here. – Tom Aug
29 '12 at 15:13

1 Answer

You're very close.

select apex_item.checkbox2(10, empno)


apex_item.text(20, empno) empno,
apex_item.text(30, ename)||apex_item.h
from emp

I'm concatenating the hidden item


since i don't want it in its own column.
Messes with the layout.
Also, the hidden item is there
because of how checkboxes work.
By using our site, you acknowledge that you have read and understand our , , and our
Checkboxes only submit their values
.
for checked items. This would mean

https://stackoverflow.com/questions/12142143/understanding-oracle-apex-application-g-fnn-and-how-to-use-it 2/4
12/6/2018 sql - Understanding Oracle Apex_Application.G_Fnn and how to use it - Stack Overflow

that array 10 has 3 values. The other


arrays would still contain the values
for all rows.
This is why i added the hidden empno
again: so we can match the checked
values to the other rows.

On submit process:

DECLARE
v_empno emp.empno%TYPE;
v_ename emp.ename%TYPE;
BEGIN
--f10: checkbox
--f20: empno
--f30: ename
--f50: empno again
for i in 1..apex_application.g_f10.
loop
for j in 1..apex_application.g_f
if apex_application.g_f10(i)
then
-- access values for the s
v_empno := apex_applicatio
v_ename := apex_applicatio

apex_debug_message.log_mes
end if;
end loop;
end loop;
END;

Run page, enable debug, select


records 2, 4 and 6, submit.

Debug output:

All you now need to do is put your


processing in that loop.

edited Aug 29 '12 at 7:28

answered Aug 27 '12 at 13:10


By using our site, you acknowledge that you have read and understand our , , and our
Tom
. 6,160 1 19 36

https://stackoverflow.com/questions/12142143/understanding-oracle-apex-application-g-fnn-and-how-to-use-it 3/4
12/6/2018 sql - Understanding Oracle Apex_Application.G_Fnn and how to use it - Stack Overflow

Thanks again Tom but just want to


confirm something and may throw a
spanner in the works, but with regards
to f20 and f30, assume f20 is a date
field that a user actually types in and
not from a database table column,
together with f30, which is a textarea
field that a user can enter a comment
in and again is not from a database
table column. Will your processing still
work for this scenario or are changes
required? – tonyf Aug 27 '12 at
13:31

It depends on what you mean actually:


if you plan on using the standard
multi-row processing that you'd use
for a standard tabular form: you can't.
Also, with manual tabular forms you
can't have tabular form validations
(declared ones in the validations
processing point). You also do not get
checksumming and optimal locking,
which are important in systems with
concurrent users. – Tom Aug 27 '12 at
13:47

Oh and hey, you could use


apex_item.date_popup2 for a date
field! – Tom Aug 27 '12 at 13:54

So Tom, based on what you have


stated, how would you go about doing
what I am after for f20 and f30 fields
which are manually entered? Would
you use an apex_collection to store
these fields or some other means?
Thanks. – tonyf Aug 27 '12 at 13:59

It of course depends on your specs


what you could and may do or where
there is some wiggle-room. If you'd
stay this course you'll need to write
validation for these fields, no way
around that. The dates could be a
pain though. Using a datepicker might
alleviate, but you'll still need to do a
TO_DATE somewhere and process
the error, and output them. Same for
the textarea. I'd advise processing
these in a seperate process than your
actual updating. Abort processing
when a validation error occurs. – Tom
Aug 27 '12 at 14:20

By using our site, you acknowledge that you have read and understand our , , and our
.

https://stackoverflow.com/questions/12142143/understanding-oracle-apex-application-g-fnn-and-how-to-use-it 4/4

Anda mungkin juga menyukai