在Oracle PLSQL函数的输出中需要帮助

问题描述

当前正在使用oracle PLSQL函数列出所有项目的项目编号,职称和雇员姓名。

对于此功能,我需要这样获得输出: [不完整的例子]

1001 Computation: Alvin,Peter
1002 Study methods: Bob,Robert
1003 Racing car: Robert

这是我当前的输出。 SQL>执行PROJECTGROUPS;

1001 Computation: Alvin
1001 Computation: Ami
1001 Computation: Michael
1001 Computation: Peter
1001 Computation: Wendy
1002 Study methods: Bob
1002 Study methods: Robert
1003 Racing car: Bob
1003 Racing car: Robert
1004 Football: Douglass
1004 Football: Eadger
1005 Swimming: Douglass
1005 Swimming: Eadger
1006 Training: Aban
1006 Training: Carl

[当前代码]

SQL> set echo on
SQL> set feedback on
SQL> set linesize 100
SQL> set pagesize 200
SQL> set serveroutput on
SQL> --
SQL> -- Task 01
SQL> --
SQL> CREATE OR REPLACE PROCEDURE PROJECTGROUPS
  2  IS
  3  Previous_pnum PROJECT.P#%type := -1;
  4  --
  5  begin
  6  for currentRow IN(select p.P#,p.PTITLE,e.NAME
  7  from PROJECT p LEFT OUTER JOIN EMPLOYEE e
  8  on p.d# = e.d#
  9  WHERE p.P# IN(1001,1002,1003,1004,1005,1006)
 10  ORDER BY p.P#,e.NAME)
 11  --
 12  --
 13  loop
 14  if currentRow.P# is not null then
 15  dbms_output.put_line(currentRow.P# || ' ' || currentRow.PTITLE || ': ' || currentRow.NAME);
 16  end if;
 17  Previous_pnum := currentRow.P#;
 18  end loop;
 19  dbms_output.put_line(NULL);
 20  END;
 21  /

Procedure created.

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)