Showing posts with label Simple Scripts. Show all posts
Showing posts with label Simple Scripts. Show all posts

Thursday, July 3, 2008

Creating a simple search in rows

Programmer usually needs creates searching data after retrieving datawindow. Here is simple searching data between rows.

long ll_nbr, ll_foundrow
string is_nostaf

ll_nbr = dw_1.rowcount( )
is_nostaf = trim(sle_name.text)
ll_foundrow = dw_1.Find("px01staf_px01numstaf = '"+ is_nostaf +"'", 1, ll_nbr)

if ll_foundrow > 0 then
dw_1.scrolltorow(ll_foundrow)
dw_1.selectrow( 0, false)
dw_1.selectrow( ll_foundrow, true)
else
messagebox('Mesej','No data')
end if

How to change color between different rows

Sometimes creating datawindow, programmer needs changes colors between rows. Usually it use for makes a different status, maybe student active in blue colors and not active in grey colors.
At datawindow, click details an insert color format like this. Format like this if(b,t,f) in other word if (boolean,true,false).

(student_status = 'A', RGB(153,204,204), RGB(153,153,153))

rgb

How to find duplicate records in a database

Often a developer finds it necessary to deal with duplicate data in a database. They may have a need to provide a list of duplicate records or delete the duplicate records. The below methods provide an easy approach to working with duplicate data.

To create a list of the duplicate records with a count of the number of duplicates per record:

SELECT column, COUNT( column )
FROM table
GROUP BY column
HAVING count( column ) > 1

To create a list of ALL duplicate records, where there will be a listing for EACH record:

SELECT column
FROM TABLE
WHERE column in (SELECT column FROM table
HAVING count(column) > 1 )
ORDER BY column