简体   繁体   中英

Executing SQL Function using toad

I am very new to DB. I am java developer and nothing to do with SQL Functions. But now I am in a situation where I need to check whether an sql function is getting executed properly on db or not

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;
/

How to execute this sql function in toad. I want to see the results like normal Select query output

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

select * FROM table(RATELIMIT_OWN.Get_Logs('a', 1));
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 

尝试:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM