Create_record or Next_record cause FRM-40102 error: The record must first be entered or deleted

Source: Internet
Author: User

In a form development, you often encounter the need to create one or more pieces of data in a single block. First of all, we will first locate the last record (sometimes we will execute the query first: app_find.find (' block_name '), query out the required data and then make the last record positioning). The following syntax can be used to move the current record to the last record:

Go_block (' Block_name ');
First_record;
LOOP
EXIT When:system. Last_record = ' TRUE ';

Next_record; --do_key (' Next_record ');
END LOOP;
or by using:

[HTML]
View Plaincopyprint?
While TRUE LOOP
If:system. Last_record <> ' TRUE ' then
Next_record;
ELSE
EXIT;
END IF;
END LOOP;
After the record points to the last record in the block, you typically use a loop to start creating a new record:

[HTML]
View Plaincopyprint?
For Kpi_rec in Kpi_cur LOOP
Create_record;
--Assigning a value to an item in a block
END LOOP;
Note: You can also use Next_record instead of Create_record. Create_record creates a new record below the current record, and then navigates to this record, and if Next_record is the last record, it will automatically create a record.

It is no problem to create a new record in this way, but if you create two records consecutively, the form will report: FRM-40102: The record must first be entered or deleted. That is, the status of the last record is problematic, but where is the problem?

After many tests, it is not difficult to find: if there is already a record in the block, then using the above code will not report the error, but if the block is originally empty, is a new block, then use the above code to deal with, when creating a second record will be reported error.

So as long as the first record is processed, this problem can be solved. The method used is to add a judgment in the loop, and if it is a new record, it is assigned directly without executing the CREATE_RECORD statement (although execution does not appear to be an error).

Here's an example:

[HTML]
View Plaincopyprint?
IF:EVALUATION_LINE.kpi_code is null and– determines whether the record is empty
: Evaluation_line.meaning is NULL then
: Evaluation_line.kpi_code: = kpi_rec.lookup_code;--Perform Assignment
: evaluation_line.meaning: = kpi_rec.meaning;
ELSE
Create_record; --No person creates a new record, assigns a value
: evaluation_line.kpi_code: = Kpi_rec.lookup_code;
: evaluation_line.meaning: = kpi_rec.meaning;
END IF;

Create_record or Next_record cause FRM-40102 error: The record must first be entered or deleted

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.