create or replace procedure StuPro
(no in number, name in varchar2, loc1 out varchar2)
as
begin
select dname, loc into name, loc1 from dept
where deptno=no;
insert int abc values (no, name, loc1);
end;
import java.sql.*;
import java.io.*;
class ProConcept {
public static void main(String[] args) {
try {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
System.out.println("DRIVERS LOADED...");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:
BudDinu ","scott ","tiger ");
DataInputStream dis = new DataInputStream(System.in);
System.out.println("ENTER DEPARTMENT NUMBER : ");
String s1 = dis.readLine();
int n1 = Integer.parseInt(s1);
CallableStatement cs = con.prepareCall("{call StuPro (?,?,?)}");
cs.setInt(1, n1);
cs.registerOutParameter(2, Types.VARCHAR);
cs.registerOutParameter(3, Types.VARCHAR);
cs.execute();
String res = cs.getString(2);
String res1 = cs.getString(3);
System.out.println("DEPARTMENT NAME : " + res);
System.out.println("DEPARTMENT LOCATION : " + res1);
} catch (Exception e) {
System.out.println(e);
}
} // main
} // ProConcept
(no in number, name in varchar2, loc1 out varchar2)
as
begin
select dname, loc into name, loc1 from dept
where deptno=no;
insert int abc values (no, name, loc1);
end;
import java.sql.*;
import java.io.*;
class ProConcept {
public static void main(String[] args) {
try {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
System.out.println("DRIVERS LOADED...");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:
BudDinu ","scott ","tiger ");
DataInputStream dis = new DataInputStream(System.in);
System.out.println("ENTER DEPARTMENT NUMBER : ");
String s1 = dis.readLine();
int n1 = Integer.parseInt(s1);
CallableStatement cs = con.prepareCall("{call StuPro (?,?,?)}");
cs.setInt(1, n1);
cs.registerOutParameter(2, Types.VARCHAR);
cs.registerOutParameter(3, Types.VARCHAR);
cs.execute();
String res = cs.getString(2);
String res1 = cs.getString(3);
System.out.println("DEPARTMENT NAME : " + res);
System.out.println("DEPARTMENT LOCATION : " + res1);
} catch (Exception e) {
System.out.println(e);
}
} // main
} // ProConcept
|
No comments:
Post a Comment