terça-feira, 2 de julho de 2013

Converting Rows to Columns (pivoting) in PL/SQL,

I thought it was pretty easy... but, after reading google and finding 10 different solutions the easiest one was:

 SELECT distinct row_nr
      ,MAX(DECODE(COL_NR, 1, o.NUMBER_VAL)) stat_1
      ,MAX(DECODE(COL_NR, 2, o.NUMBER_VAL)) stat_2
      ,MAX(DECODE(COL_NR, 3, o.NUMBER_VAL)) stat_3
      ,MAX(DECODE(COL_NR, 4, o.NUMBER_VAL)) stat_4
      ,MAX(DECODE(COL_NR, 5, o.NUMBER_VAL)) stat_5
      ,MAX(DECODE(COL_NR, 6, o.NUMBER_VAL)) stat_6
    ,MAX(DECODE(COL_NR, 7, o.NUMBER_VAL)) stat_7
     ,MAX(DECODE(COL_NR, 8, o.NUMBER_VAL)) stat_8
     ,MAX(DECODE(COL_NR, 9, o.NUMBER_VAL)) stat_9
     ,MAX(DECODE(COL_NR, 10, o.NUMBER_VAL)) stat_10
      ,MAX(DECODE(COL_NR, 11, o.NUMBER_VAL)) stat_10
    from table( as_read_xlsx.read( as_read_xlsx.file2blob( 'WORKDIR', 'dummy.xlsx' ),'Sheet1' ) ) o
    where Sheet_nr=1 and row_nr>1 
    group by row_nr
    order by  row_nr;

P.S- Also reading from a *.XLSX... but for a table it would be the same.

segunda-feira, 1 de julho de 2013

segunda-feira, 6 de maio de 2013

MS SQL 2008 is sometimes very slow with full text search

why?

Not my project so they told me to recompile the indexes and the catalog, no luck... You go to google, you read, no luck.
You decide to look at the query ... converting dates to varchar, when the day is bigger than X it gets slow.
I do have a problem with queries and dates, i'm glad i'm not the only one.

quarta-feira, 20 de março de 2013

So... encoding between oracle, web services, asp.net 1.1

Everything was configured to use utf-8, but it still gave an error when migrating a server. Checked, Rechecked, RE-rechecked and the page still had a bad encoding.

Why ? NLS_LANG was not defined in the new server.

usage: regedit =>hkey_local_machine/software/oracle/nls_lang.

I'm starting to hate oracle so much mere words can't explain. It's their "oracle DB", their "oracle crm", their "OBIEE", their "java" full of holes... it' all a huge pile of shit. period. jesus.

terça-feira, 22 de janeiro de 2013

Perl Salted Hashes

How to: follow. Understand what, why, should i ? follow.

segunda-feira, 21 de janeiro de 2013

Virtual box Increase disk size

How to increase disk size in virtual box: follow.

sexta-feira, 11 de janeiro de 2013

how to use an helper with parameter in perl web framework mojolicious

on template something like:

<%== getImagebyObjectId $obj->id %>

on app:

  $self->helper( getImagebyObjectId => sub {
    my ($self, $param) = @_;
     my $objectsdata=$self->db->resultset('Objectdata')->find({ idobject=>$param });    
     #$self->render_text($objectsdata->name);
    return $objectsdata->name;
  });

Basics: here.