oracle - plsql 过程未在此范围内声明错误
问题描述
大家好,我正在尝试为作业创建一个基本的 PLSQL 函数。代码如下
DECLARE
e_child_record_found exception;
PRAGMA EXCEPTION_INIT(e_child_record_found, -02292);
v_afd number;
function afdeling_van(p_mnr in MEDEWERKERS.AFD%type)
RETURN MEDEWERKERS.AFD%type
IS
DEPNR MEDEWERKERS.AFD%type;
BEGIN
SELECT AFD into DEPNR FROM MEDEWERKERS WHERE AFD = p_mnr;
end afdeling_van;
procedure ontsla_med(p_mnr in MEDEWERKERS.AFD%type)
IS
BEGIN
DELETE FROM UITVOERINGEN WHERE DOCENT = p_mnr;
DELETE FROM INSCHRIJVINGEN WHERE CURSIST = p_mnr;
DELETE FROM MEDEWERKERS WHERE MNR = p_mnr;
end ontsla_med;
procedure neem_med_aan(p_naam in MEDEWERKERS.NAAM%type,
p_voorl in MEDEWERKERS.VOORL%type,
p_gbdatum in MEDEWERKERS.GBDATUM%type,
p_maandsal in MEDEWERKERS.MAANDSAL%type,
p_afd in MEDEWERKERS.AFD%type,
p_functie in MEDEWEKERS.FUNCTIE%type DEFAULT('NULL'),
p_chef in MEDEWERKERS.CHEF%type DEFAULT('NULL'))
IS
v_mnr number;
BEGIN
SELECT max(MNR)into v_mnr FROM MEDEWERKERS;
v_mnr := v_mnr + 1;
INSERT INTO MEDEWERKERS(MNR, naam, voorl, functie, chef, gbdatum, maandsal, afd) VALUES(v_mnr,p_naam, p_voorl, p_gbdatum, p_maandsal, p_afd, p_functie, p_chef);
end neem_med_aan;
BEGIN
ontsla_med(p_mnr => 7900);
v_afd := afdeling_van(p_mnr => 7369);
dbms_output.put_line(v_afd);
neem_med_aan(p_naam => 'Vermeulen',
p_voorl => 't',
p_gbdatum => '15-02-1961',
p_maandsal => 2000,
p_afd => 10);
neem_med_aan(p_naam => 'derks',
p_voorl => 'm',
p_gbdatum => '05-aug-61',
p_maandsal => 2500,
p_afd => 30,
p_functie => 'Verkoper',
p_chef => 7698);
neem_med_aan(p_naam => 'Martens',
p_voorl => 'i',
p_gbdatum => '11-05-1956',
p_maandsal => 2100,
p_afd => 20,
p_functie => 'Trainer');
neem_med_aan(p_naam => 'Verbeek',
p_voorl => 'j',
p_gbdatum => '12-09-1950',
p_maandsal => 2600,
p_afd => 30,
p_functie => 'verkoper',
p_chef => 7782);
exception
when e_child_record_found then --ORA-melding, zelf gedefinieerd
raise_application_error(-20000,'De medewerker is nog verbonden aan andere gegevens');
when no_data_found then --voorgedefinieerd door Oracle
raise_application_error(-20000,'Deze medewerker bestaat niet');
end;
现在我收到以下错误
Error report -
ORA-06550: line 27, column 41:
PLS-00201: identifier 'MEDEWEKERS.FUNCTIE' must be declared
ORA-06550: line 22, column 5:
PL/SQL: Item ignored
ORA-06550: line 41, column 9:
PLS-00313: 'NEEM_MED_AAN' not declared in this scope
ORA-06550: line 41, column 9:
PL/SQL: Statement ignored
ORA-06550: line 46, column 9:
PLS-00313: 'NEEM_MED_AAN' not declared in this scope
ORA-06550: line 46, column 9:
PL/SQL: Statement ignored
ORA-06550: line 53, column 9:
PLS-00313: 'NEEM_MED_AAN' not declared in this scope
ORA-06550: line 53, column 9:
PL/SQL: Statement ignored
ORA-06550: line 59, column 9:
PLS-00313: 'NEEM_MED_AAN' not declared in this scope
ORA-06550: line 59, column 9:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
声明中的过程和函数已经存在,所以我只是在里面添加了代码。这和里面的代码有关系吗?或者程序放置或类似的东西有问题。希望得到一些帮助,在此先感谢。
解决方案
当前的定义为neem_med_aan
:
procedure neem_med_aan(p_naam in MEDEWERKERS.NAAM%type,
p_voorl in MEDEWERKERS.VOORL%type,
p_gbdatum in MEDEWERKERS.GBDATUM%type,
p_maandsal in MEDEWERKERS.MAANDSAL%type,
p_afd in MEDEWERKERS.AFD%type,
p_functie in MEDEWEKERS.FUNCTIE%type DEFAULT('NULL'),
p_chef in MEDEWERKERS.CHEF%type DEFAULT('NULL'))
看来第六行,MEDEWEKERS
应该改成MEDEWERKERS
.
祝你好运。
推荐阅读
- databricks - 基于 Databricks SQL Analytics(Redash) 查询历史记录的报告/可视化?
- express - ExpressJs 响应重定向 URL 被 IIS 更改
- python-3.x - 有没有办法从我的 csv 文件中获取数据并将其放在我的网站上
- python - 当用户在 Python 中请求时,我如何调用整个函数?
- python - ValueError:无效的 RGBA 参数:在 colors.py 中
- c# - Xamarin Forms EntryCell 添加到 c# 中的现有 TableView 无法在 CustomViewModel 中访问
- python - 使用自定义损失函数时 model.fit() 出错
- stripe-payments - 通过 Stripe Checkout 支持免费试用
- android-download-manager - DownloadManager 无法在华为设备上运行
- html - 如何移动秤?