Oracle Stored Procedure Getting Started Example

create or replace procedure testPro(
  invalue in varchar2,--input variable
  outvalue out varchar2--output variable
)
as
  counts number;--temporary variable
  testvalue varchar2(40) :='no data';--temporary variable
begin
  select count(*) into counts from base_user where ID = invalue;-- first query the number of data records to be checked, and return the number to a temporary variable
  if counts = 0 then -- determine whether there is data
    outvalue := 'No data';--If it does not exist, return a string with no data to the output variable
    --dbms_output.put_line('no data');
  else--If there is data, find out and return the name
    select name into testvalue from base_user where ID = invalue;
    outvalue: = testvalue;
  end if;
end testPro;
 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326776582&siteId=291194637