Feeds, issues, packages and code source about emulation and pograming, of VENENUX proyects, Debian related distros and massenkoh!

mysql to sybase : ISNULL vs. COALESCE

In MySQL, and also Transact-SQL (Sybase or SQLServer), you can use both ISNULL and COALESCE to use a default in case you have NULL values:
select IFNULL('pepe', 123);

For right interaction with proxy-tables in SAP Sybase, must use better than null simple check:

USE COALESCE: due is ANSI standard. So if you think you might have to port the code to another DBMS, it’s a safer bet. Works as espected in both sybase and mysql, also another stupid like micosoft.

AVOIT ISNULL: due in MySQL returns boolean depends of configuration an version. This boolean if the result are miscinterpreted can be trheated as "0" char and think if zero value. Sybase does not assume "question" behavior, whientime MySQL assumes a "question" like "this fiel are null "or not" and return "true" (yes its null) or false (no ther'n).

The problem resides in that coalesce it for experts...
sybase> select IFNULL('pepe', 123);

mysql> select IFNULL('pepe', 123);

here with coalesce in mysql expected are good:
sybase> select COALESCE('pepe', 123);

mysql> select COALESCE('pepe', 123), ;


SCHEME vs REAL DB: how to change on fly codeigniter DB with one config

Codeigniter has methos to access and manage CURRENT configured database.

SPANISH version of this : https://groups.google.com/forum/m/#!topic/venenuxsarisari/jTP0zhLQHOY

There's no method to change on the fly the "current selected db group", u must create one group per database and select it on the load, such as: 


where configdb1 its a stored array of database settings for connecting.

There's a hack 2way to dinamically choose database on the fly in the controller with one configuration.

1) configure a database group array but only in the config.php file
2) load all the varables and extrac the array of u'r db configuratio
3) change the "database" key value to the new
4) re - load the database library with the "changed" settings

a example quick code:

1) go to application/config.php :

$config['sysdb'] =  array(
'database'=>'', /* this will be changed "on the fly" in controler */

2) now in u'r controller made "each time u want to change" a database name with same connections parameters:

$configdbfly = $this->config->config['sysdb'];
$configdbfly['database']='sysdbadminis'; /*cambiamos de db*/
IMPORTANT: the undocumented "$this->config->config" are subject to change and could not be available at the lasted version, but the item can be acceced manually.