检索数据库常量

Pra*_*mod 0 plsql oracle11g

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

我试过以下查询

  select pr_Package.constant_String from dual;
Run Code Online (Sandbox Code Playgroud)

欢迎提出建议.

Jus*_*ave 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;
Run Code Online (Sandbox Code Playgroud)