當前位置:首頁 » 存儲配置 » 目標機器存儲過程創建失敗

目標機器存儲過程創建失敗

發布時間: 2023-06-05 16:46:05

A. mysql創建存儲過程,為什麼行不通

可能是少一個空格的問題


也就是那個 DELIMITER //

在 DELIMITER與 // 之間, 有一個空格.


DELIMITER//
CREATEPROCEDUREHelloWorld()
BEGIN
SELECT'HelloWorld';
END//

DELIMITER;

callHelloWorld();

+-------------+
|HelloWorld|
+-------------+
|HelloWorld|
+-------------+
1rowinset(0.00sec)

QueryOK,0rowsaffected(0.00sec)註:如果HelloWorld都失敗,那麼首先需要檢查資料庫的存儲引擎

mysql>showvariableslike'%storage_engine%';
+----------------+--------+
|Variable_name|Value|
+----------------+--------+
|storage_engine|MyISAM|
+----------------+--------+
1rowinset(0.00sec)

存儲引擎為InnoDB的資料庫,能使用存儲過程。

mysql>showvariableslike'%storage_engine%';
+----------------+--------+
|Variable_name|Value|
+----------------+--------+
|storage_engine|InnoDB|
+----------------+--------+
1rowinset(0.01sec)

B. db2創建存儲過程報錯

首先第一個錯誤,分號,應該是英文分號; 而不是中文;

C. 創建存儲過程報錯如下: 警告: 創建的過程帶有編譯錯誤。

1. 創建完存儲過程(在命令行),可以用showerr看具體錯誤
2. 可以在PLSQL中,輸入"全班排名", 然後俺右鍵->編輯,看到具體錯誤
3. 你的sql從from後一直到group by的分號;是多餘的,即便單獨在SQL窗口也會報錯
SQL應該改成
select b.學號,a.姓名, avg(a.成績) 平均分,sum(a.成績) 總分

from 成績信息表 a
join 學籍信息表 b on (a.學號=b.學號)
join 班級信息表 c on (c.班級號=b.班級號)
where c.班級名稱=class
group by b.學號
order by avg(成績) ,b.學號 desc;
4. 存儲過程不能直接用SQL,要用游標或select……into方式
比如:
create or replace procere 全班排名(
class in char(8)
)
as
cursor cur(p_class char(8)) is
select b.學號,a.姓名, avg(a.成績) 平均分,sum(a.成績) 總分

from 成績信息表 a
join 學籍信息表 b on (a.學號=b.學號)
join 班級信息表 c on (c.班級號=b.班級號)
where c.班級名稱=class
group by b.學號
order by avg(成績) ,b.學號 desc;
rs cur%rowtype;
begin
for rs in cur(class) loop
dbms_output.put_line(rs.學號||','||rs.姓名||','||rs.平均分||','||rs.總分);
end loop;
end;

D. 調用存儲過程失敗

SqlConnection conn=new SqlConnection(「connectionString」);
SqlDataAdapter da = new SqlDataAdapter();
da.selectCommand = new SqlCommand();
da.selectCommand.Connection = conn;
da.selectCommand.CommandText = "NameOfProcere";
da.selectCommand.CommandType = CommandType.StoredProcere;
param = new SqlParameter("@ParameterName", SqlDbType.DateTime);
param.Direction = ParameterDirection.Input;
param.Value = Convert.ToDateTime(inputdate);
da.selectCommand.Parameters.Add(param);

熱點內容
scratch少兒編程課程 發布:2025-04-16 17:11:44 瀏覽:619
榮耀x10從哪裡設置密碼 發布:2025-04-16 17:11:43 瀏覽:347
java從入門到精通視頻 發布:2025-04-16 17:11:43 瀏覽:62
php微信介面教程 發布:2025-04-16 17:07:30 瀏覽:288
android實現陰影 發布:2025-04-16 16:50:08 瀏覽:781
粉筆直播課緩存 發布:2025-04-16 16:31:21 瀏覽:334
機頂盒都有什麼配置 發布:2025-04-16 16:24:37 瀏覽:197
編寫手游反編譯都需要學習什麼 發布:2025-04-16 16:19:36 瀏覽:791
proteus編譯文件位置 發布:2025-04-16 16:18:44 瀏覽:350
土壓縮的本質 發布:2025-04-16 16:13:21 瀏覽:578