Hello,
here is an example:
handle Integer;
dbms_return Integer;
tablename varchar(30);
colname varchar(30);
datatype varchar(9);
counter integer := 0;
BEGIN
handle := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(handle,
'select distinct table_name,column_name,data_type ' ||
'from user_tab_columns ', DBMS_SQL.V7);
DBMS_SQL.DEFINE_COLUMN(handle, 1, tablename, 30);
DBMS_SQL.DEFINE_COLUMN(handle, 2, colname, 30);
DBMS_SQL.DEFINE_COLUMN(handle, 3, datatype, 9);
dbms_return := DBMS_SQL.EXECUTE(handle);
counter := 0;
loop
if DBMS_SQL.FETCH_ROWS(handle) = 0 then
exit;
else
DBMS_SQL.COLUMN_VALUE(handle, 1, tablename);
DBMS_SQL.COLUMN_VALUE(handle, 2, colname);
DBMS_SQL.COLUMN_VALUE(handle, 3, datatype);
counter := counter + 1;
... do everything you want with that values !!!
end if;
end loop;
n := counter;
DBMS_SQL.CLOSE_CURSOR(handle);
END;
Hope that helps ?
Manfred Peter
(Alligator Company GmbH)
http://www.alligatorsql.com