Create procedure myprocinout with an IN/OUT parameter named x - Java JDBC

Java examples for JDBC:Stored Procedure

Description

Create procedure myprocinout with an IN/OUT parameter named x

Demo Code


import java.sql.Connection;
import java.sql.Statement;

public class Main {
  public static void main(String[] args) throws Exception{
    Connection connection = null;
    Statement stmt = connection.createStatement();

    String procedure =/*from ww  w.  jav a  2 s  .  c o m*/
        "CREATE OR REPLACE PROCEDURE myprocinout(x IN OUT VARCHAR) IS "
        + "BEGIN "
        + "INSERT INTO oracle_table VALUES(x); " // Use x as IN parameter
        + "x := 'outvalue'; "                    // Use x as OUT parameter
        + "END;";
    stmt.executeUpdate(procedure);

  }
}

Related Tutorials