Monday, May 24, 2010

Display as Picture property in Column Datawindow

//1. your datawindow SQL like below, where the picture name is 00001.jpg, 00002.jpg and so on...

SELECT a.staffno, a.name, ('images\staff\'||a.staffno||'.jpg') as gambar
FROM staff a

//2. the pictures located in subdirectory images\staff\























//3. At column property, check Display as picture

//4. Output of datawindow will be like below...



Monday, April 26, 2010

Using OLE Blob in Powerbuilder 10 using Oracle 10g

In datawindow, you might want to have OLE column that display such as picture of staff department.
These are the step to do it :-



1. When building datawindow select the ID number (in my case staff number) without selecting the blob / longraw (in Oracle 10g) column.
2. Make sure the table have primary key (staff id), and update properties for datawindow as below :-



3. Add an OLE column from menu Insert->Control->OLE Database Blob.
4. As below the properties for OLE column (select blob column from the same table)



5. Key Clause: [primary key for blob table = :primary key for update in datawindow] 
6. Client Name Expression : used when opening paintbrush application to update to which staff number such as below (after running your application)



7. Paintbrush appears when double-click on OLEblob column


8. You can paste a picture or select paste from file...
9. Update back to datawindow by clicking menu in paint such below, then exit paint.



10. When return to datawindow, you have blob picture in you application!
11. Remember to save you datawindow by using dw_1.update() then commit using sqlca;
or the picture will not be updated into your database.
12. This feature doesnt not supported by Appeon till now (version 6.2)

Friday, April 2, 2010

Black Cat Relaxing

This black cat was found resting at my mother's house. Black is beauty, you're really black uh..

Wednesday, March 24, 2010

Crosstab and having SQL that display star rating

//lets say we have this SQL in crosstab datawindow in Powerbuilder (i'm using 10.2.x)

select a.KOD, d.PIHAK , c.JUMBINTANG, c.MULA, c.AKHIR, a.KOD_JENIS, e.SINGKATN, to_char(b.TKH_SEMASA, 'yyyy') as compute_0008_year
from main a, semasa b, star c, pihak d, kdfaklt e
where a.KOD = b.KOD (+)
and b.SEMASA is not null
and a.PIHAK = d.PIHAK (+)
and a.PTJ = e.KDFKLT
having  (count(to_char(b.TKH_SEMASA, 'yyyy')) between c.mula and c.AKHIR)
group by a.KOD, d.PIHAK , c.JUMBINTANG, c.MULA, c.AKHIR, a.KOD_JENIS, e.SINGKATN, to_char(b.TKH_SEMASA, 'yyyy')
order by to_char(b.TKH_SEMASA, 'yyyy'), a.KOD_PEKA

//your crosstab definition is like this

//you have datawindow output like this



//but you want an output like below?

//in a dialogbox format property of the displayed number in datawindow code this:-

Thursday, March 11, 2010

Powerbuilder Openwithparm

 string ls_stafno
//Open a response window w_find passing a string
ls_stafno = '007'
openwithparm(w_find, ls_stafno, parent)

//other example passing a structure
struc_staff  lstrc_staff
lstrc_staff.stafno = '007'
lstrc_staff.name = 'James Bond'
openwithparm(w_find, lstrc_staff)

Wednesday, March 10, 2010

Connecting Powerbuilder to Oracle 10g


sqlca.DBMS = "O10 Oracle10g (10.1.0)"
sqlca.LogPass = "tiger"
sqlca.ServerName = "server"
sqlca.LogId = "scott"
sqlca.AutoCommit = False
sqlca.DBParm = "CommitOnDisconnect='No',Async=1,PBCatalogOwner='scott'"

connect using sqlca;
dw_1.settransobject(sqlca)

Tuesday, March 9, 2010

More CASE and DECODE in oracle SQL

SELECT b.TARIKH,
b.KOD_PROJEK,
a.NAMA_PROJEK,
b.KOD_VOT, 
b.DASAR,
b.KET,
(select d.NAMA_TRANS from sbp_trans d where d.JENIS = b.JENIS_TRANS) as trans,
b.LO as rujukan,
(case when b.jenis_trans in (3,4) then b.amaun
else null
end) as debit,
DECODE(b.JENIS_TRANS, 5, b.AMAUN, null) as kredit,
(case when b.jenis_trans not in (1,2,6) then null
else b.AMAUN
end) as amt_col8, 
b.JENIS_TRANS,
(select c.AMAUN from sbp_budget c where c.KOD_VOT = b.kod_vot and c.DASAR = b.dasar and c.PTJ = a.PTJ and c.SPTJ = a.SPTJ
and c.thn_blj = :as_thnblj and c.JENIS = 1) as peruntukan,
b.KOD_SODO
FROM PROJEK a, BELANJA b
WHERE b.KOD_VOT like :as_vot
AND b.DASAR like :as_dasar
AND a.KOD_PROJEK = b.KOD_PROJEK
AND substr(a.KOD_PROJEK, 1,4) = :as_thnblj
AND a.PTJ = :as_ptj
AND a.SPTJ like :as_sptj

Monday, January 18, 2010

Enable/Disable column editing in datawindow in rowfocuschanged script


//in rowfocuschanged event in datawindow, write this
long ll_budget
if currentrow > 0 then














ll_budget = this.getitemnumber(currentrow, 'expense')
  
    if ll_budget > 0 then
        this.object.kod_vot.protect = 1   //kod_vot is your column_name
        this.object.dasar.protect = 1       //dasar is your column_name
    else
        this.object.kod_vot.protect = 0
        this.object.dasar.protect = 0
    end if
end if

//this will disable editing if ll_budget is greater than 0 and enable editing if it is zeroin other way you can always do this in datawindow expression.
go to protect expression for the particular column then code this :-

if (budget > 0, 1, 0)

//means when budget value greater than 0, 1 = to protect (disable column edit) else 0 = enabled column edit.

To Enable/disable Editing on new/existing row in datawindow

 //In your datawindow write this code in your column property, in ->General->protect
if (isRowNew(), 0, 1)
//this will enable editing on newrow and disable editing on existing row






//write code in each column to enable/disable editing for a row...
//you can put other conditions like calculation such as

if (columnname = 'Admin', 0, 1)






Having in Select Statement

 // working sample from one of my project that using HAVING select statement...
select a.KOD_PEKA, d.PIHAK , c.BINTANG, c.MULA, c.AKHIR
from p_main a, p_semasa b, p_star c, p_pihak d
where a.KOD_PEKA = b.KOD_PEKA (+)
and b.SEMASA is not null
and to_char(b.TKH_SEMASA, 'yyyy') = '2009'
and a.KOD_PIHAK = d.KOD_PIHAK (+)
having  (count(to_char(b.TKH_SEMASA, 'yyyy')) between c.mula and c.AKHIR)
group by a.KOD_PEKA, d.PIHAK , c.BINTANG, c.MULA, c.AKHIR
order by a.KOD_PEKA

Thursday, January 7, 2010

SUBSELECT Advance

//like this also can... thanx to iMohaja

select a.kod_vot, a.NAMA6, a.sumamaun, decode(b.amaun,null,0,b.amaun) amaun,
        (decode(b.amaun ,null,0,  (b.amaun/a.sumamaun)*100)) as perc
from
    (select (decode(sum(k.AMAUN), null, 0, sum(k.AMAUN))) as amaun, k.KOD_VOT, substr(k.KOD_PROJEK,5,2) as ptj
    from projek_kew k
    where substr(k.KOD_PROJEK,1,4) = :thn
    group by (substr(k.KOD_PROJEK,5,2)), K.KOD_VOT) b,
    (select s.KOD_VOT, w.NAMA6, SUM(s.AMAUN) AS SUMAMAUN, s.PTJ
    from budget s, kiobsb w
    where substr(s.KOD_VOT,1,2) = w.OBAM||w.OBSB
    and s.PTJ = :ptj
    and s.THN_BLJ = :thn
    GROUP BY s.KOD_VOT, w.NAMA6, s.ptj) a
where
a.KOD_VOT = b.kod_vot(+)
and a.PTJ = b.ptj(+)
order by 1