Create table student (id varchar2 (5) primary key, name varchar2 (20) not null, sex char (2) check (sex = 'male' or sex = 'female ')) -- insert a piece of data into student and use a function to verify whether the insertion is correct. create or replace function student_insert_check (f_id in varchar2, f_name in varchar2, sex in varchar2) return varchar2 isc_id number; beginif f_id is null thenreturn ('student ID cannot be blank, records are not inserted successfully '); end if; if f_name is null return ('name cannot be blank, the record is not inserted successfully. '); end if; if sex! = 'Male' or sex! = 'Femal' return ('gender is limited to male or female, records are not inserted successfully. ') end if; insert into student values (f_id, f_name, sex); commit; -- SQL control transaction: The commit command is used to save the modifications made by the transaction to the database. It saves all the transactions after the previous COMMIT or ROLLBACK command to the database. Return ('record inserted successfully'); end dd; ========================================================== ========================================================== = create function average1 (@ cnum char (20 )) -- create a returns int function with parameters -- return an integer of the int type as begin declare @ aver int -- declare a @ aver variable select @ aver = -- query this variable (-- variable assignment select AVG (score) from xs_kc where course No. = @ cnumgroup by course No.) return @ aver -- return variable end go select dbo. average1 (101) -- use the previously created function average1