JAVA ohh JAVA (Eds. 1)

Perbedaan public, private, protected, dan tanpa penentu akses pada variabel :
public : variabel dapat di akses pada semua kelas yang menggunakan kelas yang berisi variabel tersebut.

private : Hanya dapat diakses oleh metode2 dalam kelas itu sendiri.

protected : Variabel instan dapat diakses pada kelas sendiri dan subkelasnya.

Tanpa Penentu akses : variabel dapat diakses oleh kelas yang berada dalam package yang sama.

Perbedaan public, private, protected, dan tanpa penentu akses pada metode :
public : Metode dapat diakses oleh sembarang kelas.

private : Hanya dapat diakses pada metode2 dalam kelas yang sama.

protected : Metode dapat diakses pada kelas sendiri dan pada subkelasnya.

Tanpa Penentu akses : Metode hanya dapat diakses oleh metode dalam kelas itu sendiri ataupun metode pada kelas lain yang terletak pada package yang sama.

Access modifier yang hanya diterapkan pada deklarasi kelas hanyalah final dan public, final agar kelas tidak dapat di extend ke subkelas

Abstract class adalah class yg udah hampir jadi(50%), sedangkan interface bukan sama sekali class(0%)..

1. Abstract class boleh punya attribut, sedangkan interface tidak boleh punya attribut (hanya boleh punya konstanta).

2. Abstract class boleh punya methode yg sudah diimplementasikan, sedangkan interface tidak boleh punya methode yg sudah diimplementasikan

3. Abstract class punya constructor, sedangkan interface tidak

4.Sebuah class hanya boleh mengextend dari satu abstract class tapi boleh mengimplementasikan banyak interface…

https://i0.wp.com/i.stack.imgur.com/vSv9c.png

Advertisements

Number of days in a month

SELECT date_part('day', 
(date_part('year', CURRENT_DATE) || '-' ||
date_part('month', CURRENT_DATE) || '-01')::date
+ '1 month'::interval
- '1 day'::interval) AS days;

Atau

CREATE FUNCTION num_days(int, int) RETURNS float8 AS — years, months
    ‘SELECT date_part(”day”,
        (($1::text || ”-” || $2::text || ”-01”)::date
            + ”1 month”::interval
            – ”1 day”::interval)) AS days’
LANGUAGE ‘sql’;

 

And a quick test.

SELECT num_days(2000, 2), num_days(2001, 2), num_days(2002, 3);
num_days | num_days | num_days
----------+----------+----------
29 | 28 | 31
(1 row)

 

Cried Inside

ketakberdayaan atas setumpuk tuntutan
kegelisahan atas kewajiban yang terbengkalai
kegalauan atas permintaan yang terasa menggungung
ketakkuasaan atas segala keterbelengguan tekanan

Sample StoreProcedure SQL

USE [DB01022012]
GO
/****** Object:  StoredProcedure [dbo].[SPPostingJournalByType]    Script Date: 04/30/2012 15:02:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER procedure [dbo].[SPPostingJournalByType]
@yearprd VARCHAR (4),
@monthprd VARCHAR (2),
@journaltypeno VARCHAR (20)

as

declare
@query nvarchar(4000),
@query_db nvarchar(1000),
@query_cd nvarchar(1000),

@column_name_bb VARCHAR (4),
@column_name_db VARCHAR (4),
@column_name_cd VARCHAR (4),
@column_name_eb VARCHAR (4),

@exist_bb numeric,
@exist_db money,
@exist_cd money,
@exist_eb money,

@subledgertype int,
@employeeId int,
@partnerNo VARCHAR (20),
@journalNo VARCHAR (20),

@count int,
@month VARCHAR (2),
@coa_no VARCHAR (20),
@coa_no_parent VARCHAR (20),
@coa_no_parent_old VARCHAR (20),
@amount_db money,
@amount_cd money

–SET @monthprd = ‘9’
–SET @yearprd = ‘2011’

IF (datalength(@monthprd) = 1)
BEGIN
SET @month =  ‘0’+@monthprd;
END

SET @column_name_bb = ‘BB’ + @month
SET @column_name_db = ‘DB’ + @month
SET @column_name_cd = ‘CD’ + @month
SET @column_name_eb = ‘EB’ + @month

DECLARE jurnalItemCs CURSOR FOR

SELECT  JournalNo, AccountNo, AmountOfDebit, AmountOfCredit, SubLedgerType, CSIEmployeeId, PartnerNo
FROM    CSIACJournalEntryItem
WHERE    JournalNo IN
(select JournalNo from CSIACJournalEntry where YearPeriod=@yearprd and
MonthPeriod=@monthprd and IsPosted =’false’ and IsClosed = ‘false’
and IsValidated =’true’ and JournalTypeNo=@journaltypeno )
and IsValidated = ‘true’ and IsPosted = ‘false’ and IsClosed = ‘false’

OPEN jurnalItemCs

FETCH jurnalItemCs INTO @journalNo, @coa_no, @amount_db, @amount_cd, @subledgertype, @employeeId, @partnerNo

WHILE (@@Fetch_Status = 0)
BEGIN
SET @exist_bb = 0
SET @exist_db = 0
SET @exist_cd = 0
SET @exist_eb = 0

— Insert ke Ac Ledger
IF((select count(*) from CSIACLedger where YearPeriod = @yearprd and AccountNo = @coa_no) = 0)
BEGIN

SET @exist_eb = abs(@amount_db – @amount_cd)

SET @query =’INSERT INTO CSIACLedger ([yearperiod],[AccountNo],[‘+@column_name_db+’],[‘+@column_name_cd+’],
[‘+@column_name_bb+’],[‘+@column_name_eb+’],[lastupdated], [lastupdater] )
values
(”’+@yearPrd+”’,”’+@coa_no+”’,’+convert(varchar,@amount_db)+’,’+convert(varchar,@amount_cd)+’,
‘+convert(varchar,@exist_bb)+’, ‘+convert(varchar,@exist_eb)+’,{fn NOW()},1) ‘

EXEC(@query)
END

ELSE
BEGIN

SET @query_db = ‘((SELECT ISNULL(‘+@column_name_db+’,0) FROM CSIACLedger  WHERE [YearPeriod]=’+@yearprd+’ and [AccountNo]=’+@coa_no+’)
+ ‘+CONVERT(VARCHAR,@amount_db)+’) ‘
SET @query_cd = ‘((SELECT ISNULL(‘+@column_name_cd+’,0) FROM CSIACLedger  WHERE [YearPeriod]=’+@yearprd+’ and [AccountNo]=’+@coa_no+’)
+ ‘+CONVERT(VARCHAR,@amount_cd)+’) ‘

SET @query = ‘UPDATE CSIACLedger set [‘+@column_name_db+’] = ‘+@query_db+’,
[‘+@column_name_cd+’] = ‘+@query_cd+’
where [YearPeriod]=’+@yearprd+’ and [AccountNo]=’+@coa_no+’ ‘

EXEC(@query)

SET @query = ‘UPDATE CSIACLedger set
[‘+@column_name_eb+’] = abs([‘+@column_name_db+’] – [‘+@column_name_cd+’])
where [YearPeriod]=’+@yearprd+’ and [AccountNo]=’+@coa_no+’ ‘

EXEC(@query)

END

–Insert Sub Ledger
SET @exist_bb = 0;
SET @exist_db = 0;
SET @exist_cd = 0;
SET @exist_eb = 0;

IF(@subledgertype = 2)

BEGIN
IF((select count(*) from CSIACSubLedgerEmployee where YearPeriod = @yearprd and
AccountNo = @coa_no and CSIEmployeeId = @employeeId) = 0)

BEGIN
SET @exist_eb = abs(@amount_db – @amount_cd)

SET @query =’INSERT INTO CSIACSubLedgerEmployee ([yearperiod],[AccountNo],[CSIEmployeeId],[‘+@column_name_db+’],[‘+@column_name_cd+’],
[‘+@column_name_bb+’],[‘+@column_name_eb+’],[lastupdated], [lastupdater] )
values
(”’+@yearPrd+”’,”’+@coa_no+”’,’+convert(varchar,@employeeId)+’, ‘+convert(varchar,@amount_db)+’,’+convert(varchar,@amount_cd)+’,
‘+convert(varchar,@exist_bb)+’, ‘+convert(varchar,@exist_eb)+’,{fn NOW()},1) ‘

EXEC(@query)
END
ELSE
BEGIN
SET @query_db = ‘((SELECT ISNULL(‘+@column_name_db+’,0) FROM CSIACSubLedgerEmployee  WHERE [YearPeriod]=’+@yearprd+’ and [AccountNo]=’+@coa_no+’
and CSIEmployeeId = ‘+convert(varchar,@employeeId)+’) + ‘+CONVERT(VARCHAR,@amount_db)+’) ‘

SET @query_cd = ‘((SELECT ISNULL(‘+@column_name_cd+’,0) FROM CSIACSubLedgerEmployee  WHERE [YearPeriod]=’+@yearprd+’ and [AccountNo]=’+@coa_no+’
and CSIEmployeeId = ‘+convert(varchar,@employeeId)+’) + ‘+CONVERT(VARCHAR,@amount_cd)+’) ‘

SET @query = ‘UPDATE CSIACSubLedgerEmployee set [‘+@column_name_db+’] = ‘+@query_db+’,
[‘+@column_name_cd+’] = ‘+@query_cd+’
where [YearPeriod]=’+@yearprd+’ and [AccountNo]=’+@coa_no+’ and CSIEmployeeId=’+convert(varchar,@employeeId)

EXEC(@query)

SET @query = ‘UPDATE CSIACSubLedgerEmployee set
[‘+@column_name_eb+’] = abs([‘+@column_name_db+’] – [‘+@column_name_cd+’])
where [YearPeriod]=’+@yearprd+’ and [AccountNo]=’+@coa_no+’ and CSIEmployeeId=’+convert(varchar,@employeeId)

EXEC(@query)
END

END

IF(@subledgertype = 3)

BEGIN
IF((select count(*) from CSIACSubLedgerPartner where YearPeriod = @yearprd and
AccountNo = @coa_no and PartnerNo = @partnerNo) = 0)

BEGIN
SET @exist_eb = abs(@amount_db – @amount_cd)

SET @query =’INSERT INTO CSIACSubLedgerPartner ([yearperiod],[AccountNo],[PartnerNo],[‘+@column_name_db+’],[‘+@column_name_cd+’],
[‘+@column_name_bb+’],[‘+@column_name_eb+’],[lastupdated], [lastupdater] )
values
(”’+@yearPrd+”’,”’+@coa_no+”’,”’+@partnerNo+”’, ‘+convert(varchar,@amount_db)+’,’+convert(varchar,@amount_cd)+’,
‘+convert(varchar,@exist_bb)+’, ‘+convert(varchar,@exist_eb)+’,{fn NOW()},1) ‘

EXEC(@query)
END
ELSE
BEGIN
SET @query_db = ‘((SELECT ISNULL(‘+@column_name_db+’,0) FROM CSIACSubLedgerPartner  WHERE [YearPeriod]=’+@yearprd+’ and [AccountNo]=’+@coa_no+’
and PartnerNo = ”’+@partnerNo+”’) + ‘+CONVERT(VARCHAR,@amount_db)+’) ‘

SET @query_cd = ‘((SELECT ISNULL(‘+@column_name_cd+’,0) FROM CSIACSubLedgerPartner  WHERE [YearPeriod]=’+@yearprd+’ and [AccountNo]=’+@coa_no+’
and PartnerNo = ”’+@partnerNo+’) + ”’+CONVERT(VARCHAR,@amount_cd)+’) ‘

SET @query = ‘UPDATE CSIACSubLedgerPartner set [‘+@column_name_db+’] = ‘+@query_db+’,
[‘+@column_name_cd+’] = ‘+@query_cd+’
where [YearPeriod]=’+@yearprd+’ and [AccountNo]=’+@coa_no+’ and PartnerNo=”’+@partnerNo+”’ ‘

EXEC(@query)

SET @query = ‘UPDATE CSIACSubLedgerPartner set
[‘+@column_name_eb+’] = abs([‘+@column_name_db+’] – [‘+@column_name_cd+’])
where [YearPeriod]=’+@yearprd+’ and [AccountNo]=’+@coa_no+’ and PartnerNo=”’+@partnerNo+”’ ‘

EXEC(@query)
END

END

–Ledger for Account Parent

SET @coa_no_parent_old = @coa_no

IF((select (LevelNo-1) from CSIAccount where AccountNo=@coa_no) >= 0)
BEGIN
SET @count = 0

WHILE((select ((LevelNo-1)-@count) from CSIAccount where AccountNo=@coa_no) > 0)
BEGIN
SET @exist_bb = 0;
SET @exist_db = 0;
SET @exist_cd = 0;
SET @exist_eb = 0;

select  @coa_no_parent = AccountNoGroup from CSIAccount where AccountNo=@coa_no_parent_old

IF((select count(*) from CSIACLedger where YearPeriod = @yearprd and AccountNo = @coa_no_parent) = 0)
BEGIN

SET @exist_eb = abs(@amount_db – @amount_cd)

SET @query =’INSERT INTO CSIACLedger ([yearperiod],[AccountNo],[‘+@column_name_db+’],[‘+@column_name_cd+’],
[‘+@column_name_bb+’],[‘+@column_name_eb+’],[lastupdated], [lastupdater] )
values
(”’+@yearPrd+”’,”’+@coa_no_parent+”’,’+convert(varchar,@amount_db)+’,’+convert(varchar,@amount_cd)+’,
‘+convert(varchar,@exist_bb)+’, ‘+convert(varchar,@exist_eb)+’,{fn NOW()},1) ‘

EXEC(@query)
END

ELSE
BEGIN

SET @query_db = ‘((SELECT ISNULL(‘+@column_name_db+’,0) FROM CSIACLedger  WHERE [YearPeriod]=’+@yearprd+’ and [AccountNo]=’+@coa_no_parent+’)
+ ‘+CONVERT(VARCHAR,@amount_db)+’) ‘
SET @query_cd = ‘((SELECT ISNULL(‘+@column_name_cd+’,0) FROM CSIACLedger  WHERE [YearPeriod]=’+@yearprd+’ and [AccountNo]=’+@coa_no_parent+’)
+ ‘+CONVERT(VARCHAR,@amount_cd)+’) ‘

SET @query = ‘UPDATE CSIACLedger set [‘+@column_name_db+’] = ‘+@query_db+’,
[‘+@column_name_cd+’] = ‘+@query_cd+’
where [YearPeriod]=’+@yearprd+’ and [AccountNo]=’+@coa_no_parent+’ ‘

EXEC(@query)

SET @query = ‘UPDATE CSIACLedger set
[‘+@column_name_eb+’] = abs([‘+@column_name_db+’] – [‘+@column_name_cd+’])
where [YearPeriod]=’+@yearprd+’ and [AccountNo]=’+@coa_no_parent+’ ‘

EXEC(@query)

END

select @coa_no_parent_old = AccountNo from CSIAccount where AccountNo = @coa_no_parent

SET @count = @count + 1
END
END

FETCH jurnalItemCs INTO @journalNo, @coa_no, @amount_db, @amount_cd, @subledgertype, @employeeId, @partnerNo
END

CLOSE jurnalItemCs
DEALLOCATE jurnalItemCs

–Update Journal Status
SET @query = ‘update CSIACJournalEntryItem set IsPosted = ”true” where JournalNo = ”’+@journalNo+”’ ‘;
EXEC (@query)

SET @query = ‘update CSIACJournalEntry set IsPosted=”true” where JournalNo = ”’+@journalNo+”’ ‘;
EXEC (@query)

RETURN 1