août
17
2009
1

Just 4 fun

Written by admin in: Non classé |
juil
13
2009
0

BBAN to IBAN (Oracle – only Belgian’s Codes)

Here is a PL/SQL package that I’ve made to check and convert Belgian’s BBANs and IBANs codes whitin SQL queries.

package : BBAN_IBAN_BIC.sql (126)
package body : BBAN_IBAN_BIC_Body.sql (125)

You’ll need a table of BICs codes to get the BIC code out of BBAN and IBAN.

Download an updated version from :
http://www.bnb.be/ « Systèmes de paiement »> »Standards de paiements »> »Codes d’identification des banques »

or you could use directly this one (at youre own risk) : BIC_Table.sql (204)

Written by admin in: oracle | Mots-clefs :, , , , , ,
juin
24
2009
10

Google Earth on fedora 11 64 bit

Here the way I follow to install and make work Google Earth on Fedora 11 x86-64:

First download the linux version of Google Earth at : http://earth.google.fr/

open a terminal and become root:

su -
yum install google*

with an nvidia card you’ll need:

yum install xorg-x11-drv-nvidia-libs*.i586 (search with software install gui if it doesn't work)

and for ati card (thanks to space-hunter):

yum install xorg-x11-drv-catalyst-libs.i586

you’ll need these 32 bit libraries for Google to run quietly

yum install glibc-2.10.1-2.i686 libxml2.i586 freetype.i586 libXrender.i586 libXrandr.i586 mesa-libGL.i586 xorg-x11-drv-nvidia-libs.i586

Additions from Otto Mäkelä :

yum install libcanberra-gtk2.i586 bug-buddy.i586 PackageKit-gtk-module.i586

Then run :

sh GoogleEarthLinux.bin

it’s all…

Written by admin in: linux | Mots-clefs :, , , ,
juin
05
2009
4

Oracle backup export script (cron job)

Here is script that I’ve created to make a logical backup of the entire database every day

######################### START OF SCRIPT #########################

#!/bin/bash
#Backup script by Cédric Sougné.
ORACLE_BASE=/opt/oracle
ORACLE_HOME=$ORACLE_BASE/product/db10g
ORACLE_SID=<yoursid>
PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export ORACLE_BASE ORACLE_HOME PATH ORACLE_SID

ADMIN_EMAIL= »<yourdbamail> »
LOGFILE=$ORACLE_BASE/admin/$ORACLE_SID/backup_logs/expdp-`date +%d%m%y%H%M%S`.log

EXPORT_PATH=/opt/oracle/export_backup
DMP_FILE= »expdp-`date + »%d%m%Y_%H%M%S »`.dmp »
LOG_FILE= »expdp-`date + »%d%m%Y_%H%M%S »`.log »

echo « Starting … » > $LOGFILE
expdp \’sys/<yousyspassword> as sysdba\’ FULL=y DIRECTORY=EXPORT_BACKUP_DIR DUMPFILE=$DMP_FILE LOGFILE=$LOG_FILE
#expdp mrmrs/mrmrs TABLES=resident,sejour DIRECTORY=EXPORT_BACKUP_DIR DUMPFILE=$DMP_FILE LOGFILE=$LOG_FILE
cat $EXPORT_PATH/$LOG_FILE >> $LOGFILE
echo « Backup Completed. » >> $LOGFILE

echo « gzipping … » >> $LOGFILE
gzip $EXPORT_PATH/$DMP_FILE >> $LOGFILE
echo « gzipping Completed. » >> $LOGFILE

echo « Deleting old files » >> $LOGFILE
find $EXPORT_PATH -type f -mtime +31 | xargs rm >> $LOGFILE
echo « Delete Completed » >> $LOGFILE

cat $LOGFILE | mail -s « expdp-`date + »%d%m%Y_%T »` » $ADMIN_EMAIL

######################### END OF SCRIPT #########################

here is for the cron tab:

00 22 * * * /opt/oracle/admin/acisora1/scripts/export_backup.sh >> /dev/null

the script will be executed avery at 10 pm

Written by admin in: bash, linux, oracle | Mots-clefs :, , , ,
juin
02
2009
4

Oracle from PHP on Centos 5

1) install apache, php …

yum install httpd php php-mysql php-pear php-devel zlib zlib-devel
yum groupinstall « Development Tools »

2) Download and install oracle instant client (basic and devel) from there:

http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html

rpm -Uvh oracle-instantclient-basic-<VERSION>.i386.rpm
rpm -Uvh oracle-instantclient-devel-<VERSION>.i386.rpm

3) Add the Oracle instant client to dynamic linker

echo /usr/include/oracle/<VERSION>/client/lib/ > /etc/ld.so.conf.d/oracle_client.conf
ldconfig -v

4) Untar the PECL package and prepare it for compiling

tar -xzvf oci-<VERSION>.tgz
cd oci-<VERSION>
phpize

5) Configure the PECL package as a shared object using the instant client and specifying where the Oracle client libraries are. Then build and install it.

./configure –with-oci8=shared,instantclient,/usr/lib/oracle/<VERSION>/client/lib
make
make install

6) Add the library shared object for PHP

echo extension=oci8.so > /etc/php.d/oci8.ini

7) Start Apache

’service httpd start’ _or_ ‘/etc/init.d/httpd restart’

8) Create a PHP info page and checked to see if the Oracle (oci8) driver is listed:

echo <? phpinfo(); ?> > /var/www/html/phpinfo.php

Written by admin in: linux, oracle, php | Mots-clefs :, , , ,
mai
06
2009
0

hide div while scrolling

Here is a trick that I’ve used in the intranet of my company that have an insane use of rdp protocol avor slow internet connections.

The problem was that scrolling down in web pages containing some images was incredibly slow in firefox. That was due to the redraw of image while scrolling so I’ve decided to find a trick to hide some parts of the page during the time of scrolling.

After adding the javascript code to your page, just add the class « scrollhide » to objects that you want hide when scrolling.

exemple of use:

<div class= »scrollhide »>text to hide while scrolling</div>

<img src= »./img/imagetohide » class= »scrollhide »/>

You could easily use it to what ever you want during the onscroll event.

!!! Tested with firefox 3 and IE 7 !!!

var curdate = new Date()
var lastOnscroll = curdate.getTime();

function getElementsByClass(searchClass,node,tag) {
    var classElements = new Array();
    if ( node == null )
        node = document;
    if ( tag == null )
        tag = '*';
    var els = node.getElementsByTagName(tag);
    var elsLen = els.length;
    var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
    for (i = 0, j = 0; i < elsLen; i++) {
        if ( pattern.test(els[i].className) ) {
            classElements[j] = els[i];
            j++;
        }
    }
    return classElements;
}

function timeHideBanner() {

    var newcurdate = new Date()
    if ((newcurdate.getTime() - lastOnscroll) > 200  ) {
        var myEls = getElementsByClass('scrollhide');
        for ( i=0;i<myEls.length;i++ ) {
        // do stuff here with myEls[i]
            myEls[i].style.visibility = 'visible';
        }
        //document.getElementById('banner').style.visibility = 'visible';
    }
}

function hideBanner() {
    var newcurdate = new Date()
    lastOnscroll = newcurdate.getTime();

    var myEls = getElementsByClass('scrollhide');
    for ( i=0;i<myEls.length;i++ ) {
    // do stuff here with myEls[i]
        myEls[i].style.visibility = 'hidden';
    }
    //document.getElementById('banner').style.visibility = 'hidden';
    var t=setTimeout("timeHideBanner()",300);
}

window.onscroll = function(){ hideBanner(); }

window.mouseup = function(){ document.getElementById('banner').style.visibility = 'visible'; }
Written by admin in: javascript | Mots-clefs :, , , ,
avr
27
2009
0

PDF to PNG,JPG…

Here is a little app to convert a pdf to multiple images in pdf format.

Just open pdf and then save selected page or all pages in a png file.

Dowload : Pdf2Img (87)

Written by admin in: Non classé | Mots-clefs :, , ,
avr
17
2009
1

convert numbers into words (belgian way)

Functions gived here comes initially from developpez.com but has been modified to convert numbers in the belgian way (septante,nonante) then I’ve added possibility to add devise like Euro.

Here comes downloadable files:
english numbers to words function(needed) : to_word_en (93)
belgian translation : translate_be (235)

examples:

TRANSLATE_BE(TO_WORD_EN(156.2),’euro’)
—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————-
cent cinquante-six euros et deux cents

1 rows selected

TRANSLATE_BE(TO_WORD_EN(1.01),’euro’)
—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————-
un euro et un cents

1 rows selected

Written by admin in: oracle | Mots-clefs :, , ,
avr
02
2009
0

MySQL group_contat in ORACLE

Here is a way to add the group_concat function to ORACLE. After that you’ll be able to do just like in MySQL.

first you’ll need to create a new object type:


create or replace TYPE t_string_agg AS OBJECT
(
g_string VARCHAR2(32767),

STATIC FUNCTION ODCIAggregateInitialize(sctx IN OUT t_string_agg)
RETURN NUMBER,

MEMBER FUNCTION ODCIAggregateIterate(self IN OUT t_string_agg,
value IN VARCHAR2 )
RETURN NUMBER,

MEMBER FUNCTION ODCIAggregateTerminate(self IN t_string_agg,
returnValue OUT VARCHAR2,
flags IN NUMBER)
RETURN NUMBER,

MEMBER FUNCTION ODCIAggregateMerge(self IN OUT t_string_agg,
ctx2 IN t_string_agg)
RETURN NUMBER
);

then create a function using the newly created type :


create or replace FUNCTION tring_concat (p_input VARCHAR2)
RETURN VARCHAR2
PARALLEL_ENABLE AGGREGATE USING t_string_agg;

now try it with SCOTT’s schema


COLUMN employees FORMAT A50

SELECT deptno, group_concat(ename) AS employees
FROM emp
GROUP BY deptno;

DEPTNO EMPLOYEES
---------- --------------------------------------------------
10 CLARK,KING,MILLER
20 SMITH,FORD,ADAMS,SCOTT,JONES
30 ALLEN,BLAKE,MARTIN,TURNER,JAMES,WARD

3 rows selected.

that could be quite useful to add this function to the SYS schema and then create a public synonym. this way the function will be available to any user of the database.

Written by admin in: oracle | Mots-clefs :, , ,
mar
20
2009
0

PLSQL functions for delimited strings

Here is a package containing functions to interact with delimited strings.

Download STR package (184)

the package is named STR and has to be placed in the SYS schema to be used anywhere in the database. Just compile it as sys then make a public synonym of it. Then you will be able to use functions this way:

select str.<thefunction>(<parameters>) from dual;

Here is a couple of cool stuffs that could be realized with this package (for full details download the package)

—————————————————————————————————–

Function will split a string.  The maximum size returnable
is 4000 bytes and up to 15 fields.
For Exammple:

SQL> select str.split(’a,b,c,d’,3,’,') from dual;
STR.SPLIT(’A,B,C,D’,3,’,')
——————————————————————————–
c

select str.split(’a,b,c,d’,3,’,') from dual;
@param in_del_field             string to be split
@param in_position              position of split character(s) to return
@param in_del                   delimter to split by
@return Returns a single value from a string, up to 4K long

FUNCTION split
(in_del_field  IN     VARCHAR2,
in_pos        IN     NUMBER,
in_del        IN     VARCHAR2)
RETURN VARCHAR2;

Type is a collection/array of values returned from the split_array function

TYPE tab_split IS TABLE OF VARCHAR2(4000);

—————————————————————————————————–

Funciton takes a string passed to it and returns it as a collection of the
type tab_split.  For Example

DECLARE
t_split str.tab_split := str.split_array('a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z',',');
i       INTEGER;
BEGIN
FOR i IN t_split.FIRST .. t_split.LAST LOOP
DBMS_OUTPUT.PUT_LINE(t_split(i));
END LOOP;
END;

@param in_del_field             string to be split
@param in_del                   delimter to split by
@return Returns an Array of type str.tab_split with a row for each delimited value in in_del_field.

FUNCTION split_array
(in_del_field  IN     VARCHAR2,
in_del        IN     VARCHAR2)
RETURN tab_split;

—————————————————————————————————–

Funciton takes a table of string passed to it and returns it as a delimited string.  For Example
DECLARE
t_split str.tab_split := str.split_array('a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z',',');
i       INTEGER;
BEGIN
FOR i IN t_split.FIRST .. t_split.LAST LOOP
DBMS_OUTPUT.PUT_LINE(t_split(i));
END LOOP;
END;

@param in_tab                   table to unsplit
@param in_del                   delimter to concat
@return Returns an Varchar2 string delimited by the in_del var passed.

FUNCTION unsplit_array
(in_tab  IN     tab_split,
in_del        IN     VARCHAR2)
RETURN VARCHAR2;

—————————————————————————————————–

Function replace a string in a delimited string at the position passed in parameter.  For Example
select str.replace_at_pos(’a,b,c,d,e,f,g,h,i’,2,’z',’,') from dual;
/
a,z,c,d,e,f,g,h,i
@param in_del_field             delimited string
@param in_pos                   position where to replace string
@param in_text                  string to put in place at pos
@param in_del                   delimter to split by
@return Returns an Varchar2 string delimited by the in_del var passed.

FUNCTION replace_at_pos
(in_del_field  IN     VARCHAR2,
in_pos        IN     NUMBER,
in_text       IN     VARCHAR2,
in_del        IN     VARCHAR2)
RETURN VARCHAR2;

—————————————————————————————————–

Pipelined Function returns a table of one column with the deleminted string
passed to it.  For example, you could do the following to return a table of
the alphabet…

SELECT *
FROM TABLE(str.split_pipe('a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z',','))

@param in_del_field             string to be split
@param in_del                   delimter to split by
@return Returns a Piplined Table of Table Type tab_str with a row for each delimited value in in_del_field.
FUNCTION split_pipe
(in_del_field  IN     VARCHAR2,
in_del        IN     VARCHAR2)
RETURN tab_str PIPELINED;

download the package Download STR package (184)

Written by admin in: oracle | Mots-clefs :, , ,