JDBC_PostGreSQL_StoredProcedure1 |
- String dbURL = "jdbc:postgresql://localhost:5432/pgsdemo1";
String user = "postgres"; String pwd = "postgre_manas9";
- SQL : String sql1 = "select round (cfcal(43.25), 2); " ;
- // Connection>>statement >> Resultset >>
c = DriverManager.getConnection(dbURL,user,pwd);
st = c.createStatement();
rs = st.executeQuery(sql1);
|
Ref :
create_replace_function1.htm ,create_replace_function1.htm |
Creating Funntion that will convert Centigrade to Fahrenheit
Script : creating cfcal function:
-- Function: cfcal(numeric)
-- DROP FUNCTION cfcal(numeric);
CREATE OR REPLACE FUNCTION cfcal(i numeric)
RETURNS numeric AS
$BODY$
DECLARE
temp1 numeric ;
BEGIN
RETURN (i * 9/5) + 32 ;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
ALTER FUNCTION cfcal(numeric)
OWNER TO postgres; |
Code Snippet:
- Accessing Stored Procedure in PostGreSQL
- Processing Recordset
-
|
Code :
JDBC_PostGreSQL_StoredFunction1.txt |
Run time Display:
|
|
|
|
|