关闭

Oracle自定义函数

发表于:2009-9-25 10:57

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:未知    来源:网络转载

  判断任务过期时间:

  create or replace function GetUrgentState(m_TaskID   varchar2,
  m_SendTime date,
  m_flag     varchar2)
  return varchar2 IS
  myDate     date;
  ExpireTime date;
  strsql     varchar2(200);
  begin
  myDate := m_SendTime;
  strsql := 'select max(EXPIRETIME) from t_wf_supervise where TASKID =''' ||
  m_TaskID || '''';
  execute immediate strsql
  into ExpireTime;
  --没有到期时间 就是正常状态
  if ExpireTime is null then
  if m_flag = 'String' then
  return '正常';
  end if;
  if m_flag = 'Img' then
  return 'cb_execute.gif';
  end if;
  end if;
  --未发送任务,就是判断当前时间
  if m_SendTime is null then
  myDate := sysdate;
  end if;
  if ExpireTime < myDate then
  if m_flag = 'String' then
  return '超期';
  end if;
  if m_flag = 'Img' then
  return 'cb_limit.gif';
  end if;
  end if;
  --小于3天的任务预警
  if ExpireTime - myDate < 3 then
  if m_flag = 'String' then
  return '预警';
  end if;
  if m_flag = 'Img' then
  return 'cb_warning.gif';
  end if;
  else
  if m_flag = 'String' then
  return '正常';
  end if;
  if m_flag = 'Img' then
  return 'cb_execute.gif';
  end if;
  end if;
  end;

  查询其它表数据:

  create or replace function GetPreNode(m_PreTaskID varchar2) return varchar2 IS
  nodename varchar2(50);
  strsql   varchar2(200);
  begin
  if m_PreTaskID is null then
  return '';
  end if;
  strsql := 'select max(nodename) from t_Wf_Tasklist where TaskID =''' ||
  m_PreTaskID|| '''';
  execute immediate strsql
  into nodename;
  return nodename;
  end;

  格式化标题输出:

  create or replace function FormatTitle(m_title    varchar2,
  m_length   number,
  m_FillChar varchar2) return varchar2 IS
  begin
  if lengthb(m_title) > m_length*2 then
  return substr(m_title, 0,m_length) || m_FillChar;
  else
  return m_title;
  end if;
  end;

《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号