OracleORA-01451: columns to be modified to NULL cannot be modified to NULL

Source: Internet
Author: User
After debugging a program, if the problem occurs, you can check the information and find that Oracle does not allow you to change the NULL field to the NULL field. I had to make a judgment before the modification. Open PLSQL, such

After debugging a program, if the problem occurs, you can check the information and find that Oracle does not allow you to change the NULL field to the NULL field. I had to make a judgment before the modification. Open PL/SQL, such

After debugging a program, if the problem occurs, you can check the information and find that Oracle does not allow you to change the NULL field to the NULL field. I had to make a judgment before the modification.
Open PL/SQL and write the following code:
Declare
Visnull varchar2 (4 );
Begin
Select nullable into visnull from user_tab_columns
Where table_name = upper ('tblstockinspect ')
And column_name = upper ('fdepartid ');
If visnull = 'n' then
Alter table tblStockInspect modify FDepartID int null;
End if;
End;

Run, and the following error message appears:
---------------------------------------------------------------------------
ORA-06550: 8th rows, 7th columns:
PLS-00103: The symbol "ALTER" appears when one of the following is required:
(Begin case declare exit
For goto if loop mod null pragma raise return select update
While
<
Continue close current delete fetch lock insert open rollback
Savepoint set SQL execute commit forall merge pipe purge
---------------------------------------------------------------------------------
After careful consideration, the original alter statement cannot be run directly in PL/SQL, so you have to change it as follows:
Declare
Visnull varchar2 (4 );
Begin
Select nullable into visnull from user_tab_columns
Where table_name = upper ('tblstockinspect ')
And column_name = upper ('fdepartid ');
If visnull = 'n' then
Execute immediate 'alter table tblStockInspect modify FDepartID int null ';
End if;
End;
Run through

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.