-
create or replace FUNCTION queryempincome( eno IN NUMBER) RETURN NUMBER AS --定義變量保存員工薪水和獎(jiǎng)金 psal emp.sal%type; pcomm emp.comm%type; BEGIN SELECT sal,comm INTO psal,pcomm FROM emp WHERE empno=eno; RETURN psal*12+nvl(pcomm,0); END;查看全部
-
create or replace PROCEDURE raisesalary( eno IN NUMBER) AS --定義一個(gè)變量保存漲前的薪水 psal emp.sal%type; BEGIN --得到員工漲前的薪水 SELECT sal INTO psal FROM emp WHERE empno=eno; --給該員工漲100 UPDATE emp SET sal=sal+100 WHERE empno=eno; --需不需要commit? --一般不在存儲(chǔ)過程或存儲(chǔ)函數(shù)中,commit和rollback. --打印 dbms_output.put_line('漲前的薪水:' || psal || '漲后的薪水:' || (psal + 100)); END;查看全部
-
set serveroutput on /* 調(diào)用存儲(chǔ)過程: 1.exec sayhello(); 2.begin sayhello(); sayhello(); end; / */ create or replace procedure sayhello as --說明部分 begin dbms_output.put_line('Hello World'); end; / exec sayhello();查看全部
-
jdbc連接字符串查看全部
-
老師,您好,我想知道的是存儲(chǔ)過程是在數(shù)據(jù)庫中的,那如果我通過java寫進(jìn)去的話可以嗎?如果可以的話,哪個(gè)的效率高一點(diǎn)呢?您推薦的做法是?查看全部
-
在應(yīng)用沖訪問包中的存儲(chǔ)過程 注意:需要帶上包名查看全部
-
在out參數(shù)中使用光標(biāo): 聲明包結(jié)構(gòu) = 包頭 + 包體 ==== 包頭: create or replace package mypackage as type empcursor is ref cursor;(自定義申明) procedure queryEmpList(dno in number,empList out empcursor); end mypackage; 包體: create or replace package body mypackage as procedure queryEmpList(dno in number,empList out empcursor) as begin open empList from select * from emp where deptno=dno; end queryEmpList; end mypackage;查看全部
-
java訪問存儲(chǔ)過程和存儲(chǔ)函數(shù) connection接口 callablestatement接口(調(diào)用數(shù)據(jù)庫的存儲(chǔ)過程和存儲(chǔ)函數(shù)) 通過java程序訪問: 首先訪問oracle數(shù)據(jù)庫需要在oracle安裝目錄下orcl下lib下拷貝一個(gè)jar包 復(fù)制到工程中(新建一個(gè)目錄forder命名為lib) 創(chuàng)建一個(gè)類jdbcutil public class jdbcutil(){ private static string driver = "oracle.jdbc.oracledriver"; private static string url = "jdbc:oracle;thin:@ip地址;端口;orcl"; private static string user = "scott"; private static string password = "tiger"; //注冊(cè)數(shù)據(jù)庫的驅(qū)動(dòng) static{ try{ class.forname(driver); }catch(classnotfoundexcepption e){ throw new exceptionininitializererror(e); } } } //獲取數(shù)據(jù)庫連接 public static connection getconnection(){ return drivermanger.getconnection(url,user,password); } //釋放數(shù)據(jù)庫資源 public static void release(connection conn,staticment st,resultset rs){ if(rs != null) { rs.close(); rs = null; } if(st !=null) { rt.close(); rt = null; } if(conn!=null){ conn.close(); conn = null; } }查看全部
-
原則: 如果只有一個(gè)返回值,用存儲(chǔ)函數(shù);否則,就用存儲(chǔ)過程。查看全部
-
超級(jí)用戶給普通用戶授權(quán)。 grant DEBUG CONNECT SESSION, DEBUG ANY PROCEDURE to user;查看全部
-
創(chuàng)建或者替代存儲(chǔ)過程: create [or replace] PROCEDURE 過程名(參數(shù)列表) AS PLSQL子程序體; 存儲(chǔ)過程怎么調(diào)用? 方法一:exec 存儲(chǔ)過程名(); 方法二:begin 存儲(chǔ)過程名(); end; /查看全部
-
創(chuàng)建或者替代存儲(chǔ)過程: create [or replace] PROCEDURE 過程名(參數(shù)列表) AS PLSQL子程序體; 存儲(chǔ)過程怎么調(diào)用? 方法一:exec 存儲(chǔ)過程名(); 方法二:begin 存儲(chǔ)過程名(); end; /查看全部
-
存儲(chǔ)函數(shù)可以通過return語句返回值,而存儲(chǔ)過程不能通過return語句返回值; 存儲(chǔ)過程和存儲(chǔ)函數(shù)的相同點(diǎn):完成特定功能的程序,存儲(chǔ)在數(shù)據(jù)庫中供所有用戶調(diào)用。查看全部
-
create or replace procedure sayhelloworld as --說明部分(as不能省略) begin dbms_putout.out(); end;查看全部
-
包頭只負(fù)責(zé)聲明: type empcursor is ref cursor ;聲明empcursor為光標(biāo)類型;查看全部
舉報(bào)
0/150
提交
取消