This function accepts table name as input parameter and returns columns available in that table.
This function uses user_tab_cols table to read column names.
CREATE OR REPLACE FUNCTION DPGLOC.Getcolumns(P_table IN VARCHAR)
RETURN VARCHAR
IS
ColumnNames VARCHAR(20000);
ColumnName user_tab_cols.COLUMN_NAME%TYPE;
indexvalue NUMBER;
CURSOR tmpCursor(TAB_LE VARCHAR) IS
--CURSOR tmpCursor IS
SELECT COLUMN_name FROM user_tab_cols WHERE UPPER(table_name)=UPPER(TAB_LE);
BEGIN
indexvalue:=0;
OPEN tmpCursor(P_table);
--OPEN tmpCursor;
LOOP
FETCH tmpCursor INTO ColumnName;
EXIT WHEN tmpCursor%NOTFOUND;
IF(indexvalue=0)THEN
ColumnNames:=ColumnName;
indexvalue:=1;
ELSE
ColumnNames :=ColumnNames||','||ColumnName;
END IF;
END LOOP;
RETURN ColumnNames;
END;
/
No comments:
Post a Comment