Luo Hao

Oracle——存储过程及函数写法

Rehoni / 2020-09-01


Oracle的插入存储过程实现

  create or replace procedure insert_by_tablename(tableName in varchar2,
                                     sortId in number,
                                     flId in varchar2,
                                     flName in varchar2,
                                     flCode in varchar2,
                                     vindicateOid in varchar2,
                                     baseVoltageId in varchar2,
                                     flLongitude in number,
                                     flLatitude in number,
                                     fullPath in varchar2,
                                     runManageOid in varchar2)
  as
      dynamic_insert_sql varchar2(1000);
  begin
      dynamic_insert_sql := 'insert into ' || tableName ||
                            '(ID,FL_NAME,FL_CODE,VINDICATE_OID,SORT_ID,BASE_VOLTAGE_ID,LONGITUDE,LATITUDE,FULL_PATH,RUNMANAG_OID)' ||
                             ' values (:1,:2,:3,:4,:5,:6,:7,:8,:9,:10)';
      execute immediate dynamic_insert_sql using flId,flName,flCode,vindicateOid,sortId,baseVoltageId,flLongitude,flLatitude,fullPath,runManageOid;
      commit;
  end insert_by_tablename;