I have multiple tables in my database. I have to find out the names of those tables. So I have written the following program:
CREATE OR REPLACE FUNCTION fun_tablefinder( keyword VARCHAR2 )
RETURN NUMBER
IS
v_query VARCHAR2(200);tablename VARCHAR2(20);
tablename NUMBER;
BEGIN
v_query:='SELECT count(TABLE_NAME) FROM USER_TAB_COLUMNS WHERE TABLE_NAME LIKE ''%'||upper(keyword)||'%''';
EXECUTE IMMEDIATE v_query INTO tablename;
RETURN tablename;
END;
But there is error in my query which I can't fix:
tablename:= fun_tablefinder('ubl'); is not working
And also I am confused about how can I extract multiple rows while calling this function. How can I use loop to handle those results?
Thanks in advanced.
count(*)into a VARCHAR2? It's a number so use one! I also don't understand what you mean when you say " i am confusing with that how can i extract multiple rows while calling this function". What exactly are you trying to achieve?