[英]Oracle Apex: Success With compilation error
I'm trying to create a procedure named "Greetings" in the oracle apex.我正在尝试在 oracle 顶点中创建一个名为“Greetings”的过程。 The Procedure Greetings runs with some error throwing up called "Success with compilation error".
程序问候运行时抛出一些错误,称为“编译错误成功”。 Is there anything wrong with my below code.
我下面的代码有什么问题吗?
Code:代码:
create table tb_Animals (
txt_Name varchar(20) Primary Key,
int_Weight number
);
insert into tb_Animals values ('Dog',30);
insert into tb_Animals values ('Cat',15);
CREATE OR REPLACE PROCEDURE greetings
AS
BEGIN
select * from tb_Animals;
END;
In PL/SQL, you have to insert those values into something, usually a variable, However, if you're selecting the whole table contents, then it has to be something else;在 PL/SQL 中,您必须将这些值插入到某个东西中,通常是一个变量,但是,如果您要选择整个表格内容,那么它必须是其他东西; one option might be a refcursor.
一个选项可能是一个参考。 For example:
例如:
SQL> CREATE OR REPLACE PROCEDURE greetings
2 AS
3 rc sys_refcursor;
4 BEGIN
5 open rc for
6 select * from tb_Animals;
7 END;
8 /
Procedure created.
SQL>
It is now correct as far as compilation is concerned, but - actual "solution" depends on what you really want to do.就编译而言,它现在是正确的,但是 - 实际的“解决方案”取决于您真正想要做什么。
Two problems I see here:我在这里看到两个问题:
If you just want your script to return the data you just inserted into the table as a confirmation, just run the select statement without the procedural stuff, like this (and don't forget to commit your changes:):如果您只是希望您的脚本返回您刚刚插入表中的数据作为确认,只需运行 select 语句而不使用程序内容,就像这样(并且不要忘记提交您的更改:):
create table tb_Animals (
txt_Name varchar(20) Primary Key,
int_Weight number
);
insert into tb_Animals values ('Dog',30);
insert into tb_Animals values ('Cat',15);
commit;
select * from tb_Animals;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.