0

我想创建一个匿名块,在其中执行以下操作:

set session set current_schema = PTSI;
DECLARE
var_cur_proj structure.structure_code%TYPE;
var_cur_task structure.structure_code%TYPE;
TYPE tbl_result AS OBJECT
(
  projeto_id structure.structure_code%TYPE,
  projeto structure.description%TYPE,
  tarefa_id structure.structure_code%TYPE,
  tarefa structure.description%TYPE,
  recurso_id structure.structure_code%TYPE,
  recurso structure.description%TYPE,
  perfil_id structure.structure_code%TYPE,
  perfil structure.description%TYPE,
  rate_id structure.structure_code%TYPE,
  rate_value rate_change_point_res.rate_value%TYPE,
  dia date,
  horas_reportadas NUMBER(38,2),
  horas_integradas_realizadas NUMBER(38,2),
  horas_integradas_remanescentes NUMBER(38,2),
  horas_planeadas NUMBER(38,2)
);
TYPE table_resul IS TABLE OF tbl_resul;
resultado table_result;
BEGIN

END;
/

这给了我一个错误...我正在关注此站点以创建表变量(http://ss64.com/oraplsql/declaretbl.html),发现它不起作用,我尝试创建表变量,例如我习惯于创建函数返回的表(创建对象然后创建表)。

任何人都可以帮助我吗?

4

1 回答 1

3

而不是创建为对象,您应该将其创建为记录,然后从记录中声明表,并且正如 Justin 上面提到的,您必须在null;Begin 和 End 标签之间至少有一个。请参阅下面的修改代码。http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/record_definition.htm了解更多详情。

alter session set current_schema = PTSI;

DECLARE
  var_cur_proj structure.structure_code%TYPE;
  var_cur_task structure.structure_code%TYPE;
  TYPE rec_result IS RECORD
  (
    projeto_id structure.structure_code%TYPE,
    projeto structure.description%TYPE,
    tarefa_id structure.structure_code%TYPE,
    tarefa structure.description%TYPE,
    recurso_id structure.structure_code%TYPE,
    recurso structure.description%TYPE,
    perfil_id structure.structure_code%TYPE,
    perfil structure.description%TYPE,
    rate_id structure.structure_code%TYPE,
    rate_value rate_change_point_res.rate_value%TYPE,
    dia date,
    horas_reportadas NUMBER(38,2),
    horas_integradas_realizadas NUMBER(38,2),
    horas_integradas_remanescentes NUMBER(38,2),
    horas_planeadas NUMBER(38,2)
  );
  TYPE table_result IS TABLE OF rec_result;
  resultado table_result;
BEGIN
  null;
END;
/

希望这可以帮助

于 2013-10-23T22:40:09.167 回答