martedì 14 luglio 2015

Vertica - "One or more rows were rejected by the server"

Di fronte all'errore:
One or more rows were rejected by the server.
Verificare le righe che lo generano con la query:
SELECT *
FROM error_messages
WHERE error_level='ERROR'
order by event_timestamp desc

lunedì 5 gennaio 2015

Linux - Comandi vari per gestire directory

Verificare dove è montata una directory
df nome_dir -h
Verificare quanto occupa una directory
totale occupato:   du -sh nome_dir
totale occupato dalle sottodirectory: du -h --max-depth=1

lunedì 27 ottobre 2014

Linux -bash: fork: Resource temporarily unavailable

Se dovesse capitare che su Linux ad ogni comando che si cerca di eseguire si presenti l'errore

-bash: fork: Resource temporarily unavailable
Provare a stoppare tutti i processi con il comando
kill -9 -1
E poi restartare uno a uno tutti i processi della macchina.



Possibili operazioni sistemistiche per effettuare diagnosi (sostituire PID con il pid del processo)

Verificare i file aperti da un processo:
lsof -p PID | wc -l
Scrivere l'elenco dei file aperti su file
lsof -p PID > output.log

Vedere i thread aperti
ps -mo THREAD -p PID | awk '{print $5 }' | sort | uniq -c

giovedì 2 agosto 2012

SpagoBI - Gestione valori default JasperReport

The problem is that when you do not valorize an analytica driver Spagobi Server send to the engine an empty string as value.
The empty string is valid parameter value for jasper so it do not use the default one as expected. This managment of not valorized parameters can be improved in order to avoid this kind of problems. However for the moment I can suggets to you this workaround. In the jasper template for each parameter AAA that can be optionally valorized by the user define also another twin parameter named SAFE_AAA defined like this ...

($P{AAA} != null && $P{AAA}.trim().length() > 0) ? $P{AAA}: "my default value"

then use SAFE_AAA in place of AAA. Let me know if this work around works in your case. 

martedì 26 giugno 2012

Java - Problematic frame - C [libc.so.6+0x72f33] __libc_calloc+0x93

# An unexpected error has been detected by Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00002aaaab262f33, pid=5234, tid=1086544192
#
# Java VM: Java HotSpot(TM) 64-Bit Server VM (10.0-b19 mixed mode linux-amd64)
# Problematic frame:
# C  [libc.so.6+0x72f33]  __libc_calloc+0x93
#
# An error report file with more information is saved as:
# /mnt/bi/bisw/talend/KeyWord_2/Stg_Keyword_0.1/Stg_Keyword/hs_err_pid5234.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp



Soluzione: aggiungere questi parametri quando viene lanciato java

-Xms2048M -Xmx2048M -Dfile.encoding=UTF-8
-XX:+UseParallelGC
-XX:NewSize=512M
-XX:MaxNewSize=512M

venerdì 22 giugno 2012

MySql - Occupazione spazio nelle tabelle

SELECT
   table_schema,table_name, count(*) TABLES,
   round(sum(table_rows)/1000000,2) rows,
   round(sum(data_length)/(1024*1024*1024),2) DATA,
   round(sum(index_length)/(1024*1024*1024),2) idx, 
   round(sum(data_length+index_length)/(1024*1024*1024),2) total_size,
   round(sum(index_length)/sum(data_length),2) idxfrac
FROM
   information_schema.TABLES
group by table_schema,table_name
order by 7 desc

giovedì 21 giugno 2012

MySql - Salvataggio di tabella su file

Salvataggio di tabella su file:
SELECT * FROM prova
INTO OUTFILE '/mnt/prova.csv'
FIELDS TERMINATED BY ';' ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n';

Se Infobright potrebbe dare il seguente errore:
The query includes syntax that is not supported by the Infobright Optimizer. Either restructure the query with supported syntax, or enable the MySQL Query Path in the brighthouse.ini file to execute the query with reduced performance. 

Per risolverlo eseguire prima lo statement:
set @bh_dataformat = 'txt_variable';

Caricamento da file:
LOAD DATA INFILE '/mnt/prova.csv' INTO TABLE prova1

martedì 12 giugno 2012

Vertica - Query di monitoraggio

Verificare lo spazio occupato dalla tabelle sul disco

SELECT t.table_schema,t.table_name AS table_name,
SUM(ps.wos_row_count + ps.ros_row_count) AS row_count,
SUM(ps.wos_used_bytes + ps.ros_used_bytes)/(1024*1024) AS MB_count
FROM tables t
JOIN projections p ON t.table_id = p.anchor_table_id
JOIN projection_storage ps on p.projection_name = ps.projection_name
WHERE (ps.wos_used_bytes + ps.ros_used_bytes) > 500000
GROUP BY t.table_schema,t.table_name
ORDER BY MB_count DESC;

Vedere l'elenco della tabelle
SELECT * FROM tables;

Verificare le query attive
select node_name, user_name, client_hostname, session_id, transaction_start, statement_start, current_statement
from sessions

Killare una sessione
Inserire come parametro il campo session_id
SELECT CLOSE_SESSION('vertica01.pgh.wpahs774:0x1db5bb');

martedì 13 marzo 2012

Linux - Eseguire in background con stdout e stderr su file

Comando per eseguire un file batch in background con stdoutput e stderror indirizzati su file:

nohup ./PRIMO_RUN_MS_0.1/PRIMO_RUN_MS/PRIMO_RUN_MS_run.sh >/job_log/stdout.log 2>&1 &


Il risultato sarà l'esecuzione del job "PRIMO_RUN_MS_0.1/PRIMO_RUN_MS/PRIMO_RUN_MS_run.sh" con stdoutput scritto su /job_log/stdout.log".
Anche lo stderror viene indirizzato sullo stesso file (2>&1).
L'esecuzione è in backgroup (è presente la &), quindi prosegue anche se viene chiuso il terminale

Linux - Automount directory di rete windows

Ipotizziamo di dover montare la directory "temp" presente sul server windows "nas01" su un sistema oparativo linux.
Per poterlo fare è necessario:

1. creare la directori di destinazione. Nel nostro caso: mkdir /mnt/temp
2. aggiungere la seguente riga al file /etc/fstab:

//nas01/temp /mnt/temp cifs user=nomedomino/username,password=xx123,rw,uid=username,gid=username 0 0

Automaticamente la directori verrà montata all'avvio come se fosse eseguito il mount manualmente.

Ulteriori informazioni:
http://wiki.centos.org/TipsAndTricks/WindowsShares

giovedì 23 febbraio 2012

PostgreSql - Impostazioni server per DataWarehouse


Significato dei principali paramentri di configurazione del server PostgreSql presenti nel file postgresql.conf e valorizzazione consigliata per applicazioni di tipo Data Warehouse.


fsync
Se questo parametro è attivo, il server PostgreSQL proverà ad assicurarsi che gli aggiornamenti siano scritti fisicamente su disco, eseguendo chiamate di sistema fsync() o vari metodi equivalenti (si veda wal_sync_method). Questo assicura che il cluster database possa recuperare a uno stato consistente dopo un blocco del sistema operativo o dell'hardware.
Mentre disabilitare fsync spesso è un beneficio in termini di prestazioni, questo può risultare in corruzione irrecuperabile dei dati in caso di blocco o arresto inaspettato del sistema. Così è consigliabile disabilitare fsync se è possibile ricreare facilmente l'intero database a partire da dati esterni.
Esempi di circostanze sicure per disabilitare fsync includono il caricamento iniziale di un nuovo cluster di database a partire da un file di backup, l'uso di un cluster per l'elaborazione di statistiche all'ora che vengono quindi ricreate, o per un clone in sola lettura del database che viene ricreato frequentemente e non viene usato per il failover. Hardware di alta qualità da solo non è sufficiente a giustificare la disabilitazione di fsync.
In molte situazioni, disabilitare synchronous_commit per le transazioni non critiche può fornire molti dei potenziali benefici equivalenti a disattivare fsync, senza i rischi collegati di corruzione di dati.
fsync può essere impostato solo nel file postgresql.conf o dalla linea di comando del server. Se di disabilita questo parametro, considerare anche la disabilitazione di full_page_writes.
Per datawarehouse valorizzato a off

synchronous_commit
Specifica se il commit della transazione aspetterà che i record WAL siano scritti su disco prima che il comando restituisca un indicazione di «successo» al client. L'impostazione predefinita, e sicura, è on. Quando impostato a off, ci può essere un ritardo tra quando viene riportato il successo al client e quando la transazione è veramente garantita essere sicura rispetto a un blocco del server. (Il massimo ritardo è tre volte wal_writer_delay). Diversamente da fsync, impostare questo parametro a off non crea nessun rischio di inconsistenza del database: un blocco del sistema operativo o del database potrebbe risultare nella perdita di alcune transazioni presumibilmente sottoposte a commit, ma lo stato del database sarà comunque lo stesso come se quelle transazioni fossero state annullate di recente. Quindi, disabilitare synchronous_commit può essere un'alternativa utile quando le prestazioni sono più importanti rispetto alla certezza assoluta sulla durabilità di una transazione.
Questo parametro può essere cambiato in qualsiasi momento; il comportamento per qualsiasi transazione è determinato dall'impostazione effettiva quando viene effettuato il commit. È inoltre possibile, e utile, avere alcune transazione che fanno il commit in modo sincrono e altre che lo fanno in modo asincrono. For example, to make a single multistatement transaction commit asynchronously when the default is the opposite, issue SET LOCAL synchronous_commit TO OFF within the transaction.
Per datawarehouse valorizzato a off

full_page_writes 
Quando questo parametro è attivo, il server PostgreSQL™ scrive l'intero contenuto di ogni pagina disco nel WAL durante la prima modifica di quella pagina dopo un checkpoint. Questo è necessario perchè la scrittura di una pagina che è in elaborazione durante un blocco del sistema operativo potrebbe essere completata solo parzialmente, portando a una pagina su disco che contiene un insieme di dati vecchi e nuovi. The row-level change data normally stored in WAL will not be enough to completely restore such a page during post-crash recovery. Storing the full page image guarantees that the page can be correctly restored, but at the price of increasing the amount of data that must be written to WAL. (Because WAL replay always starts from a checkpoint, it is sufficient to do this during the first change of each page after a checkpoint. Therefore, one way to reduce the cost of full-page writes is to increase the checkpoint interval parameters.)
Disabilitare questo parametro velocizza le operazioni normali, ma potrebbe portare o a una corruzione non recuperabile dei dati, o a una corruzione dei dati silenziosa, dopo un fallimento del sistema. I rischi solo simili a disabilitare fsync, sebbene minori, e dovrebbe essere disabilitato solo nelle stesse circostanze raccomandate per quel parametro.
Per datawarehouse valorizzato a off


max_connections 
Per datawarehouse scegliere un valore tra 10 e 40
 

shared_buffers (integer)

Imposta l'ammontare di memoria che il server database usa per i buffer di memoria condivisa. Il valore predefinito è tipicamente 32 megabyte (32MB), ma potrebbe essere meno se le impostazioni del kernel non lo supportano (come determinato durante l'initdb). Questa impostazione deve essere almeno 128 kilobytes. (Valori non predefiniti di BLCKSZ cambiano il minimo). Comunque, impostazioni significativamente maggiori rispetto al minimo sono di solito necessarie per buone prestazioni. Questo parametro può essere impostato solo all'avvio del server.
Se si ha un server database dedicato con 1GB o più di RAM, un valore di partenza ragionevole per shared_buffers è il 25% della memoria del sistema. Ci sono molti carichi di lavoro anche dove sono in vigore grandi valori per shared_buffers, ma dato chePostgreSQL fa affidamento anche sulla cache del sistema operativo, è improbabile che un'allocazione di più del 40% della RAM per shared_buffers funzionerà meglio rispetto a un quantitativo minore. Impostazioni più grandi per shared_buffers di solito richiedono un incremento corrispondente in checkpoint_segments, per diffondere il processo di scrittura di grandi quantità di dati nuovi o cambiati in un periodo di tempo più lungo.
Su sistemi con meno di 1GB di RAM, una percentuale di RAM più piccola è appropriata, quindi da lasciare spazio adeguato per il sistema operativo. Inoltre, su Windows, valori grandi per shared_buffers non sono così efficaci. Si potrebbero avere risultati migliori mantenendo il valore relativamente basso e usando maggiormente la cache del sistema operativo. L'intervallo utile pershared_buffers su sistemi Windows è generalmente da 64MB a 512MB.
Incrementare questo parametro potrebbe causare che PostgreSQL richieda più memoria System V condivisa rispetto a quello che permette il valore predefinito del sistema operativo. Si veda la sezione «Memoria condivisa e semafori» della guida per informazioni su come aggiustare questi parametri, se necessario. 
¼ of RAM

work_mem
Specifica l'ammontare di memoria che deve essere usata da operazioni di ordinamento interne e dalle tabelle hash prima di scrivere in file disco temporanei. Il valore predefinito è un megabyte (1MB). Si noti che per una query complessa, diverse operazioni di ordinamento o hash potrebbero essere eseguite in parallelo; ogni operazione potrà usare tanta memoria quanto specificato da questo valore prima che cominci a scrivere dati in file temporanei. Inoltre, diverse sessioni in esecuzione potrebbero fare tali operazioni concorrentemente. Perciò, la memoria totale usata potrebbe essere molte volte più grande di work_mem; è necessario tenerlo a mente quando si sceglie il valore. Operazioni di ordinamento sono usate per ORDER BY, DISTINCT e join merge. Hash tables are used in hash joins, hash-based aggregation, and hash-based processing of IN subqueries.
128MB to 1GB
 

maintenance_work_mem (integer)


Specifica l'ammontare di mamoria massimo da usare per operazioni di manutenzione, tipo VACUUM, CREATE INDEX e ALTER TABLE ADD FOREIGN KEY. Il valore predefinito è 16 megabyte (16MB). Dato che solo una di queste operazioni può essere eseguita alla volta da una sessione di database, e normalmente un'installazione non ne ha molte in esecuzione consorrentememte, è sicuro impostare questo valore significativamente maggiore rispetto a work_mem. Valori maggiori potrebbero aumentare le prestazioni del vacuum e del ripristino dei dump del database.
Si noti che quando autovacuum è in esecuzione, questa memoria potrebbe essere allocata autovacuum_max_workers volte, quindi fare attenzione a non impostare un valore predefinito troppo alto.
512MB to 1GB
 

temp_buffers 
Imposta il massimo numero di butter temporanei usati da ogni sessione di database. Questi sono buffer locali alla sessione usati solo per accedere a tabelle temporanee. Il valore predefinito è otto megabyte (8MB). L'impostazione può essere cambiata all'interno di sessioni individuali, ma solo prima del primo utilizzo di tabelle temporanee all'interno della sessione; tentativi successivi di cambiare il valore non avranno effetto su quella sessione.
Una sessione allocherà buffer temporanei come richiesto dal limite fornito da temp_buffers. Il costo di impostare un valore grande in sessioni che effettivamente non necessitano di molti buffer temporanei è solo quello di un destrittore di buffer, o circa 64 byte per incremento in temp_buffers. Comunque se un buffer è effettivamente usato, 8192 byte aggiuntivi saranno consumati (o in generale,BLCKSZ byte). 
128MB to 1GB 

effective_cache_size 
¾ of RAM
 

wal_buffers
L'ammontare di memoria usata nella memoria condivisa per dati WAL. Il valore predefinito è 64 kilobyte (64kB). L'impostazione necessita solo di essere larga abbastanza per contenere l'ammontare di dati WAL generati da una transazione tipica, dato che i dati sono scritto fuori dal disco ad ogni commit di transazione. Questo parametro può essere impostato solo all'avvio del server.
Incrementare questo parametro potrebbe causare che PostgreSQL richieda più memoria condivisa System V rispetto a quello che permette la configurazione predefinita del sistema operativo.
16MB 

venerdì 10 febbraio 2012

PostgreSql - Gestione utenti, esempi di grant

Creazione utente: 

create user pippo with password 'pippo'
Gestione grant:
  • per poter usare lo schema:
GRANT USAGE ON SCHEMA dwh to sce
  • per poter creare tabelle nello schema
GRANT CREATE ON SCHEMA dwh to sce
  • possibilità di leggere tutte le tabelle dello schema
GRANT SELECT ON ALL TABLES IN SCHEMA dwh to sce
  • possibilità di leggere la tabella specifica
GRANT SELECT ON dwh.fct_booking to sce

giovedì 12 gennaio 2012

SpagoBI - Personalizzare pagina di login

Per personalizzare la pagina di login è necessario editare il file login.jsp dentro la cartella
apache-tomcat-6.0.33\webapps\SpagoBI\WEB-INF\jsp\wapp

lunedì 9 gennaio 2012

mercoledì 28 dicembre 2011

MDX - Calcoli utili

Valore nel periodo corrispondente dell'anno precedente
([Measures].[Ven], ParallelPeriod([Calendario.Calendario Castoldi].[Anno],1,[Calendario.Calendario Castoldi].CurrentMember))

Indice rispetto all'anno
[Measures].[Ven]/([Measures].[Ven], Ancestor([Calendario.Calendario Castoldi].CurrentMember, [Calendario.Calendario Castoldi].[Anno]))
 
Indice rispetto a tutti gli articoli
[Measures].[Ven]/([Measures].[Ven], [Articolo].[Tutti gli articoli])


venerdì 23 dicembre 2011

SpagoBI - Deploy Cubo JPivot

Passi da eseguire per il deploy di un nuovo cubo:

(1) Innanzitutto è necessario impostare il valore della variabile "spagobi_resource_path" nel file \apache-tomcat\conf\server.xml con tutto il percorso
<Environment name="spagobi_resource_path" type="java.lang.String" value="C:/SpagoBI/apache-tomcat-6.0.33/resources"/>
(2) creare lo schema (esempio.xml)
(3) aggiungere lo schema esempio.xml alla cartella  \apache-tomcat\resources\Olap
(4) modificare il file \apache-tomcat\webapps\SpagoBIJPivotEngine\WEB-INF\classes\engine-config.xml aggiungendo le informazioni relative al nuovo schema
<SCHEMAS> 
<SCHEMA catalogUri="/Olap/esempio.xml" name="esempio" /> 
 </SCHEMAS>
(5) riavviare Spago e aggiungere un nuovo documento OLAP

olapdoc.png

mercoledì 14 dicembre 2011

PostgreSQL - Generare dim_calendar

Breve script per generare una semplice dimensione temporale (calendario) con posgres utile in ogni datawarehouse:

create table stg.dim_calendar as
select to_char( to_date('20000101', 'YYYYMMDD') + s, 'YYYYMMDD')::int8 as dw_id_calendar,
(to_date('20000101', 'YYYYMMDD') + s)::timestamp as timestamp,
(to_date('20000101', 'YYYYMMDD') + s) as date,
to_char( to_date('20000101', 'YYYYMMDD') + s, 'YYYYMMDD')::varchar as YYYYMMDD,
to_char( to_date('20000101', 'YYYYMMDD') + s, 'YYYYMM')::varchar as YYYYMM,
to_char( to_date('20000101', 'YYYYMMDD') + s, 'YYYY')::varchar as Year,
to_char( to_date('20000101', 'YYYYMMDD') + s, 'Q')::int4 as Quarter,
to_char( to_date('20000101', 'YYYYMMDD') + s, 'MM')::int4 as Month,
to_char( to_date('20000101', 'YYYYMMDD') + s, 'Mon') as Month_name,
to_char( to_date('20000101', 'YYYYMMDD') + s, 'W')::int4 as Week_of_month,
to_char( to_date('20000101', 'YYYYMMDD') + s, 'WW')::int4 as Week_of_year,
to_char( to_date('20000101', 'YYYYMMDD') + s, 'DD')::int4 as Day_of_month,
to_char( to_date('20000101', 'YYYYMMDD') + s, 'D')::int4 as Day_of_week,
to_char( to_date('20000101', 'YYYYMMDD') + s, 'Dy') as Day_of_week_name,
to_char( to_date('20000101', 'YYYYMMDD') + s, 'DDD')::int4 as Day_of_year
from generate_series(0, 7300) s

Japser - Gestione dei parametri: $P{}, $P!{}, $X{}

$P{} 
Using $P{} in the report query is for situations where the query is fixed at design time and you only wish to inject values into the query before it is executed. The example does not illustrate this concept, however the $X{} explained shortly works with a similar concept.
When using $P{} you do something like the following:
    
   SELECT * FROM Address WHERE city = $P{customerId}
     
 
If we changed the query in this way and turned on Debugging for the JRJdbcQueryExecuter in an application running this report, we would get an output like this (the hosting application also collected the value for the parameter and supplied it to JasperReports when it was time to Fill the report):
  
    SELECT * FROM Address WHERE city = ?
    Parameter #1 (city of type java.lang.String): New York
     
In this case the query as seen above and the parameter are passed to the database via the JDBC Driver (MySQL in this example) to be executed.
As report developers we don't have to worry about adding quotes around the String value for city in the query as that will be done for us.
This illustrates one way of injecting values into the query. 

$P!{} 
Using $P!{} allows you to modify the query syntax itself. The query in the sample uses this:
    
     SELECT * FROM Address WHERE $X{NOTIN, City, ExcludedCities} ORDER BY $P!{OrderClause}
     
 
If we run the report in an application and collect values for the parameters (OrderBy was given the value 'LastName') we will see an output like this:
    
    SELECT * FROM Address WHERE City NOT IN (?) ORDER BY LastName
    Parameter #1 (ExcludedCities[0] of type java.lang.String): New York
     
 
Here we can see the value of $P!{OrderClause} was added into the query directly by JasperReports. For this reason, when working with $P!{} you must ensure any values collected will not result in a syntax error in the query as they will be inserted directly into the query. However this does give us the power to modify the query entirely. For example we could have set the whole 'ORDER BY' clause using $P!{}, or chosen to omit it entirely. 

$X{} 

There are also cases when just using $P{} in the report query is not enough, because parts of the query need to be dynamically built, depending on one or more report parameter values, in order to construct a valid query. The most common case is the <column_name> = $P{<param_name>} equality clause. When the value of the parameter is null, the expression <column_name> = NULL becomes invalid and it has to be replaced with <column_name> IS NULL. Another case comes with IN and NOT IN query clauses that need to use a collection report parameter as a list of values, unavailable for the simple $P{} syntax. 
Such complex query clauses are introduced into the query using the $X{} syntax. The general form of a $X{} clause is $X{functionName, param1, param2,...}. 
Similar to the $P{} explanation above, $X{} results in ? being added to the query before submitting it to the DB. Also submitted are the values collected leaving it to the JDBC driver to add the values in and ensure the syntax of the query is correct.


Built-in SQL Clause Functions 

As shown above, complex queries generation might depend on parameter values. JasperReports provides built-in support for several SQL clause functions which require some additional processing:
  1. The ${EQUAL, <column_name>, <parameter_name>} clause function 

    The function expects three mandatory clause tokens:
    • The first token represents the function ID and always takes the fixed value EQUAL.
    • The second token is the SQL column (or column combination) to be used in the clause.
    • The third token is the name of the report parameter that contains the value to compare to.
    If the parameter's value is not null, the function constructs a <column_name> = ? clause. 
    If the parameter's value is null, the function generates a <column_name> IS NULL clause. 
     
  2. The ${NOTEQUAL, <column_name>, <parameter_name>} clause function 

    The function expects three mandatory clause tokens:
    • The first token represents the function ID and always takes the fixed value NOTEQUAL.
    • The second token is the SQL column (or column combination) to be used in the clause.
    • The third token is the name of the report parameter that contains the value to compare to.
    If the parameter's value is not null, the function constructs a <column_name> <> ? clause. 
    If the parameter's value is null, the function generates a <column_name> IS NOT NULL clause. 
     
  3. The ${LESS, <column_name>, <parameter_name>} clause function 

    The function expects three mandatory clause tokens:
    • The first token represents the function ID and always takes the fixed value LESS.
    • The second token is the SQL column (or column combination) to be used in the clause.
    • The third token is the name of the report parameter that contains the value to compare to.
    If the parameter's value is not null, the function constructs a <column_name> < ? clause. 
    If the parameter's value is null, the comparison with null will be neglected and the function generates a SQL clause that will always evaluate to true (e.g. 0 = 0). 

    Note: If the comparison with null (which always return false) should not be ignored, then one can use the <column_name> < $P{<parameter_name>} instead. 
     
  4. The ${LESS], <column_name>, <parameter_name>} clause function 

    The function expects three mandatory clause tokens:
    • The first token represents the function ID and always takes the fixed value LESS].
    • The second token is the SQL column (or column combination) to be used in the clause.
    • The third token is the name of the report parameter that contains the value to compare to.
    If the parameter's value is not null, the function constructs a <column_name> <= ? clause. 
    If the parameter's value is null, the comparison with null will be neglected and the function generates a SQL clause that will always evaluate to true (e.g. 0 = 0). 

    Note: If the comparison with null (which always return false) should not be ignored, then one can use the <column_name> <= $P{<parameter_name>} instead. 
     
  5. The ${GREATER, <column_name>, <parameter_name>} clause function 

    The function expects three mandatory clause tokens:
    • The first token represents the function ID and always takes the fixed value GREATER.
    • The second token is the SQL column (or column combination) to be used in the clause.
    • The third token is the name of the report parameter that contains the value to compare to.
    If the parameter's value is not null, the function constructs a <column_name> > ? clause. 
    If the parameter's value is null, the comparison with null will be neglected and the function generates a SQL clause that will always evaluate to true (e.g. 0 = 0). 

    Note: If the comparison with null (which always return false) should not be ignored, then one can use the <column_name> > $P{<parameter_name>} instead. 
     
  6. The ${[GREATER, <column_name>, <parameter_name>} clause function 

    The function expects three mandatory clause tokens:
    • The first token represents the function ID and always takes the fixed value [GREATER.
    • The second token is the SQL column (or column combination) to be used in the clause.
    • The third token is the name of the report parameter that contains the value to compare to.
    If the parameter's value is not null, the function constructs a <column_name> >= ? clause. 
    If the parameter's value is null, the comparison with null will be neglected and the function generates a SQL clause that will always evaluate to true (e.g. 0 = 0). 

    Note: If the comparison with null (which always return false) should not be ignored, then one can use the <column_name> >= $P{<parameter_name>} instead. 
     
  7. The ${BETWEEN, <column_name>, <left_parameter_name>, <right_parameter_name>} clause function 

    The function expects four mandatory clause tokens:
    • The first token represents the function ID and always takes the fixed value BETWEEN.
    • The second token is the SQL column (or column combination) to be used in the clause.
    • The third token is the name of the parameter that contains the left member value.
    • The fourth token is the name of the parameter that contains the right member value.
    If both parameter values are not null, the function constructs a double comparison, similar to the BETWEEN SQL clause where both interval endpoints are excluded: (<column_name> > ? AND <column_name> < ?) 
    If the left parameter's value is null, the function constructs a <column_name> < ? clause, using the right parameter's value at fill time. 
    If the right parameter's value is null, the function constructs a <column_name> > ? clause, using the left parameter's value at fill time. 
    If both parameter values are null, the function generates a SQL clause that will always evaluate to true (e.g. 0 = 0). 
     
  8. The ${[BETWEEN, <column_name>, <left_parameter_name>, <right_parameter_name>} clause function 

    The function expects four mandatory clause tokens:
    • The first token represents the function ID and always takes the fixed value [BETWEEN.
    • The second token is the SQL column (or column combination) to be used in the clause.
    • The third token is the name of the parameter that contains the left member value.
    • The fourth token is the name of the parameter that contains the right member value.
    If both parameter values are not null, the function constructs a double comparison, similar to the BETWEEN SQL clause where the left interval endpoint is included and the right endpoint is excluded: (<column_name> >= ? AND <column_name> < ?) 
    If the left parameter's value is null, the function constructs a <column_name> < ? clause, using the right parameter's value at fill time. 
    If the right parameter's value is null, the function constructs a <column_name> >= ? clause, using the left parameter's value at fill time. 
    If both parameter values are null, the function generates a SQL clause that will always evaluate to true (e.g. 0 = 0). 
     
  9. The ${BETWEEN], <column_name>, <left_parameter_name>, <right_parameter_name>} clause function 

    The function expects four mandatory clause tokens:
    • The first token represents the function ID and always takes the fixed value BETWEEN].
    • The second token is the SQL column (or column combination) to be used in the clause.
    • The third token is the name of the parameter that contains the left member value.
    • The fourth token is the name of the parameter that contains the right member value.
    If both parameter values are not null, the function constructs a double comparison, similar to the BETWEEN SQL clause where the left interval endpoint is excluded and the right endpoint is included: (<column_name> > ? AND <column_name> <= ?) 
    If the left parameter's value is null, the function constructs a <column_name> <= ? clause, using the right parameter's value at fill time. 
    If the right parameter's value is null, the function constructs a <column_name> > ? clause, using the left parameter's value at fill time. 
    If both parameter values are null, the function generates a SQL clause that will always evaluate to true (e.g. 0 = 0). 
     
  10. The ${[BETWEEN], <column_name>, <left_parameter_name>, <right_parameter_name>} clause function 

    The function expects four mandatory clause tokens:
    • The first token represents the function ID and always takes the fixed value [BETWEEN].
    • The second token is the SQL column (or column combination) to be used in the clause.
    • The third token is the name of the parameter that contains the left member value.
    • The fourth token is the name of the parameter that contains the right member value.
    If both parameter values are not null, the function constructs a double comparison, similar to the BETWEEN SQL clause where both interval endpoints are included: (<column_name> >= ? AND <column_name> <= ?) 
    If the left parameter's value is null, the function constructs a <column_name> <= ? clause, using the right parameter's value at fill time. 
    If the right parameter's value is null, the function constructs a <column_name> >= ? clause, using the left parameter's value at fill time. 
    If both parameter values are null, the function generates a SQL clause that will always evaluate to true (e.g. 0 = 0). 
     
  11. The ${IN, <column_name>, <parameter_name>} clause function 

    The function expects three mandatory clause tokens:
    • The first token represents the function ID and always takes the fixed value IN.
    • The second token is the SQL column (or column combination) to be used in the clause.
    • The third token is the name of the report parameter that contains the value list. The value of this parameter has to be an array, a java.util.Collection or null.
    If the parameter's value is a collection of not null values, the function constructs a <column_name> IN (?, ?, .., ?) clause 
    If the parameter's value is a collection containing both null and not null values, the function constructs a (<column_name> IS NULL OR <column_name> IN (?, ?, .., ?)) clause 
    If the parameter's value is a collection containing only null values, the function constructs a <column_name> IS NULL clause 
    If the parameter's value is null, the function generates a SQL clause that will always evaluate to true (e.g. 0 = 0). 
     
  12. The ${NOTIN, <column_name>, <parameter_name>} clause function 

    The function expects three mandatory clause tokens:
    • The first token represents the function ID and always takes the fixed value NOTIN.
    • The second token is the SQL column (or column combination) to be used in the clause.
    • The third token is the name of the report parameter that contains the value list. The value of this parameter has to be an array, a java.util.Collection or null.
    If the parameter's value is a collection of not null values, the function constructs a <column_name> NOT IN (?, ?, .., ?) clause 
    If the parameter's value is a collection containing both null and not null values, the function constructs a (<column_name> IS NOT NULL AND <column_name> NOT IN (?, ?, .., ?)) clause 
    If the parameter's value is a collection containing only null values, the function constructs a <column_name> IS NOT NULL clause 
    If the parameter's value is null, the function generates a SQL clause that will always evaluate to true (e.g. 0 = 0).

SpagoBI e Jasper: parametri multi valore

La sintassi $X{ <IN o NOTIN>, <colonna>, <parametro>} con SpagoBI NON funziona...

Per utilizzare i parametri multi valore è necessario definire un driver anlitico su sSpagoBI di tipo stringa e associare come modalità di prompt la cheklist in modo da permettere all'utente di selezionare più valori
Nel report è necessario definire il parametro di tipo stringa e usarlo nella query in questo modo:
select * from xxx
where cod IN ($P!{codici})

martedì 6 dicembre 2011

SpagoBI - Installazione su Oracle

http://spagobi.blogspot.com/2010/06/how-to-config-spagobi-with-oracle.html



Modificare il dialetto hibernate nel file jbpm.hibernate.cfg.xml che si trova in \webapps\SpagoBI\WEB-INF\classes 
mettendo: org.hibernate.dialect.OracleDialect

vedere anche:

http://www.spagoworld.org/jforum/posts/list/255.page



This document records the steps to install and config the Oracle database connection as reporting data source in SpagoBI. 

You can config the database connection using JNDI resource that is shared between reporting applications; or you can config JDBC data source connection, so, a new JDBC connection (non-shareable) will be created for each of reporting applications (document) execution.


Environment
============
SpagoBI: version 2.5
OS Server: Windows server 2008 R2 (x64)
App Server: Tomcat 6.0.18 (in the SpagoBI demo package)
Oracle database: 11g R2 (for windows x64)
JDBC driver: ojdbc5.jar (for JDK 1.5 or up) 
Java: JDK 1.6.0_20

1. Create JNDI Data Source Connection

1) Download and unzip the file "Demo-SpagoBI-2.5.0-apache-tomcat-6.0.18-04092010.zip" to your local folder (liketomcathome\);
2) Copy the Oracle jdbc driver file "ojdbc5.jar" to your tomcathome\lib folder;
3) Edit the file "server.xml" at the folder "tomcathome\conf" and add / edit the following items:


4) Edit the file "context.xml" at the folder "tomcathome\webapps\SpagoBI\META-INF" as showing below:


5) Edit the file "context.xml" at the folder "tomcathome\webapps\SpagoBIJasperReportEngine\META-INF" as showing below:



6) Modificare in modo opportuno il dialetto hibernate nei file "jbpm.hibernate.cfg.xml" e "hibernate.cfg.xml" (lo trovi in \webapps\SpagoBI\WEB-INF\classes)

7) Start Tomcat server to enable the above changes;

8) Log on to SpagoBI at http://localhost:8080/SpagoBI to create a data source connection:

Click "Resources" -> "Data Source"


Click Insert button (icon) to add a new data source


Enter the settings for the new data source


Test the new connection before you save and exit.



2. Create JDBC Connection

1) Download and unzip the file "Demo-SpagoBI-2.5.0-apache-tomcat-6.0.18-04092010.zip" to your local folder (liketomcathome\);
2) Copy the Oracle jdbc driver file "ojdbc5.jar" to your tomcathome\lib folder;
3) Start Tomcat server to enable the above changes;
4) Log on to SpagoBI at http://localhost:8080/SpagoBI to create a data source connection:

Click "Resources" -> "Data Source"


Click Insert button (icon) to add a new data source


Enter the settings for the new data source


Test the new connection before you save and exit.