Monthly Archives: December 2014

My workspace setup

Hello there!
Today I’m sharing with you my corporate office workspace setup featuring:

  • 2x Ergotron Neo-Flex Arm display mounts supporting 2x 19′ 3×4 LDC displays (they are good for coding)
  • Corporate Lenovo Thinkpad x230 with Zelda decal 🙂
  • Lenovo dockstation
  • Goldtouch V2 keyboard hacked into truly separate one
  • Kensington Orbit trackball with scroll ring
  • Some cute little things

IMG_2069
IMG_2074
Don’t really like this corporate environment with lots of buzzing people and grey walls, etc. But I tried to make it as comfortable for me as it could be.

Notepad++ (Boost) Regex: conditional replacement, if n-th group exists

Say you have long list of variable names

V2002
V2003
V2004_NC
V2004_USD
...

and you want to form new strings, which will vary depending on presence of the suffix (_NC, _USD).
Here how you can form new strings in Notepad++ (but not in Sublime 2, both utilizing Boost regex syntax)
Pattern:

([a-z]+)(\d+)(_(\w+))?

Replace string:

when nvl\($0,0\)!=0 then into tmp_int values \(model, $2, $0, (?3'$4':null)\)

Note the (?3’$4′:null) part. It’s interpreted as “if pattern #3 is present then insert quoted pattern #4, else insert literal ‘null'”
So we will get the following

when nvl(V2002,0)!=0 then into tmp_int values (model, 2002, V2002, null)
when nvl(V2003,0)!=0 then into tmp_int values (model, 2003, V2003, null)
when nvl(V2004_NC,0)!=0 then into tmp_int values (model, 2004, V2004_NC, 'NC')
when nvl(V2004_USD,0)!=0 then into tmp_int values (model, 2004, V2004_USD, 'USD')

Pretty easy and useful.
BTW Sublime 2 just can’t do it right.

Oracle: Regexp_Replace respecting word boundaries

Sometimes you just want to preserve word boundaries while using Oracle regexp_replace, or to replace the whole word only, not substrings within other words. Pity, but Oracle regexp syntax does not understand perl’s ‘\b’ (word boundary). So the workaround is to use ‘\W’ (not word). Here how I do it:

regexp_replace( 
    haystack
    , '(\W|^)(' || what_to_replace || ')(\W|$)'
    , '\1' || with_what || '\3'
    , 1
    , 0
    , 'imn'
)

Credits go to SQL.ru forum

OGG: Fixing OGG-01367

Hello everybody! Finally moved to separate hosting. And here’s the first post!

Yesterday bumped into this GoldenGate error:

OGG-01367: Length of CSN {0}, {1,number,0}, from input data source not equal to that of previous CSN, {2,number,0}
Cause: There is a possible memory corruption or invalid data in the trail.
Action: Contact Oracle Support.

Metalink says

The workaround is to disable BATCHSQL

And it worked.

Cheers!