Thursday, June 19, 2008

vicidial installation slang.h required

During the installation of vicidial astguiclient a package newt (version 0.51.6 - that may b latest) need to be installed. While configuring the package and making the make file by make command the error comes (in fact list of errors will be there) which shows that the slang.h is needed for making the file.
(I faced this issue at least 3 time while installation of vicidial)
the solution for that is quit simple, but i couldn't found on net.
You need to have slang-devel installed. To do so you can run yum install slang-devel.
that' it. compile that again and there will be no error in compilation of the newt package.
don't forget to make clean before ./configure and make commnads.

Wednesday, June 18, 2008

How to get table structure in Oracle?

There is one data dictionary table called user_tab_columns which store metadata about table.
In this the column_name, data_type and data_length are usually we want.
For this purpose.

SQL> set lines 200
SQL> select column_name,data_length,data_type from user_tab_columns where table_name = 'DEPT';

Output of above query will show following metadata of DEPT table.

COLUMN_NAME DATA_LENGTH DATA_TYPE
------------------------------ ----------- -------------------
DEPTNO 22 NUMBER
DNAME 14 VARCHAR2
LOC 13 VARCHAR2

Saturday, June 14, 2008

Get the date difference in the php (date_diff)

Get the difference between two dates in the php.
A custom function to get the date difference.

function get_datediff($dated_elimiter, $date_end, $date_start)
{
$arr_date_start=explode($dateformat, $date_start); //explode the start date by the delimiter
$arr_date_end=explode($dateformat, $date_end); //explode the start date by the delimiter
$startdate_greg=gregoriantojd($arr_date_start[1], $arr_date_start[2], $arr_date_start[0]); //use php function to converts a Gregorian date to Julian day count
$enddate_greg=gregoriantojd($arr_date_end[1],$arr_date_end[2],$arr_date_end[0]);
return $enddate_greg - $startdate_greg; // get the difference between the date
}

Now, let's get this code in action -

$date_end ="1986-10-06"; //value of the start date from where you want to start
$date_start= "1985-10-06"; //value of the start date up to where you want to count
$date_delimiter='-'; // the delimiter of date u can use - , / here depending on your date format

$datediff = get_datediff($date_delimiter, $date_end, $date_start); //call the fuction

$datediff variable will display the difference of the date in term of day.

Further, you can customize this function as per your requirement of date format ... cheers!!!!

Tuesday, June 10, 2008

How to spool data in Excel file?

Hi friends, sometimes we require to spool or export resultset of sql query in excel file without using third party tool. Here is very simple example of How to spool data in Excel file?
Excample:
SQL> spool c:\dept.csv
SQL> select dname || ',' || deptno from dept;

DEPTNO','DNAME
--------------------------------------------------------------------------------
10,ACCOUNTING
20,RESEARCH
30,SALES
40,OPERATIONS

SQL> spool off

Hope this will help you.

Friday, May 30, 2008

CDR Report Monthly Traffic

The CDR report is fantastic tool for getting call statistics on for your Asterisk.
I was configuring that for my Asterisk. I have installed the version asterisk-stat-v2_0_1 on my machine.

While testing I found the MONTHLY TRAFFIC, Pie chart inconsistence.
It is showing the proper values in the PIE CHART but the colors are not coming properly as it should.
Well, the values are coming properly, March 2008 is having 390 mins and pie hart shows it as 97%, but the color of that block of pie doesn't match, as shown below.

After much debugging I found the solution for that and it is to revert the array which feeds the data to the graph.
The pie graph is getting generated in graph_pie.php
In this file the $data is used to generate the graph (i.e it is passed in the class PieGraph).

So in order to get proper colors according to the you just need to revert the array before it get passed to the class ;)

Well, this may be probably a bug or overlooked while designing.
If you found any bugs and want to have solutions of other bugs I have found and fixed, just drop me a mail.
You will have solution in mail...

Friday, May 23, 2008

Enabling Archive Log Mode

Create two directories in Linux
$mkdir $oracle_home/archive1
$mkdir $oracle_home/archive2

Connect with sqlplus as SYS
sql> conn / as sysdba

set archive log destination parameter
sql> alter system set log_archive_dest1=’location=$oracle_home/archive1’ scope = spfile;
sql> alter system set log_archive_dest2=’location=$oracle_home/archive2’ scope = spfile;
sql>alter system set log_archive_format=’orclarch_%d_%t_%r_%s.log’ scope = spfile;

now shutdown database
sql>shut immediate

then start database in mount mode
sql>startup mount

now put database in archive log mode
sql>alter database archivelog;

open the database
sql>alter database open;


Now check is it in archive log mode?

sql>alter system switch logfile;
then go to archive1 directory and see physically that archive log is there and also see that in oracle by following command.
sql>select name from v$archived_log;

whoppingggggggg

Thursday, May 22, 2008

ORA-01552

ORA-01552:cannot use system rollback segment for non-system tablespace 'USERS' Oracle.
I was getting this error in our oracle release 10.2.0.0. Main cause I found was that somehow I have changed parameter undo_management = manual that by default was auto.
I just changed undo_management = auto and than all problems with rollback segments disappeared.
sql> alter system set undo_management = auto scope = spfile;
sql>shut immediate
sql>startup