【问题标题】:Creating a Record using PLSQL使用 PLSQL 创建记录
【发布时间】:2015-07-10 14:48:23
【问题描述】:

我正在尝试创建一个非常基本的程序。我只需要为表中的单行创建一条记录。我错过了什么?我收到的错误代码是“在期望时遇到符号声明......”

Create or Replace Procedure Luke as
Declare
Type type_basket is record(Term_code section.term_code%type, 
                           Subject_Code section.subject_code%type, 
                            Course_Number section.course_number%type, 
                              Section section.section%type);
Rec_Basket type_basket;

Begin
  Select term_code, subject_code, course_number, section into Rec_basket
    from Enrollment
      where term_code=201201 and course_number=105;

dbms.output_put.line(rec_basket.term_code);

end;

【问题讨论】:

    标签: plsql oracle11g record procedure


    【解决方案1】:

    DECLARE只需要anonymous blocks and subblocks,你don't use it to declare stored procedure variables

    注意:
    子程序的声明部分不像匿名块的声明部分那样以关键字 DECLARE 开头。

    所以删除那一行:

    Create or Replace Procedure Luke as
      Type type_basket is ...
      Rec_Basket type_basket;
    Begin
      Select ...
    end;
    /
    

    您可以使用%rowtype 变量而不是显式声明记录类型,然后选择整行,但我假设您的分配专门针对记录。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-29
      • 2017-04-24
      • 1970-01-01
      • 1970-01-01
      • 2021-08-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多