martedì 27 settembre 2011

Excel determinare le difference tra due fogli

Tramite una formula di Excel che confronta celle corrispondenti di una stessa riga è possibile determinare se una riga è stata variata
eseguendo la seguente formula :   

lunedì 29 agosto 2011

OCPJP SCJP CX-310-065 Certification Exams examples sources.


In attatchment zip with some source example for OCP JP SCJP.

Zipped as ecplise project.

lunedì 22 agosto 2011

Clear content of users tables reviewd with exception handling

begin for t in (select table_name from user_tables) loop BEGIN execute immediate 'TRUNCATE table '||TRIM(t.table_name); EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.put_line (' ERROR '); END; end loop; end;

venerdì 19 agosto 2011

Oracle total size of tables


Using the fooling SQL command in SQL Plus or TOAD:

SELECT SUM(BYTES) FROM USER_SEGMENTS WHERE SEGMENT_TYPE='TABLE';

this is the result


giovedì 21 luglio 2011

Clear content of users tables

begin for t in (select table_name from user_tables) loop execute immediate ' truncate table '||t.table_name; end loop; end;

Retrieve and set Oracle Charset


Retrieving

SELECT value$ FROM sys.props$ WHERE name = 'NLS_CHARACTERSET' ;


Settiing

ALTER DATABASE CHARACTER SET WE8ISO8859P1;


Usefull in exp imp command beetwen differente oracle databases with different charset.


 

mercoledì 29 giugno 2011

redirect jsp response to pdf file in file system

<%@ page import="java.io.*" %>
<%@ page language="java" session="false" %>
<%@ page contentType="application/pdf" %>
<%
String file = request.getParameter("file");
String filename = request.getParameter("filename");
response.setContentType("application/pdf");
response.addHeader("Content-Disposition","inline; filename=\""+filename+"\"" );
BufferedInputStream buf=null;
ServletOutputStream myOut=null;

try{

myOut = response.getOutputStream( );
File myfile = new File(file);

//set response headers


response.setContentLength( (int) myfile.length( ) );

FileInputStream input = new FileInputStream(myfile);
buf = new BufferedInputStream(input);
int readBytes = 0;

//read from the file; write to the ServletOutputStream
while((readBytes = buf.read( )) != -1)
myOut.write(readBytes);

} catch (IOException ioe){

throw new ServletException(ioe.getMessage( ));

} finally {

//close the input/output streams
if (myOut != null)
myOut.close( );
if (buf != null)
buf.close( );

}


%>Example of calling is :

pdf.jsp?file=C:\temp\a.pdf&filename=a.pdf

martedì 3 maggio 2011

MSAccess test/check vowels for last letter of a field.

Here is the example :


SELECT ClientiFunzioniCustom.[Funzione] FROM FunzioniCustom where
MID(TRIM(FunzioniCustom.[Funzione]),LEN(TRIM(FunzioniCustom.[Funzione])),LEN(TRIM(FunzioniCustom.[Funzione]))+1) Not  in('A','E','I','O','U');

MSAccess SQL Capitalize

To capialize a string of a field you should use API STRCONV
like following example :
SELECT DISTINCT(STRCONV(FunzioniCustom.[Funzione],3)) FROM FunzioniCustom;

giovedì 17 febbraio 2011

DECODE & dual for DB2

DECODE from oracle
-- SELECT CASE MESE WHEN '02' THEN 'Febbraio' WHEN '03' THEN 'Marzo'
WHEN '04' THEN 'Aprile' ELSE 'Boh' END from MESI


Dual from Oracle is SYSIBM.SYSDUMMY1 for DB2
-- SELECT 'CIAO' FROm SYSIBM.SYSDUMMY1

martedì 15 febbraio 2011

Create FDF with password using iText

Create FDF with password using java and itext.
In this site good tutorial.

in riferimento a: iText in Action: example part3.chapter09.CreateFDF (visualizza su Google Sidewiki)

lunedì 31 gennaio 2011

Oracle objects determine creation date

<code type="sql">
select OWNER, OBJECT_NAME, to_char(CREATED,'MM/DD/YYYY HH24:MI:SS')
created, status from dba_objects
where OWNER in ('MYSCHEMA') and OBJECT_TYPE='VIEW'
order by OWNER,OBJECT_NAME
</code>

giovedì 20 gennaio 2011

Java StackStrace to String

<code type="java">
catch (Exception e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
System.out.println(sw.toString().toUpperCase());
}
</code>

martedì 11 gennaio 2011

Return Userdn form a LDAP search

<code type="java">
SearchResult searchResult = null;
if (namEnum.hasMore()) {
searchResult = (SearchResult) namEnum.next();

// Build the User DN
userDN = searchResult.getName() + "," + sAPPEND_BASE_DN;
} else {
// User not found
throw new NamingException(" Invalid Username ");
}
System.out.println("User DN="+userDN);
</code>