获取Form界面LOV对应的SQL语句



SELECT sa.sql_text, sa.*
  FROM v$session se, v$sqlarea sa
 WHERE se.prev_hash_value = sa.hash_value
   AND se.audsid = 144375585(db_session_id)
 db_seeion_id在界面中的profile中找

 DECLARE CURSOR cur_lov_sql(p_pre_sql_addr VARCHAR2) IS
        SELECT t.sql_text
          FROM v$sqltext_with_newlines t
         WHERE t.address = p_pre_sql_addr
         ORDER BY t.piece;

--
l_lov_sql VARCHAR2(2400);
l_prev_sql_addr VARCHAR2(200);
BEGIN
  BEGIN
    SELECT v.prev_sql_addr
      INTO l_prev_sql_addr
      FROM v$session v
     WHERE v.sid = &sid;
  EXCEPTION
    WHEN OTHERS THEN
      dbms_output.put_line('get prev sql addr error,' || SQLCODE || ':' ||
                           SQLERRM);
  END;
  --
  FOR rec IN cur_lov_sql(l_prev_sql_addr) LOOP
    l_lov_sql := nvl(l_lov_sql, '') || rec.sql_text;
  END LOOP;
  --
  dbms_output.put_line('lov查询sql为:');
  dbms_output.put_line(l_lov_sql);
END;

你可能感兴趣的:(form,LOV)