problem in print record at block level [message #583456] |
Wed, 01 May 2013 05:06 |
irfankundi786@yahoo.com
Messages: 269 Registered: February 2009 Location: pakistan
|
Senior Member |
|
|
hi expert
i have problem i want to to display in message all the values of block in for example when i create the fourth record the three already records are show in message..actually first i want to in message than i would populate pl/sql table.
the code is at block leve when-new-reocord-instance
************************************************************
declare
v_record number :=1 ;
v_cur_record number;
begin
v_cur_record :=:system.cursor_record;
Message('system cursor record iss...'||v_cur_record);
pause;
for i in 1..v_cur_record-1 loop
go_record(v_record);
message('curosor loop is :'||i);
message('task desc :'||:TXT_TASK_DESC);
exit when :system.last_record='True';
v_record := v_record + 1;
end loop;
end;
**************************************************************
actually in block there are three record and this message should be display for the three time but the loop is executed more time....
|
|
|
|
Re: problem in print record at block level [message #583469 is a reply to message #583465] |
Wed, 01 May 2013 07:40 |
irfankundi786@yahoo.com
Messages: 269 Registered: February 2009 Location: pakistan
|
Senior Member |
|
|
there are three record in block ..so it should be executed three time and display in message the task_desc of each record.
v_cur_record is the variable to set the for loop to executed ..for example if i create for the new record that is fourth record then
v-cur_record=4-1=3
for i in 1...3 loop
Now??????
if further explaination need please reply
|
|
|
|
Re: problem in print record at block level [message #583472 is a reply to message #583470] |
Wed, 01 May 2013 07:55 |
irfankundi786@yahoo.com
Messages: 269 Registered: February 2009 Location: pakistan
|
Senior Member |
|
|
the problem is when created the fourth record..the one problem is when loop is existed the cursor is located on third last record ..
not the fourth record create ...my first problem
the next one is the loop is executed for the three time and then start for twice start....
|
|
|
Re: problem in print record at block level [message #583473 is a reply to message #583472] |
Wed, 01 May 2013 08:01 |
cookiemonster
Messages: 13963 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
irfankundi786@yahoo.com wrote on Wed, 01 May 2013 13:55the problem is when created the fourth record..the one problem is when loop is existed the cursor is located on third last record ..
not the fourth record create ...my first problem
the next one is the loop is executed for the three time and then start for twice start....
Well the main problem is that you shouldn't be trying to do this code in when-new-record-instance.
Guess what happens when you use go_record to go to a different record? It fires when-new-record-instance again.
What are trying to achieve with this code?
|
|
|
Re: problem in print record at block level [message #583482 is a reply to message #583473] |
Wed, 01 May 2013 09:13 |
irfankundi786@yahoo.com
Messages: 269 Registered: February 2009 Location: pakistan
|
Senior Member |
|
|
ok...your means that at each record it is executed...suppose it is then this code should be executed for
first record it should
for i in 1..1
for the 2nd record it should be executed
for i in 1..2
for the 3rd record it shoud be executed
for i in 1..3
but the problem it should created the fourth record but it did't???
now i actually i want to print all the record task_desc then i populated this in pl/sql table then after population i will check
each pl/sql table task_desc with the new record create desc and if the desc is already in table then message should display for the duplication task....
thats why first i display the task_desc through message then i will populated the table...
|
|
|
Re: problem in print record at block level [message #583483 is a reply to message #583482] |
Wed, 01 May 2013 09:51 |
cookiemonster
Messages: 13963 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
You're doing all this to check for duplicates?
Stop that.
Use the when-new-record-instance to issue a post command, this will apply any new/changed records to the DB, without committing them.
Then use a select statement in the appropriate when-validate trigger to check for duplicates.
I never use pl/sql arrays for this.
|
|
|
|
|
|
|
|
Re: problem in print record at block level [message #583509 is a reply to message #583507] |
Wed, 01 May 2013 12:19 |
irfankundi786@yahoo.com
Messages: 269 Registered: February 2009 Location: pakistan
|
Senior Member |
|
|
i have doing what u asked as post in when-new-record-instance then
this code is at when-validate-item in task-desc field
#####################
declare
v_count number;
begin
select mt.task_no into v_count from TASK_MT mt
where mt.task_no =:TXT_TASK_NO;
message('count is '||v_count);
if v_count >0 then
Message('this record is already existed....');
Raise form_trigger_failure;
end if;
exception
when others then
Message('Exception..'||dbms_error_text);
end;3
now some two record is commited in database if now i create third and fourth record then the fourth record is validated from commited as well the post record that is not still commited in database..
like i have two record....
task-0001
task-0002
and third record is
task-0001
whether this record is validated
|
|
|
|
Re: problem in print record at block level [message #583512 is a reply to message #583511] |
Wed, 01 May 2013 12:34 |
irfankundi786@yahoo.com
Messages: 269 Registered: February 2009 Location: pakistan
|
Senior Member |
|
|
i have at some no-data-found exception ...
and some case i have too-many-rows exception raise..
your are right...
but give me the solution..i have write the select statement to check whether the task is already entered or not....
if select count > 0 means record is existed...
if not then this mean this record is not existed
The rest of message will explain in next post.
please give me the solution
|
|
|
|
Re: problem in print record at block level [message #583516 is a reply to message #583514] |
Wed, 01 May 2013 12:46 |
irfankundi786@yahoo.com
Messages: 269 Registered: February 2009 Location: pakistan
|
Senior Member |
|
|
at when-validate-item of :txt_task-desc
----------------------------------------------
declare
v_count number;
begin
select mt.task_no into v_count from TASK_MT mt
where mt.task_no =:TXT_TASK_DESC;
message('count is '||v_count);
if v_count >1 then
Message('this record is already existed....');
Raise form_trigger_failure;
end if;
exception
when others then
Message('Exception..'||dbms_error_text);
end;
================================================================
i have two record entered like in
irfan
irfan
but still the no-data found exception raised.....
|
|
|
|
|
|
Re: problem in print record at block level [message #583523 is a reply to message #583519] |
Wed, 01 May 2013 13:10 |
irfankundi786@yahoo.com
Messages: 269 Registered: February 2009 Location: pakistan
|
Senior Member |
|
|
means that i run the form in debug mode ...nothing is happenend.no error...
one another thing whether the select statement i mention above check the posted and commited record or only check the posted recorded.
You see any error in code..
i have the POST key word in when-new-record-instance
|
|
|
|
|
Re: problem in print record at block level [message #583639 is a reply to message #583565] |
Thu, 02 May 2013 10:41 |
irfankundi786@yahoo.com
Messages: 269 Registered: February 2009 Location: pakistan
|
Senior Member |
|
|
sir the problem is not the 0,1 i have checked with both value.
but the result in acquired....
some time it return no data found some time more rows fetched...
whether is it possible what we are doing with the Post in When-new-record-instance and
then with item validate to check the duplicate recordssssss
|
|
|
Re: problem in print record at block level [message #583662 is a reply to message #583639] |
Thu, 02 May 2013 15:12 |
cookiemonster
Messages: 13963 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
Littlefoot's example code:
declare
l_count number;
begin
select count(*)
into l_count
from your_table
where some_column = ...
and ...
if l_count > 1 then
message(...);
raise form_trigger_failure;
end if;
end;
Your code:
begin
select mt.task_no into v_count from TASK_MT mt
where mt.task_no =:TXT_TASK_DESC;
message('count is '||v_count);
Littlefoot's code counts records that match what has been entered in the datablock. Your code obviously doesn't.
Your code will throw no_data_found when there are no matches in the db - when there are no duplicates. It'll find one or many rows when there are duplicates.
Make your code actually do what Littlefoot suggested and it'll work just fine.
|
|
|