Home » Developer & Programmer » Forms » problem in print record at block level (Form 10g)
problem in print record at block level [message #583456] Wed, 01 May 2013 05:06 Go to next message
irfankundi786@yahoo.com
Messages: 205
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 #583465 is a reply to message #583456] Wed, 01 May 2013 06:19 Go to previous messageGo to next message
cookiemonster
Messages: 10573
Registered: September 2008
Location: Rainy Manchester
Senior Member
How many times is it executed?
What is v_cur_record set to?
Why have you got an exit statement in a for loop?

Re: problem in print record at block level [message #583469 is a reply to message #583465] Wed, 01 May 2013 07:40 Go to previous messageGo to next message
irfankundi786@yahoo.com
Messages: 205
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 #583470 is a reply to message #583469] Wed, 01 May 2013 07:51 Go to previous messageGo to next message
cookiemonster
Messages: 10573
Registered: September 2008
Location: Rainy Manchester
Senior Member
So according to the above the loop will iterate 3 times. You seem to be saying it's doing something else.
So what is it doing? It's really difficult to fix code when you don't know what's going wrong.
Re: problem in print record at block level [message #583472 is a reply to message #583470] Wed, 01 May 2013 07:55 Go to previous messageGo to next message
irfankundi786@yahoo.com
Messages: 205
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 Go to previous messageGo to next message
cookiemonster
Messages: 10573
Registered: September 2008
Location: Rainy Manchester
Senior Member
irfankundi786@yahoo.com wrote on Wed, 01 May 2013 13:55
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....


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 Go to previous messageGo to next message
irfankundi786@yahoo.com
Messages: 205
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 Go to previous messageGo to next message
cookiemonster
Messages: 10573
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 #583484 is a reply to message #583483] Wed, 01 May 2013 10:05 Go to previous messageGo to next message
irfankundi786@yahoo.com
Messages: 205
Registered: February 2009
Location: pakistan
Senior Member

please explain with example how i can use when-new-record-instance to post in db...can't uderstand..please explain..???
as i said that i create record in block
Re: problem in print record at block level [message #583485 is a reply to message #583484] Wed, 01 May 2013 10:21 Go to previous messageGo to next message
cookiemonster
Messages: 10573
Registered: September 2008
Location: Rainy Manchester
Senior Member
read up on the post command in form builder help
Re: problem in print record at block level [message #583486 is a reply to message #583484] Wed, 01 May 2013 10:26 Go to previous messageGo to next message
Littlefoot
Messages: 18833
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
"Post" is a command, just like "commit" or any other. It means that WHEN-NEW-RECORD-INSTANCE trigger is supposed to look like this:
post;
It will save form records into the table, but won't commit them (which means that if you, finally, do not COMMIT, these changes will be lost).
Re: problem in print record at block level [message #583506 is a reply to message #583486] Wed, 01 May 2013 12:02 Go to previous messageGo to next message
irfankundi786@yahoo.com
Messages: 205
Registered: February 2009
Location: pakistan
Senior Member

it means that if created the three record and at post these record at when-new-record-instance then after the fourth record created and at when-validate trigger it can be checked for the duplicate
Re: problem in print record at block level [message #583507 is a reply to message #583506] Wed, 01 May 2013 12:13 Go to previous messageGo to next message
Littlefoot
Messages: 18833
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Yes. Using the SELECT statement, as Cookiemonster explained.
Re: problem in print record at block level [message #583509 is a reply to message #583507] Wed, 01 May 2013 12:19 Go to previous messageGo to next message
irfankundi786@yahoo.com
Messages: 205
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 #583511 is a reply to message #583509] Wed, 01 May 2013 12:30 Go to previous messageGo to next message
Littlefoot
Messages: 18833
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
As of code you posted: shouldn't you find a "number of records" using COUNT function? The way you wrote it, there's danger of failing with NO-DATA-FOUND or TOO-MANY-ROWS. Although you (sort of) handled it with WHEN OTHERS, you'd probably want to avoid it.

As of the rest of your message: sorry, I don't understand what you are saying.
Re: problem in print record at block level [message #583512 is a reply to message #583511] Wed, 01 May 2013 12:34 Go to previous messageGo to next message
irfankundi786@yahoo.com
Messages: 205
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 #583514 is a reply to message #583512] Wed, 01 May 2013 12:39 Go to previous messageGo to next message
Littlefoot
Messages: 18833
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Code you posted seems to be close to the solution; did you try with COUNT?
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;
Re: problem in print record at block level [message #583516 is a reply to message #583514] Wed, 01 May 2013 12:46 Go to previous messageGo to next message
irfankundi786@yahoo.com
Messages: 205
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 #583518 is a reply to message #583516] Wed, 01 May 2013 12:53 Go to previous messageGo to next message
Littlefoot
Messages: 18833
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Did you POST first? Perhaps you should run the form in debug mode, trace its execution and see what's going on.
Re: problem in print record at block level [message #583519 is a reply to message #583518] Wed, 01 May 2013 12:56 Go to previous messageGo to next message
irfankundi786@yahoo.com
Messages: 205
Registered: February 2009
Location: pakistan
Senior Member

no debug mode...
yes i have post in when-new-record-instance...
but??
Re: problem in print record at block level [message #583521 is a reply to message #583519] Wed, 01 May 2013 13:05 Go to previous messageGo to next message
Littlefoot
Messages: 18833
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
How do you mean, no debug mode? You use Forms 10g, don't you? That's what information you posted when opening the topic suggests.
Re: problem in print record at block level [message #583523 is a reply to message #583519] Wed, 01 May 2013 13:10 Go to previous messageGo to next message
irfankundi786@yahoo.com
Messages: 205
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 #583525 is a reply to message #583523] Wed, 01 May 2013 13:17 Go to previous messageGo to next message
Littlefoot
Messages: 18833
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Do you know how to use debug mode?

SELECT sees data that already exists in a table (obviously, committed previously) as well as posted data (you just posted).
Re: problem in print record at block level [message #583565 is a reply to message #583525] Wed, 01 May 2013 17:20 Go to previous messageGo to next message
cookiemonster
Messages: 10573
Registered: September 2008
Location: Rainy Manchester
Senior Member
If you're checking if the value already exists you should be checking if the count is greater than 0 not 1.
If it's greater than 1 then a duplicate has already been posted to the DB, you want to avoid that.
Re: problem in print record at block level [message #583639 is a reply to message #583565] Thu, 02 May 2013 10:41 Go to previous messageGo to next message
irfankundi786@yahoo.com
Messages: 205
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 Go to previous message
cookiemonster
Messages: 10573
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.


Previous Topic: call a form from a multi record field (merged 2)
Next Topic: foms 6i - getting ora-00928 missing select keyword ora-06512 at"package.procedure_name" at line
Goto Forum:
  


Current Time: Sun Apr 20 11:27:32 CDT 2014

Total time taken to generate the page: 0.11294 seconds