ORA-00913 error: PL/SQL: ORA-00913: too values

Source: Internet
Author: User

ORA-00913 error.


Description: PL/SQL: ORA-00913: too partition values


Objective: To compile a script that can insert data cyclically.


Procedure: SQL> desc tcustmer
Name Null? Type
-----------------------------------------------------
CUST_CODE not null VARCHAR2 (10)
NAME VARCHAR2 (30)
CITY VARCHAR2 (20)
State char (2)


SQL> CREATE SEQUENCE tcustmer_cust
Increment by 1
Start with 1
Max value 100000000
Caching 10000
NOCYCLE;

SQL> begin
2 for I in 1 .. 10 loop
3 insert into tcustmer
4 values (tcustmer_cust.nextval, 't', 'test' | I, 'beijing', 'cn ');
5 if mod (I, 10) = 0 then
6 commit;
7 end if;
8 end loop;
9 commit;
10 end;
11/
Insert into tcustmer
*
ERROR at line 3:
ORA-06550: line 3, column 20:
PL/SQL: ORA-00913: too then values
ORA-06550: line 3, column 8:
PL/SQL: SQL Statement ignored


Check the inserted values value. The number of columns exceeds the number of columns in the tcustmer table.
The adjustment is as follows:
SQL> begin
For I in 1 .. 10 loop
Insert into tcustmer
Values ('T' | tcustmer_cust.nextval, 'test' | I, 'beijing', 'cn ');
If mod (I, 10) = 0 then
Commit;
End if;
End loop;
Commit;
End;
/
PL/SQL procedure successfully completed.
Summary:

Incorrect understanding of tcustmer_cust.nextval. The purpose of creating a sequence is to eliminate primary key interference. Therefore, you need to put it in the column value when using it.



Related Article

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.