Thursday, September 17, 2009

How to find informix cost factor

Cost factor of a table is used to measure the performance of the sql executions. When your table cost factor is high, it will decrease the sql exection . That means it will get some times to generate resultsets of the sql.
Here is the way to measure informix cost factor.
Example :-
set explain on;
select * from table
  • Use set explain on; before your sql stetement in telnet client in dbaccess mode in informix.
  • Then exit dbaccess mode and type "ls -ltrh" in your home directory.
  • This will list all the files. Go to end. You will find a file called as "sqexplain.out".
  • Vi the file. Then press "shift+g" to end of the file to see your table cost factor details.

Friday, September 11, 2009

sql for monthly,yearly report

select year(added_on),month(added_on),count(*) from table_name
group by 1,2
order by 2


This will produce a resultset for monthly yearly reports.

Ex :-

Year Month Records
------ ------ --------
2009 5 14416
2009 6 788
2009 7 15413
2009 8 16091

Wednesday, September 2, 2009

Mysql today in where clause

select * from table where added_on=date(now());

To use this sql you must have used "date" datatype for your table column.
select * from table where added_at=now();

This works fine for "time" columns too .

Monday, August 31, 2009

Get radio button value in js

Suppose your radio button grop is "radiogroup".
function getradioSelection() {
var group=document.getElementsByName("radiogroup");
var grp='';
for(var k=0;k<group.length;k++){
if(group[k].checked){
grp=group[k].value;
}
return grp;
}

This method will return the selected radio button value.

Tuesday, August 25, 2009

Insert data into mysql from text file


Unload data into a text file.
Import data into a excel sheet. Then save the file again as .txt(Tab delimited) file.
Export file to your mysql server. vi the .txt file in linux. Then save the file using following command.
  • :%s/tab/|/g ---------->Then enter.
  • :wq!  ------------->Save the file
  • LOAD DATA INFILE "table.txt" INTO TABLE table
    FIELDS TERMINATED BY '|' LINES TERMINATED BY '\n'
    ----> Load data to mysql server

Unload/load data from informix

unload to "table.txt" select * from table

This will unload data to your user login in database server. Suppose you logged as "test" user, it will unload data to folder "test".

load data from "table.txt" insert into table

Use this sql to load data from "table.txt" to a table.

Thursday, August 20, 2009


String qur="select a from table a";
Query q = em.createQuery(qur);
q.setFirstResult(0);
q.setMaxResults(10);

This will return the resultset limited to 10 in ejb.