#!/usr/bin/ksh # set -xv # author : B. Polarski # program : smenu_stream_aq.ksh # date : 12 Decembre 2005 # 03 October 2007 : added primary and secondary instances for queue # added optin -bq to see buffered queues # added optin -bs and -bf to see buffered Subscribers meta data and stats # added optin -bp to see buffered Publishser data and stats # 21 November 2007 Added option -key to option -readp to show the transaction details # 06 Mars 2008 Added options -txn to extract/apply/purge all LCR related to a TXN ID HOST=`hostname` HOST=`echo $HOST | awk '{ printf ("%-+15.15s",$1) }'` # ------------------------------------------------------------------------------------- function check_par { PAR=\$$1 eval A=${PAR} if [ -z "$A" ];then echo "Parameter '$1' is not set" exit fi } # ------------------------------------------------------------------------------------- function help { cat < -qn -p -create -l -l -stop -start -lq -v -purge -qn -cust -read [-u ] -readp [-u ] -key [-rn ] aq -t [-pi [-si ] aq -ld -lc -lg -lh -ls -lt -li aq -fdrop -l : list queue figures -readp : read the AQ\$__P header for each objects -q : list all queue -key : display all values from a given transaction row in a transaction -bq : list buffered queues (the row is identified by its MSGID number) -s : list buffered suscribers figures -v : Verbose : show sql text -b : list buffered publisher -pi : Primary Instance number for the owner of the queue table -sm : list buffered suscribers metadata -si : Secondary Instance number for the owner of the queue table -create : Create a queue -siz : List name and size to objects associated to Queue tables -start : Start a queue -qt : list all queue tables and their real size in blocks -stop : Stop a queue -p : Queue owner password (default to queue_owner) -drop : Drop a queue -k : Reduce HWM for queue table and associated _P and IOT -purge : Purge a queue -fdrop : Force a drop of a queue table -purgep : Remove all rows from axception queue -rn : Limite select to first rows -lq : list queue contents -gm : List size of all AQ\$ tables -qn : Queue name -sched : Queue schedule -t : Queue table -u : Queue owner -l[c|d|g|h|i|s|t] : List AQ\$__ associated IOT queue contents -cd : coalesce AQ\$__d Create a queue : aq -create -qn -u Start a queue : aq -start -qn -u Stop a queue : aq -stop -qn -u drop a queue : aq -drop -qn -u Purge a queue : aq -purge -qn change inst owner : aq -t -pi read queue : aq -read read exception queue : aq -readp transaction details : aq -readp -key | -txn (use aq -readp to see the values for -key) Rerun contents of _P exception queue : aq -execute -qn -u shrink queue table and associated _P and IOT tables : aq -k -u coalesce the _d iot : aq -cd force a drop of queue table : aq -fdrop -t # ...................................................................................................... Stream administrator admin and his password can be deduced by smenu if you defined one for this instance in SM/3.8 ortherwise it will try to default to STRMADMIN/STRMADMIN # ...................................................................................................... EOF exit } # ------------------------------------------------------------------------------------- function do_execute { if [ -n "$SETXV" ];then echo "$SQL" fi sqlplus -s "$CONNECT_STRING" < ' ||p.msgid); end if ; oldColList:= lcr.get_values('OLD'); newColList:= lcr.get_values('NEW','Y'); strOut:= RPAD(' Column',colLen)||RPAD(' Old Value',valLen) ||RPAD(' New Value',valLen); dbms_output.put_line(' '); strOut:= RPAD('-',colLen,'-')||RPAD(' -',valLen,'-') ||RPAD(' -',valLen,'-'); dbms_output.put_line(strOut); -- this old trick is derived from the old pick-a-month-pos-in-list-of-all-months-in-year FOR i IN 1..oldColList.Count LOOP OldCols:= OldCols||oldColList(i).column_name||','; END LOOP; FOR i IN 1..newColList.Count LOOP NewCols:= NewCols||newColList(i).column_name||','; END LOOP; -- Now, with the function INSTR, we check that the proposed column exists at least in one of the 2 lists FOR Col IN (SELECT column_name Name FROM all_tab_columns WHERE owner = lcr.get_object_owner AND table_name = lcr.get_object_name AND (INSTR(OldCols,column_name||',') > 0 OR INSTR(NewCols,column_name||',') > 0) ORDER BY column_id) LOOP strOut:= RPAD(Col.Name,colLen)||' '; str:= '-'; IF INSTR(OldCols, Col.Name||',') > 0 THEN str:= '"'||retStr(lcr.Get_Value('OLD',Col.Name))||'"'; IF str IS NULL OR str = '""' THEN str:='NULL'; ELSIF INSTR(str,'ERR!') > 0 THEN str:='-'; END IF; END IF; str:= RPAD(str,valLen); strOut:= strOut||str; str:= '-'; IF INSTR(NewCols, Col.Name||',') > 0 THEN str:= '"'||retStr(lcr.Get_Value('NEW',Col.Name,'N'))||'"'; IF str IS NULL OR str = '""' THEN str:='NULL'; ELSIF INSTR(str,'ERR!') > 0 THEN str:='-'; END IF; END IF; str:= RPAD(str,valLen); strOut:= strOut||str; dbms_output.put_line(strOut); END LOOP; -- DDL ELSIF cmdtype = 'SYS.LCR\$_DDL_RECORD' THEN rc := p.user_data.GetObject(ddl_lcr); dbms_output.put_line('-- Object : '|| ddl_lcr.get_object_owner||'.'||ddl_lcr.get_object_name); dbms_output.put_line('-- Lcr creation Time : '||ddl_lcr.get_source_time); dbms_output.put_line('-- Txn-ID / SCN : '||ddl_lcr.get_transaction_id ||' / '||ddl_lcr.get_scn); dbms_output.put_line('-- Ddl statement :'); DBMS_LOB.CREATETEMPORARY(DDLTxt, TRUE); ddl_lcr.get_ddl_text(DDLTxt); dbms_output.put_line(DDLTxt); DBMS_LOB.FREETEMPORARY(DDLTxt); -- PROCEDURE ELSIF cmdtype = 'SYS.LCR\$_PROCEDURE_RECORD' THEN dbms_output.put_line('PROCED=' ||cmdtype); rc := p.user_data.GetObject(proc_lcr); dbms_output.put_line('-- Package : '|| proc_lcr.get_package_owner||'.'||proc_lcr.get_package_name||'.'||proc_lcr.get_procedure_name); -- buggy dbms_output.put_line('-- Publication : '|| proc_lcr.GET_PUBLICATION); dbms_output.put_line('-- Txn-ID / SCN : '||proc_lcr.get_transaction_id ||' / '||proc_lcr.get_scn); END IF; if ( '$DO_EXEC' = 'TRUE' ) then begin lcr.execute(TRUE); dbms_output.put_line(chr(10) ||' LCR Re-Executed status : OK'); dbms_output.put_line('delete from $TARGET_QUEUE where MSGID = '''||p.msgid||''''); execute immediate ('delete from $TARGET_QUEUE where MSGID = '''||p.msgid||''''); exception when others then dbms_output.put_line(chr(10) || 'Bleh.. Execute is not NOK'); end ; end if ; <> null; END LOOP; exception when no_data_found then null ; end ; end; / prompt EOF exit # ........................ # Purge a queue contents # ........................ elif [ "$CHOICE" = "READ_QUEUE" ];then if [ -n "$ROWNUM" ];then WHERE_ROWNUM=" where rownum <= $ROWNUM " ORDERBY=" order by msgid desc" fi if [ -n "$fcol" ];then COL_DEF="col varchar2(35);" COL_GET_VALUE="col:=lcr.get_value('old','$fcol');" #COL_GET_VALUE="col:=to_char(lcr.get_value('old','$fcol'));" COL_OUTPUT="||' '||col" fi if [ "$Q_EXEC" = "TRUE" ];then DO_EXEC="lcr.execute(TRUE);" else unset DO_EXEC fi VAR=`sqlplus -s "$CONNECT_STRING"<