Click here to Skip to main content
15,891,721 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
create or replace function sum
   (n1 in number,n2 in number)
   return number
   is
   temp number(8);
   begin
   temp :=n1+n2;
   return temp;
   end;
   /



Error :
java.sql.SQLException: ORA-06550: line 1, column 19:
PLS-00103: Encountered the symbol "," when expecting one of the following:

. ( ) * @ % & - + / at mod remainder rem <an exponent="" (**)="">
|| indicator multiset

What I have tried:

import java.sql.*;

class CallableStatementFunction	
{
	public static void main(String args[])throws Exception
	{
		try
		{
			Class.forName("oracle.jdbc.driver.OracleDriver");
			Connection con=DriverManager.getConnection(".....");
			
			CallableStatement cs=con.prepareCall("{?= call sum(?,?)}");  
			
			cs.setInt(2,10);  
			cs.setInt(3,20);
			cs.registerOutParameter(1,Types.INTEGER); 
			cs.execute();    
			
			System.out.println("10+20 =" + cs.getInt(1));
      			
			cs.close();		
			con.close();
		}
		catch(Exception e)
		{
			System.out.println(e);
		}
	}
}
Posted
Updated 24-Sep-19 8:13am
v2

1 solution

Done, sum is a keyword instead replace sum with sum1.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900