PDA

View Full Version : Calling Oracle Function


gkkumar
03-05-03, 11:57
i am using callable statement to update an oracle databse with 1
number field and 2 VarChar fields, it gives me an error when trying
to execute the statement saying"not all variables bound". i am
putting the whole error and the code snippet at the
bottom....pls do help


CREATE OR REPLACE FUNCTION Round(ip_input_value IN NUMBER,
ip_curr_code IN VARCHAR2, ip_ext_cty IN VARCHAR2)
RETURN NUMBER IS

lv_round_factor currency.rounding_factor%TYPE;
lv_new_value NUMBER(19,11);

BEGIN
SELECT rounding_factor INTO lv_round_factor
FROM currency
WHERE currency.currency_code = ip_curr_code;

lv_new_value := (ip_input_value / 12);

IF ip_ext_cty = 'N' THEN
lv_new_value := ROUND(lv_new_value,lv_round_factor);
ELSE
lv_round_factor := (-1 * lv_round_factor);
lv_new_value := ROUND(lv_new_value,lv_round_factor);
END IF;
RETURN (lv_new_value * 12);
END Round;
/



Connection conn = null;
int onRow = 0;
String tot = "Not initialized";
try
{
final int numParams = 1;
conn = SOTDBConnection.login();
CallableStatement cs = conn.prepareCall("{ ? = call Round(?,?,?)}");
cs.registerOutParameter(numParams, Types.INTEGER);
cs.setString(2, currency);
cs.setString(3, extendedCountry);

for(int row = 0;row < numLines;row++)
{
String [] l = (String []) lines.get(row);
tot = l[TOTAL];

if(!tot.equals(""))
{
StringBuffer b = new StringBuffer(tot.length());
b.setLength(tot.length());
int current = 0;
for(int i = 0;i < tot.length();i++)
{
char ch = tot.charAt(i);
if(ch != ',')
{
b.setCharAt(current++, ch);
}
}
String noComma = b.toString();
cs.setDouble(1, Double.parseDouble(noComma));
cs.execute();
double price = Double.parseDouble(cs.getString(1));
NumberFormat nf = NumberFormat.getNumberInstance();
nf.setMaximumFractionDigits(numDecimals);
nf.setMinimumFractionDigits(numDecimals);
tot = new String(nf.format(price));
data.set(row*numColumns + TOTAL, tot);
}
}
}
catch (Exception ex)
{
String errorMsg = "ERROR in row: " + onRow + ",tot: " + tot + ",curr: " + currency + ",ext: " + extendedCountry;
LOGUtils.debugMsg(errorMsg + ", exception: " + ex.toString());
}
finally
{
if(conn != null)
{
try
{
conn.close();
}
catch(Exception e)
{
LOGUtils.errorMsg("Exception closing connection in , e:" + e.toString());
}
}
}

ERROR:::
THROWIN THE EXCEPTION THOUGH PAGE IS DISPLYIN PROPERLY.....

ORA-01008 not all variables bound

gkkumar
03-06-03, 12:33
hey,

PROBLEM SOLVED ..........



THANKS

jbbrown
04-12-03, 17:00
gkkumar,

how did you solve the problem? I am running into something very similar.

Thanks

jbbrown