为什么 PLS-00382:表达式类型错误? [英] Why PLS-00382: expression is of wrong type?

查看:129
本文介绍了为什么 PLS-00382:表达式类型错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下自定义RECORD TYPE:

TYPE TB48_RECTYPE IS RECORD ( 
                             codpo varchar2(5 BYTE),
                             codco varchar2(5 BYTE),
                             quadr varchar2(5 BYTE),
                             espec varchar2(5 BYTE),
                             aperf varchar2(5 BYTE),
                             subes varchar2(5 BYTE),
                             datin date);

现在是一个返回完全相同类型的函数.

And now a function that returns the exact same type.

function retorna_infos_tabela_48(i_nip in varchar2) return TB48_RECTYPE is

retorno_REC TB48_RECTYPE;


begin
    select m.CODPO,
           m.CODCO,
           m.QUADR,
           m.ESPEC,
           m.APERF,
           m.SUBES,
           m.DATIN 
    into retorno_REC
    from TB48_M m
    where m.NRO = i_nip;

    return retorno_REC;

end retorna_infos_tabela_48; 

但是,(这已经花费了我 4 个多小时),当我尝试像这样运行它时:

However, (and this has cost me more than 4 hours already), when I try and run it like this:

    DECLARE 
    TYPE TB48_RECTYPE IS RECORD (
                             codpo varchar2(5 BYTE),
                             codco varchar2(5 BYTE),
                             quadr varchar2(5 BYTE),
                             espec varchar2(5 BYTE),
                             aperf varchar2(5 BYTE),
                             subes varchar2(5 BYTE),
                             datin date);
  RetVal TB48_RECTYPE;
  I_NIP VARCHAR2(200);

  BEGIN 
    I_NIP := '88888888';
    RetVal := RETORNA_INFOS_TABELA_48 ( I_NIP );
    COMMIT; 
  END;

我收到以下错误消息:PLS-00382:表达式类型错误.(在我将函数返回值分配给 RetVal 变量的那一行)

I get the following error message: PLS-00382: expression is of wrong type. (on the line that I assign the function returned value to the RetVal variable)

我的意思是,该函数返回一个 RECORD,它与我声明的变量类型完全相同!!我在这里错过了什么???

I mean, the function returns a RECORD which is of the exact same type as the variable I've declared!! What am I missing here???

提前致谢(以及一些 REP 点).

Thanks (and a few REP points) in advance.!

推荐答案

我怀疑您的问题是您试图将全局声明的类型放入本地声明的类型中.

I suspect your problem is that you attempting to place a globally declared type into a locally declared one.

我认为如果您将程序更改为以下内容,它应该会起作用.

I think if you change your procedure to the following it should work.

declare

  RetVal TB48_RECTYPE;
  i_nip varchar2(200);

begin

   i_nip := '86583557';
   RetVal := USERTEMPOS.PKG_ESTRANG_NOVA.RETORNA_INFOS_TABELA_48 ( I_NIP );

   commit;

end;

目前你的 commit 什么都不做...

Currently your commit is doing nothing...

您尚未提供如何创建全局类型,但如果您没有在包中创建,则提供的语法为 不正确;你确定编译了吗?

You haven't provided how you created your global type, but if you didn't do it in a package then the provided syntax is incorrect; are you sure it compiled?

这篇关于为什么 PLS-00382:表达式类型错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆