* Implemented trunc in pl/pgsql

This commit is contained in:
Heng Sin Low 2007-01-26 10:09:53 +00:00
parent e532181e97
commit 1f49f0e571
2 changed files with 32 additions and 25 deletions

View File

@ -18,31 +18,35 @@ SQLActions[ ] = {
AS 'org.compiere.sqlj.Adempiere.getProperty(java.lang.String)'
LANGUAGE java VOLATILE;;
CREATE OR REPLACE FUNCTION TRUNC(datetime TIMESTAMP WITH TIME ZONE)
RETURNS TIMESTAMP WITH TIME ZONE
AS 'org.compiere.sqlj.Adempiere.trunc(java.sql.Timestamp)'
LANGUAGE java VOLATILE;;
--Replace by pl/pgsql implementation
--CREATE OR REPLACE FUNCTION TRUNC(datetime TIMESTAMP WITH TIME ZONE)
--RETURNS TIMESTAMP WITH TIME ZONE
--AS 'org.compiere.sqlj.Adempiere.trunc(java.sql.Timestamp)'
--LANGUAGE java VOLATILE;;
CREATE OR REPLACE FUNCTION firstOf(datetime TIMESTAMP WITH TIME ZONE ,xx VARCHAR)
RETURNS TIMESTAMP WITH TIME ZONE
AS 'org.compiere.sqlj.Adempiere.firstOf(java.sql.Timestamp,java.lang.String)'
LANGUAGE java VOLATILE;;
--Replace by pl/pgsql implementation
--CREATE OR REPLACE FUNCTION firstOf(datetime TIMESTAMP WITH TIME ZONE ,xx VARCHAR)
--RETURNS TIMESTAMP WITH TIME ZONE
--AS 'org.compiere.sqlj.Adempiere.firstOf(java.sql.Timestamp,java.lang.String)'
--LANGUAGE java VOLATILE;;
CREATE OR REPLACE FUNCTION daysBetween(datetime1 TIMESTAMP WITH TIME ZONE , datetime2 TIMESTAMP WITH TIME ZONE)
RETURNS INTEGER
AS 'org.compiere.sqlj.Adempiere.getDaysBetween(java.sql.Timestamp,java.sql.Timestamp)'
LANGUAGE java VOLATILE;
--Replace by pl/pgsql implementation
--CREATE OR REPLACE FUNCTION daysBetween(datetime1 TIMESTAMP WITH TIME ZONE , datetime2 TIMESTAMP WITH TIME ZONE)
--RETURNS INTEGER
--AS 'org.compiere.sqlj.Adempiere.getDaysBetween(java.sql.Timestamp,java.sql.Timestamp)'
--LANGUAGE java VOLATILE;;
CREATE OR REPLACE FUNCTION addDays(day TIMESTAMP WITH TIME ZONE, days INTEGER)
RETURNS TIMESTAMP WITH TIME ZONE
AS 'org.compiere.sqlj.Adempiere.addDays(java.sql.Timestamp,int)'
LANGUAGE java VOLATILE;
--Replace by pl/pgsql implementation
--CREATE OR REPLACE FUNCTION addDays(day TIMESTAMP WITH TIME ZONE, days INTEGER)
--RETURNS TIMESTAMP WITH TIME ZONE
--AS 'org.compiere.sqlj.Adempiere.addDays(java.sql.Timestamp,int)'
--LANGUAGE java VOLATILE;;
CREATE OR REPLACE FUNCTION charAt(source VARCHAR, pos INTEGER)
RETURNS VARCHAR
AS 'org.compiere.sqlj.Adempiere.charAt (java.lang.String,int)'
LANGUAGE java VOLATILE;
--Replace by pl/pgsql implementation
--CREATE OR REPLACE FUNCTION charAt(source VARCHAR, pos INTEGER)
--RETURNS VARCHAR
--AS 'org.compiere.sqlj.Adempiere.charAt (java.lang.String,int)'
--LANGUAGE java VOLATILE;;
CREATE OR REPLACE FUNCTION nextID(AD_Sequence_ID INTEGER, System VARCHAR)
RETURNS INTEGER

View File

@ -334,6 +334,9 @@ public class Adempiere implements Serializable
*/
static public int getDaysBetween (Timestamp start, Timestamp end)
{
//check null
if (start == null || end == null) return 0;
boolean negative = false;
if (end.before(start))
{