Monday, September 29, 2014

SQL transaction for safety

In SQL studio, whenever an update to a table is perform, always test it first using TRANSACTION command. This ensures the execution of the query in its entity, and we can also have a preview on how the data will look like after the query execution.

DECLARE @TransactionName varchar(20) = 'Transaction1';
BEGIN TRAN @TransactionName

delete from C70_XTABLE

where C70_XTABLE_ID like '%Colleague%'

select * from C70_XTABLE


ROLLBACK TRAN @TransactionName;


After executing the whole query block, the data will remain unchanged, and we will have a sneak peek of what the query will do.

* Edit: The whole block can be written as:

begin transaction
(sql queries here)
rollback transaction

Tuesday, September 9, 2014

How to search for text/process/data element using ESEARCH

If you have access to Colleague terminal (through UI desktop, if you still have it), using ESEARCH can give you more accurate and complete results than the function "Find Reference" in Colleague Studio.

After you're in terminal, use this syntax to look for references to subroutine S.MY.TEST.SUB.

ESEARCH ST.SUBROUTINES  <enter>
>>>>S.MY.TEST.SUB  <enter>

SAVE.LIST SOME.SAVEDLIST <enter>

ELE SAVEDLISTS SOME.SAVEDLIST000 <enter> (note the three 0s were added)

P <enter> (P to browse the file, Q to quit)


ESEARCH is fairly fast. The only limitation is has is that you need to go in different modules such as ST.SUBROUTINES or CORE.SUBROUTINES or ST.SOURCE to search for them. Colleague Studio maintains pretty good references, but sometimes it misses customized processes.