Discussions
Categories
- 197K All Categories
- 2.5K Data
- 546 Big Data Appliance
- 1.9K Data Science
- 450.8K Databases
- 221.9K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 552 MySQL Community Space
- 479 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.1K ORDS, SODA & JSON in the Database
- 556 SQLcl
- 4K SQL Developer Data Modeler
- 187.2K SQL & PL/SQL
- 21.4K SQL Developer
- 296.4K Development
- 17 Developer Projects
- 139 Programming Languages
- 293.1K Development Tools
- 110 DevOps
- 3.1K QA/Testing
- 646.1K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 161 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.2K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 19 Java Essentials
- 162 Java 8 Questions
- 86K Java Programming
- 81 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 205 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 475 LiveLabs
- 39 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 175 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 233 Portuguese
master/detail: validation
Hello all,
let's say I have a master-detail form, displaying recipes as master, and ingredients as detail. Let's say I'm only allowed to mark a recipe as "Low-Calories" if it doesn't contain ingredients A, B, or C.
What trigger would you use? and how do you browse the uncommitted ingredients list programatically to check for presence of A, B, or C?
EXAMPLE
Recipe ____________________ Type
=====================================
John's Breakfast ____________ Standard
Jim's Lunch ________________ Low-Calories
=====================================
(Sorry don't know how to use a monospaced font)
The user edits John's breakfast and marks it standard, and then goes to the ingredients list, and deletes any records for A, B, and C; and later goes back to the recipe master record and wants to replace the "Standard" value with "Low-Calories" value. This should be allowed only after ensuring that no A, B, or C are found in the detail records.
Thanks for your help and tips!
Edited by: user2339825 on Sep 2, 2009 2:24 PM
let's say I have a master-detail form, displaying recipes as master, and ingredients as detail. Let's say I'm only allowed to mark a recipe as "Low-Calories" if it doesn't contain ingredients A, B, or C.
What trigger would you use? and how do you browse the uncommitted ingredients list programatically to check for presence of A, B, or C?
EXAMPLE
Recipe ____________________ Type
=====================================
John's Breakfast ____________ Standard
Jim's Lunch ________________ Low-Calories
=====================================
(Sorry don't know how to use a monospaced font)
The user edits John's breakfast and marks it standard, and then goes to the ingredients list, and deletes any records for A, B, and C; and later goes back to the recipe master record and wants to replace the "Standard" value with "Low-Calories" value. This should be allowed only after ensuring that no A, B, or C are found in the detail records.
Thanks for your help and tips!
Edited by: user2339825 on Sep 2, 2009 2:24 PM
Tagged:
Best Answer
-
Hi!
you mean from first-record to last-record ...declare l_cur_rec pls_integer := :system.cursor_record; begin first_record; loop if your_condition_check then your_action; end if; if :system.last_record = 'TRUE' then exit: end if; next_record; end loop; go_record ( l_cur_rec ); end;
btw: monospace with {noformat}text
{noformat}
Answers
-
Hi,
You can solve this in two ways:
Let's say that type is on the list item. In the trigger when-list-changed you can check this:
1. Go to the details block. Go through all the records and check ingredients.
2. Make query and check ingredients (but it needs to use "post" after each operation on details block).
Regards
Jakub -
1. Go to the details block. Go through all the records and check ingredients.Yes, that's what I need to do. Any hints on syntax? how do I go from first...last item in the detail block?
Thanks in advance! -
If your "low calories" marker-item is a checkbox or a poplist, you can use either the WHEN-CHECKBOX-CHECKED-trigger or the WHEN-LIST-CHANGED-trigger and do something like:
DECLARE bABCFound BOOLEAN:=FALSE; BEGIN GO_BLOCK('DETAIL'); FIRST_RECORD; LOOP EXIT WHEN :SYSTEM.RECORD_STATUS='NEW'; IF :DETAIL.TYPE IN ('A','B', 'C') THEN bABCFound:=TRUE; EXIT; END IF; EXIT WHEN :SySTEM.LAST_RECORD='TRUE'; NEXT_RECORD; END LOOP; IF bABCFound THEN -- Do whatever you want here END IF; END;
-
Hi!
you mean from first-record to last-record ...declare l_cur_rec pls_integer := :system.cursor_record; begin first_record; loop if your_condition_check then your_action; end if; if :system.last_record = 'TRUE' then exit: end if; next_record; end loop; go_record ( l_cur_rec ); end;
btw: monospace with {noformat}text
{noformat} -
thanks guys. i wanted to mark both answers as correct but it wouldn't let me.
cheers -
Thanks!
Andreas was more detailed, so he is more correct, i think ...
But anyway, he has enough ...
Regards
This discussion has been closed.