Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE EMPLOYEE
- (
- "EMPLOYEE_NUMBER" VARCHAR2(20 BYTE),
- "EMPLOYEE_NAME" VARCHAR2(80 BYTE),
- "EMPLOYEE_DEPT" VARCHAR2(40 BYTE)
- );
- create or replace PACKAGE PKG_SP_EMPLOYEE
- AS
- TYPE tbl_employees_in
- IS
- TABLE OF EMPLOYEE%ROWTYPE INDEX BY PLS_INTEGER;
- PROCEDURE main(
- p_employee IN PKG_SP_EMPLOYEE.tbl_employees_in,
- x_status OUT VARCHAR
- );
- END PKG_SP_EMPLOYEE;
- create or replace PACKAGE BODY PKG_SP_EMPLOYEE
- AS
- PROCEDURE main(
- p_employee IN PKG_SP_EMPLOYEE.tbl_employees_in,
- x_status OUT VARCHAR
- )
- IS
- BEGIN
- FOR i in 1..p_employee.count
- loop
- INSERT INTO "EMPLOYEE"
- (
- EMPLOYEE_NUMBER,
- EMPLOYEE_NAME,
- EMPLOYEE_DEPT
- )
- VALUES (
- p_employee(i).EMPLOYEE_NUMBER,
- p_employee(i).EMPLOYEE_NAME,
- p_employee(i).EMPLOYEE_DEPT
- );
- end loop;
- dbms_output.put_line('Success');
- x_status := 'Success';
- EXCEPTION
- WHEN OTHERS THEN
- dbms_output.put_line('Failure');
- x_status := 'Failure';
- END main;
- END PKG_SP_EMPLOYEE;
- Connection con= null;
- OracleCallableStatement cstmt = null;
- try {
- Class.forName("oracle.jdbc.driver.OracleDriver");
- con=DriverManager.getConnection("jdbc:oracle:thin:@test.com:1521:TESTAD",
- "user","password");
- cstmt = (OracleCallableStatement)con.prepareCall (
- "begin PKG_SP_EMPLOYEE.MAIN (?,?); end;");
- String[] values = { "1", "John Doe", "HR" };
- cstmt.setPlsqlIndexTable (1, values, values.length, values.length, OracleTypes.VARCHAR, 3);
- cstmt.registerOutParameter(2, java.sql.Types.VARCHAR);
- cstmt.execute ();
- //...
- java.sql.SQLException: ORA-06550: line 1, column 7:
- PLS-00306: wrong number or types of arguments in call to 'MAIN'
- ORA-06550: line 1, column 43:
- **PLS-00418: array bind type must match PL/SQL table row type**
- ORA-06550: line 1, column 7:
- PL/SQL: Statement ignored
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement