Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Concat SQL_TEXT from Statspack tables.
Hmmmm. It seems that I don't get replies to a lot of my posts. Do I ask
the hard questions or just stupid ones? On sencond thought, don't answer
that... ;)
In any case, in reinventing the wheel, I decided to just create a function that uses a REF CURSOR to generically concat the column for me:
CREATE OR REPLACE FUNCTION newwheel (p_tabname IN VARCHAR2, p_colname IN VARCHAR2, p_whereclause IN VARCHAR2) RETURN VARCHAR2 AS
TYPE rc_type IS REF CURSOR; rc rc_type; v_col VARCHAR2(2000); v_result VARCHAR2(4000); BEGIN OPEN rc FOR 'SELECT '||p_colname||' FROM '||p_tabname||' '||p_whereclause; LOOP FETCH rc INTO v_col; EXIT WHEN rc%NOTFOUND; v_result := v_result||v_col; END LOOP; CLOSE rc; RETURN(v_result);
Then I can:
SELECT newwheel('PERFSTAT.STATS$SQLTEXT','sql_text','WHERE HASH_VALUE =
1232131312')
FROM dual;
Hope this can help someone else!
Rich
"Well I'm sorry, but I'm going to have to shoot you."
"Right-oh, sir." <THUMP>
"What a senseless waste of human life."
-----Original Message-----
Sent: Monday, February 10, 2003 10:29 AM
To: Multiple recipients of list ORACLE-L
Hey all,
In 8.1.7.4, does anyone have a SQL that will take the output from the following:
SELECT sql_text
FROM PERFSTAT.STATS$SQLTEXT SS
WHERE SS.HASH_VALUE = :myhash
ORDER BY PIECE
...and append/concat all the rows into a single column.
I *know* someone's done this before and I don't want to re-invent the wheel unless I have to.
TIA!
Rich
Rich Jesse System/Database Administrator rich.jesse_at_qtiworld.com Quad/Tech International, Sussex, WI USA
-- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Jesse, Rich INET: Rich.Jesse_at_qtiworld.com Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).Received on Wed Feb 12 2003 - 13:44:26 CST
![]() |
![]() |