Tracing SQL across the wire

This can be really useful in place of database tracing, especially when you want to see the action the *application* takes, and not just what it does in the database.

[[email protected]************** common]# tcpdump -A -nn port 1521 | \
>                               awk '{if (tolower($0) ~ "select" || tolower($0) ~ "update") {p=1;print} \
>                                     else if(p == 1 && $0 !~ "^[0-9][0-9]:") {print} \
>                                     else if ($0 ~ "^[0-9][0-9]:") {p=0}}'
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), capture size 65535 bytes
.......................SELECT t1.config_path,t1.content_id
   FROM srch_config t1
  WHERE ((t1.uniq_server_id IS NULL)
    OR (:1  = t1.uniq_server_id)).................... .......i....__NULL__
.......................SELECT t1.config_path,t1.content_id
   FROM srch_config t1
  WHERE ((t1.uniq_server_id IS NULL)
    OR (:1  = t1.uniq_server_id)).................... .......i....__NULL__
.......................SELECT t1.config_path,t1.content_id
   FROM srch_config t1
  WHERE (NOT ((t1.uniq_server_id IS NULL))
    AND NOT ((:1  = t1.uniq_server_id))).................... .......i....__NULL__
.......................SELECT t1.config_path,t1.content_id,t1.generation,t1.claimed_generation,t1.nxt_inc_generation,t1.uniq_server_id,t1.last_activity,t1.last_full_index,t1.last_incr_index
   FROM srch_config t1
  WHERE ((t1.config_path = :1  AND t1.content_id = :2 ))............................i...............i...-/atg/userprofiling/search/ProfileOutputConfig.DEFAULT
.......................SELECT t1.config_path,t1.content_id
   FROM srch_config t1
  WHERE ((t1.uniq_server_id IS NULL)
    OR (:1  = t1.uniq_server_id)).................... .......i....__NULL__
.......................SELECT t1.config_path,t1.content_id
   FROM srch_config t1
  WHERE ((t1.uniq_server_id IS NULL)
    OR (:1  = t1.uniq_server_id)).................... .......i....__NULL__
.......................SELECT t1.config_path,t1.content_id
   FROM srch_config t1
  WHERE ((t1.uniq_server_id IS NULL)
    OR (:1  = t1.uniq_server_id)).................... .......i....__NULL__
.......................SELECT t1.config_path,t1.content_id
   FROM srch_config t1
  WHERE ((t1.uniq_server_id IS NULL)
    OR (:1  = t1.uniq_server_id)).................... .......i....__NULL__
...........................UPDATE dms_queue_entry  SET handling_client_id = :1 ,      read_state = :2   WHERE handling_client_id < 0    AND delivery_date < :3     AND queue_id IN (SELECT qr.queue_id                     FROM dms_queue_recv qr                     WHERE qr.client_id = :4 ) ...........................i..............i..............i..............i.....^)............$.\.+..^)..
...........................UPDATE dms_topic_entry SET read_state = :1  WHERE delivery_date < :2    AND read_state = 0   AND subscriber_id IN (SELECT ts.subscriber_id                         FROM dms_topic_sub ts                         WHERE ts.client_id = :3                            AND ts.active = 1) ...........................i..............i..............i.............$.\.+...^)..
.......................SELECT t1.config_path,t1.content_id
   FROM srch_config t1
  WHERE ((t1.uniq_server_id IS NULL)
    OR (:1  = t1.uniq_server_id)).................... .......i....__NULL__