嘿伙计们,我有一个只输出表格列的存储过程。相反,我想要'有'[列数]'学生'。作为输出。以下示例。
CREATE OR REPLACE PROCEDURE active_students (arc in out sys_refcursor)
as
begin
open arc for select count(*) from student;
end;
这会生成
Count(*)
30
希望阅读
There are 30 students.
答案 0 :(得分:2)
使用:
CREATE OR REPLACE PROCEDURE JSU4290M.active_students (arc in out sys_refcursor)
AS
BEGIN
OPEN arc FOR
SELECT 'There are '|| COUNT(*) ||' students.' AS col
FROM STUDENT;
END;
双管道(||)是Oracle(现在是ANSI标准)连接字符串的方法。 Oracle将隐式地将整数值转换为字符串。