< Prev - Examples - Next >

Binary Types

Binary types of 32-bit integer and floating point and 64-bit floating point are supported.

Example Description

PL/SQL Function

PL/SQL Function : BINARY_TYPES
create or replace function binary_types
(
  i_bin_float   in  binary_float, 
  i_bin_double  in  binary_double, 
  i_bin_integer in  binary_integer,
  o_bin_float   out binary_float,
  o_bin_double  out binary_double
)
return binary_integer
/**
 * Demo of binary type handling.
 * @param i_bin_float 32-bit floating point value.
 * @param i_bin_double 64-bit floating point value.
 * @param i_bin_integer 32-bit integer value.
 * @param o_bin_float 32-bit floating point value
 * @param o_bin_double  64-bit floating point value.
 * @return 32-bit integer
 */
is
begin
  o_bin_float := i_bin_float * 3.14159265359;
  o_bin_double := i_bin_double * 3.14159265359;
  return i_bin_integer * 3;
end binary_types;

Factory API : Calling the PL/SQL Function

Using the static factory to get the remote service.
Java Calling Class : BinaryTypesFactoryApi.java
package plsql_workbench_examples.factoryapi;

import factory.ExamplesRPCFactory;
import service.BinaryTypesService;
import transferobject.BinaryTypesTO;

public class BinaryTypesFactoryApi {
  public static void main(String[] args) {
    try {
      // getting the service
      BinaryTypesService service = ExamplesRPCFactory.getBinaryTypesService();

      // calling the stored procedure
      BinaryTypesTO binaryTypesTO = service.call(1f, 1d, 1);

      // print values
      System.out.format("%.12f   %.12f   %d%n",
                        binaryTypesTO.oBinFloat,
                        binaryTypesTO.oBinDouble,
                        binaryTypesTO.returnValue);
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }
}

Spring API : Calling the PL/SQL Function

Using Spring annotation to inject the service and call the remote service.
Java Calling Class : BinaryTypesSpringApi.java
package plsql_workbench_examples.springapi;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.stereotype.Component;

import service.BinaryTypesService;
import transferobject.BinaryTypesTO;

@Component
public class BinaryTypesSpringApi {
  @Autowired
  private BinaryTypesService binaryTypesService;

  public static void main(String[] args) {
    // Register Spring Beans, Spring Context and call demo method 
    try (GenericApplicationContext ctx = BaseSpringConfig.getCtx(BinaryTypesSpringApi.class)) {
      ctx.getBean(BinaryTypesSpringApi.class).runDemo();
    }
  }

  private void runDemo() {
    try {
      // calling the stored procedure
      BinaryTypesTO binaryTypesTO = binaryTypesService.call(1f, 1d, 1);

      // print values
      System.out.format("%.12f   %.12f   %d%n",
                        binaryTypesTO.getOBinFloat(),
                        binaryTypesTO.getOBinDouble(),
                        binaryTypesTO.getReturnValue());
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }
}

< Prev - Examples - Next >