Need help with Multi-Block procedure [message #307715] |
Wed, 19 March 2008 11:54  |
solisdeveloper
Messages: 48 Registered: March 2008 Location: Mexico
|
Member |
|
|
Hi everyone:
I realy could use your help guys, so here's my situation:
I have 2 data blocks "blk_newusers" and "blk_oldusers" they both have the same items and data types and I'm trying to make a procedure to validate that there are no null items, but i want to make it in a way that i can use the same procedure for both blocks.
What i did was to create a procedure to wich I'm sending a string with the name of the block.
This is what I'm sending:
pr_validate_null_items (':blk_newusers');
And this is what my code looks like:
PROCEDURE pr_validate_null_items(p_block VARCHAR2)IS
BEGIN
IF p_block || '.it_username' IS NULL THEN
message ('The user name is null');
RAISE form_trigger_failure;
END IF;
END;
But when I run it, it simply does nothing, it seems like forms is actualy trying to check if the string ":blk_newusers.it_username" IS NULL, wich is obviously not
What am I doing wrong?
Can u help me?
|
|
|
|
Re: Need help with Multi-Block procedure [message #307760 is a reply to message #307753] |
Wed, 19 March 2008 17:26   |
solisdeveloper
Messages: 48 Registered: March 2008 Location: Mexico
|
Member |
|
|
Hum...Ok I apreaciate the help LittleFoot, but nevermind the not null validation, that's not what worries me, the thing is that in my form I'll be constantly runing procedures in both data-blocks and instead of making two diferent procedures with the very same functionality, but with the only diference being the name of the data-block, I'd rather make 1 generic procedure that receives the name of the block and then do all due validations necesary.
So my question is how can I do the following IF statements like the ones below? This is how my code looks like but when I run my form it's not working, I'm obviously doing something wrong when i concatenate the block and field I guess, because Forms simply ignores them:
(p_block is a varchar2 variable containing the name of the block that i need to validate dinamically)
PR_VALIDATE_USER (p_block VARCHAR2) IS
BEGIN
IF p_block || '.it_age' > 30 THEN
p_block || '.it_category' := 2;
END IF;
IF p_block || '.it_haschilden' = 'YES' THEN
set_item_property(p_block || '.it_numberofchildren',ENABLED, property_true);
next_item;
END IF;
END;
In a few words, my questions is:
How can I concatenate a varchar2 variable containing the name of a block, to the name of an Item in order to evaluate the value that the item contains by using an IF statement?
Thanks i really need the help on this.
|
|
|
|
|
|
|
Re: Need help with Multi-Block procedure [message #307980 is a reply to message #307782] |
Thu, 20 March 2008 11:45  |
solisdeveloper
Messages: 48 Registered: March 2008 Location: Mexico
|
Member |
|
|
Hi everyone:
Well I finally solved it with a little help from a friend who reminded me of a Built-In that came out to be quiet useful.
My problem was that when I tried this: IF p_block || 'it_haschildren' = 'YES'... Forms was actually trying to compare the two Strings ":blk_newusers.it_haschildren" and "YES" instead of retreiving the value contained in :blk_newusers.it_haschildren and then compare it whith "YES"
This is how my code looks like and it works perfectly for any given Form in wich I may want to validate my user's data.
PR_VALIDATE_USER (p_block VARCHAR2) IS
BEGIN
:GLOBAL.valueof := NAME_IN(':' || p_block || '.it_haschilden');
IF :GLOBAL.valueof = 'YES' THEN
set_item_property(':' || p_block || '.it_numberofchildren',ENABLED, property_true);
next_item;
END IF;
END;
So now I can use this procedure everytime I want to validate the item it_haschildren, no matter what form I'm working on or the name of the block that I'm using.
I thought about posting it in case somebody was trying the same. Thanks for all your help and advices.
Regards!
|
|
|