检索数据库常量

时间:2012-02-23 08:56:58

标签: plsql oracle11g

我想通过前端查询检索数据库常量,以在DropDownList中填充此常量字符串。

我尝试过以下查询

  select pr_Package.constant_String from dual;

欢迎提出建议。

1 个答案:

答案 0 :(得分:6)

您无法直接在SQL语句中引用打包的常量。

您可以向包中添加一个函数,该函数返回常量并从SQL调用该函数。这样的东西会起作用(尽管你可能想要考虑一旦有函数返回数据就将常量移动到包体而不是包规范。)

create or replace package pkg_const
as
  some_constant number;
  function get_constant
    return number;
end;

create or replace package body pkg_const
as
  function get_constant
    return number
  is
  begin
    return some_constant;
  end;
end;

select pkg_const.get_constant from dual;