Using PL/SQL


  1. Make Sure Your Oracle Environment Is Set Correctly.
  2. That is you can connect to Oracle database via SQL*Plus. Check the Using Oracle .

  3. Write a PL/SQL Program.
  4. Check an example MyPLSQL.sql.

  5. There Are Two Ways to Execute a PL/SQL Program:

    • Execute the Program under the SQL*Plus Environment:
      For example,
         shell> sqlplus C##user.id/password@//65.52.222.73:1521/cdb1 - 
                  @MyPLSQL.sql 

    • Embed PL/SQL Blocks in a Program such as JDBC and Pro*C/C++.
      The JDBC or Pro*C/C++ precompiler treats a PL/SQL block like a single embedded SQL statement. Therefore, you can place a PL/SQL block anywhere in a program that you can place an SQL statement. For example, use the following two steps to execute a JDBC program with PL/SQL blocks, MyJDBC.java:
         shell> /usr/bin/javac MyJDBC.java 
         shell> /usr/bin/java  MyJDBC