PL/SQL过程-值太多 [英] PL/SQL procedure - too many values
问题描述
我确定这很简单,但是我真的是PL/SQL的新手,这让我感到困惑.
I'm sure this is something simple, but I'm really new to PL/SQL and this has me stuck.
我编写了一个简单的存储过程,以返回有关客户的一些值.马上,%rowtype
并没有作为保留关键字出现,但是编译器没有将它们标记为错误.
I've written a simple stored procedure to return a few values about a customer. Right off the bat, the %rowtype
's are not coming up as reserved keywords but the compiler isn't flagging those as errors.
但是,它忽略了将行FROM demo_customers
标记为too many values
的整个SQL语句.即使我尝试将其减少为仅选择一列,它仍然会给我同样的错误.
It is, however, ignoring the entire SQL statement flagging the line FROM demo_customers
as too many values
. Even if I try reducing it to only select one column it still gives me the same error.
create or replace
PROCEDURE GETCUSTOMER
(
arg_customerID demo_customers.customer_id%type,
returnRec OUT demo_customers%rowtype
)
AS
BEGIN
SELECT customer_id, cust_first_name, cust_last_name, cust_email
INTO returnRec
FROM demo_customers
WHERE customer_id = arg_customerID ;
END GETCUSTOMER;
推荐答案
如果要选择%ROWTYPE记录,则需要执行SELECT *
而不是选择单个列
If you want to select into a %ROWTYPE record, you'll want to do a SELECT *
rather than selecting individual columns
create or replace
PROCEDURE GETCUSTOMER
(
arg_customerID demo_customers.customer_id%type,
returnRec OUT demo_customers%rowtype
)
AS
BEGIN
SELECT *
INTO returnRec
FROM demo_customers
WHERE customer_id = arg_customerID ;
END GETCUSTOMER;
如果您明确选择4列,Oracle希望您有4个变量来选择这些值.
If you select 4 columns explicitly, Oracle expects you to have 4 variables to select those values into.
这篇关于PL/SQL过程-值太多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!