A certain job needs to write a stored procedure, record the general usage
Note: variable assignment requires variable name + type, variable assignment can use variable name: = ** or select id into variable name from table name
create
or replace procedure insertUser
as
id VARCHAR(32); --If you don't want to create a process, you can directly use DECLARE id VARCHAR(32);, it will directly execute
begin
for person in (select * from T_PERSON) loop --Start the loop for variable name in (loop statement ) loop
if ( person.age>0) then --conditional judgment
select LOWER(rawtohex(sys_guid())) into id from dual; --assign value to id, select LOWER(rawtohex(sys_guid())) from dual; this The statement will generate a lowercase 32-bit uuid
insert into BIZ_USER( ** ) VALUES( **); --insert statement
end if; --end condition If there is still can continue if end if;
end loop; --end loop
commit;
end;
--implement
begin insertinsertUser();
end;
In the middle, there was a problem due to the large amount of data, that is, the age was not declared. It is correct that the statement can be executed several times, and this problem will occur when it is executed again. After querying, it is found that the temporary table space is full.
Then I used the simplest and rude method, just restart the database, there should be a better way.
The following is Windows to restart the Oracle database.
1. Close the database: win+r, enter the following code to stop:
set ORACLE_SID=SID_Name, press Enter.
sqlplus /nolog
SQL> connect / as sysdba
SQL> shutdown immediate
SQL> exit
2. Start the database: win+r, enter the following code to start:
set ORACLE_SID=your database SID name
sqlplus /nolog
SQL> connect / as sysdba
SQL> startup
SQL> exit
--show pdbs;
--alter pluggable database all open;