agora inbox for pljava-dev@postgresql.org  
help / color / mirror / Atom feed
[Pljava-dev] Problem  [SELECT - 0 row(s), 0.019 secs]  [Error Code: 0, SQL State: 42601] ERROR: Default type java.math.BigDecimal cannot be replaced by int
2+ messages / 0 participants
[nested] [flat]

* [Pljava-dev] Problem  [SELECT - 0 row(s), 0.019 secs]  [Error Code: 0, SQL State: 42601] ERROR: Default type java.math.BigDecimal cannot be replaced by int
@ 2005-02-21 17:54 
  2005-02-21 19:04 ` [Pljava-dev] Re: Problem  [SELECT - 0 row(s), 0.019 secs]  [Error Code: 0, SQL State: 42601] ERROR: Default type java.math.BigDecimal cannot be replaced by int 
  0 siblings, 1 reply; 2+ messages in thread

From:  @ 2005-02-21 17:54 UTC (permalink / raw)

Hi all!

I have following case:

my Function:
/** Currency **/
CREATE OR REPLACE FUNCTION currencyBase (Amount DECIMAL,
C_CurrencyFrom_ID NUMERIC,    ConversionDate Timestamp, AD_Client_ID
NUMERIC, AD_Org_ID NUMERIC)
RETURNS DECIMAL
AS
'org.compiere.sqlj.Currency.base(java.math.BigDecimal,int,java.sql.Timestamp,int,int)'
LANGUAGE java; 


my CLASS FILE: 

public static BigDecimal base (BigDecimal p_Amount,int
p_C_CurrencyFrom_ID, Timestamp p_ConversionDate,int p_AD_Client_ID,int
p_AD_Org_ID) throws SQLException
{
// Return NULL
if (p_Amount == null || p_C_CurrencyFrom_ID == 0)
return null;
// Return Amount
if (p_Amount.signum() == 0)
return p_Amount;

// Base Currency
String sql = "SELECT ac.C_Currency_ID "
+ "FROM AD_ClientInfo ci"
+ " INNER JOIN C_AcctSchema ac ON
(ci.C_AcctSchema1_ID=ac.C_AcctSchema_ID) "
+ "WHERE ci.AD_Client_ID=?";
int C_CurrencyTo_ID = Compiere.getSQLValue(sql, p_AD_Client_ID);
// Return Amount
if (p_C_CurrencyFrom_ID == C_CurrencyTo_ID)
return p_Amount;
//
return convert(p_Amount, p_C_CurrencyFrom_ID, C_CurrencyTo_ID, 
p_ConversionDate, 0, p_AD_Client_ID, p_AD_Org_ID);
} // base

I execute my function:

SELECT  currencyBase(o.GrandTotal,o.C_Currency_ID,o.DateAcct,
o.AD_Client_ID,o.AD_Org_ID) AS ConvAmt FROM C_Order o ;

but recieved this error: (Default type java.math.BigDecimal cannot be
replaced by int)

I think the problem is my o.C_Currency_ID is a type NUMERIC, but my
method as for int. I do not want to change all my methods.

Can You tell me How can I change to Default type or make some type of
mapping using pljava?


Victor P?rez Ju?rez








^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* [Pljava-dev] Re: Problem  [SELECT - 0 row(s), 0.019 secs]  [Error Code: 0, SQL State: 42601] ERROR: Default type java.math.BigDecimal cannot be replaced by int
  2005-02-21 17:54 [Pljava-dev] Problem  [SELECT - 0 row(s), 0.019 secs]  [Error Code: 0, SQL State: 42601] ERROR: Default type java.math.BigDecimal cannot be replaced by int 
@ 2005-02-21 19:04 ` 
  0 siblings, 0 replies; 2+ messages in thread

From:  @ 2005-02-21 19:04 UTC (permalink / raw)

Victor,
> but recieved this error: (Default type java.math.BigDecimal cannot be
> replaced by int)
> 
> I think the problem is my o.C_Currency_ID is a type NUMERIC, but my
> method as for int. I do not want to change all my methods.
>
Yes, your suspicion is correct. The NUMERIC is mapped to BigDecimal by 
default.

> Can You tell me How can I change to Default type or make some type of
> mapping using pljava?
> 
This is something that's still on the TODO list I'm afraid. PLJava comes 
with limited mapping capabilities today. So either you take the pain in 
SQL (and declare your SQL functions with int parameters) or in Java and 
use BigDecimal to receive the NUMERIC.

Regards,
Thomas Hallgren





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2005-02-21 19:04 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-02-21 17:54 [Pljava-dev] Problem  [SELECT - 0 row(s), 0.019 secs]  [Error Code: 0, SQL State: 42601] ERROR: Default type java.math.BigDecimal cannot be replaced by int 
2005-02-21 19:04 ` 

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox