Ooh … Begitu! I see, I see …

Icon

Setelah kelayapan di internet, cari-cari info dari sana-sini dan bongkar pasang tips (terutama programming), akhirnya baru sadar … ternyata begitu caranya … [all about tricks and tips I have found during my work as programmer.]

get rows of dynamic latest date(s)

…. sorry for not updating for such a long time. 😛
just got a mail from a friend recently. probably this is some idea to share:


yo, Byeol. got a problem here. I have a table (FB) where I need to store every month’s stock of any available Product:

CREATE TABLE TSTOCK (
	THEDATE			DATE NOT NULL,
	PRODUCTID		VARCHAR(30) NOT NULL,
	COST			DOUBLE PRECISION DEFAULT 0 NOT NULL,
	LASTSTOCK		DOUBLE PRECISION DEFAULT 0 NOT NULL
);
ALTER TABLE TSTOCK ADD PRIMARY KEY (THEDATE, PRODUCTID);

the problem is … how to get only the last stocks of every available Product? the last date of each product might be different, like a certain product might be not updated this month but its last date was last month, while the others last dates are within this month. so basically, what I need is calling each Product’s last date row.
thanks in advance!

– Jack

hmmm …. Jack, you meant this one?

select s.* from TSTOCK s
where s.THEDATE = (select first 1 THEDATE from TSTOCK 
	where (PRODUCTID = s.PRODUCTID)
	order by THEDATE desc)

anyone got a better idea??

Filed under: Firebird, , , ,

SMS Gateway, oh SMS Gateway …

* still cursing herself after posting a bubbling in her other blog with the same title. *

Guys … do you know where is the place to get a lot of AT Commands manuals or references? Especially for the modems, not just for mobile phones. Please help. Many thanks for your attention and help. ^^

…….. ah yes, I am a “she”. 😛

Filed under: Delphi programming, Java programming, , ,

cast Double to String in java

Double to String casting …
if you want to display its String in number format (like this ###,###,##0.00) do not use these lines …

    
    Double sk = 12300000000.35;
    System.out.println(sk.toString());
    System.out.println(String.valueOf(sk));

they would result like these ones:

1.230000000035E10
1.230000000035E10

use this one instead.

    
    Double sk = 12300000000.35;
    NumberFormat nm = NumberFormat.getNumberInstance();

    System.out.println(nm.format(sk));

the latter result would be this:
12.300.000.000,35

Filed under: Java programming, , , , , , ,

deprecated File toURL() method in Java 6

after upgrading to Java 6, I just found out that toURL() method is deprecated in Java 6.
after doing some googling, I reached to this page: http://www.jguru.com/faq/view.jsp?EID=1280051

The author (in the link above) said:

The toURL() method of File does not properly escape characters that aren’t valid in a URL. You can write better code today without waiting for Java 6 by calling the toURL() method after calling toURI() on a File object.

and provided these code samples for us:

    URL url1 = file.toURL();         // bad
    URL url2 = file.toURI().toURL(); //good

hmmm … okay, I got it.

Filed under: Java programming, , , , , , , , ,