使用toad执行SQL函数

时间:2012-09-07 09:09:48

标签: sql oracle function toad

我对DB很新。我是java开发人员,与SQL函数无关。 但是现在我需要检查sql函数是否在db上正确执行

CREATE OR REPLACE FUNCTION RATELIMIT_OWN.Get_Logs ( p_yyyymm VARCHAR2, p_numec NUMBER )
RETURN LOG_RECORD_TABLE PIPELINED IS

TYPE        ref0 IS REF CURSOR;
cur0        ref0;

out_rec     LOG_RECORD := log_record(NULL,NULL,NULL);

BEGIN

OPEN cur0 FOR
  'SELECT eventid, errormsg, create_date from logs partition (LOGS_P' || p_yyyymm || ') where numec=:1'
USING p_numec;

  LOOP
   FETCH cur0 INTO out_rec.eventid, out_rec.msg, out_rec.create_date;
   EXIT WHEN cur0%NOTFOUND;
   PIPE ROW(out_rec);
  END LOOP;
  CLOSE cur0;

RETURN;
END Get_Logs;
/

如何在toad中执行此sql函数。我希望看到结果像普通的选择查询输出

3 个答案:

答案 0 :(得分:3)

要检查表值函数,请尝试:

select * FROM table(RATELIMIT_OWN.Get_Logs('a', 1));

答案 1 :(得分:2)

FOE EXECUTING THE FUNCTION    
SELECT RATELIMIT_OWN.Get_Logs(....,...) FROM DUAL ;

AND
ORA-00904:  MEAN COLUMN NAME IS NOT VALID PLSS CHECK THE COLUMN NAME 

答案 2 :(得分:0)

尝试:

 select  RATELIMIT_OWN.Get_Logs(...) from dual;