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 (159)
package body : BBAN_IBAN_BIC_Body.sql (156)

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 (247)

Written by admin in: oracle | 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 :, , , ,
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 (111)
belgian translation : translate_be (261)

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 :, , ,