mysql存储过程及(java调用)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql存储过程及(java调用)相关的知识,希望对你有一定的参考价值。
create procedure DeleteDataByPdfDocId ( IN pdfDocId varchar(100) ) BEGIN #根据pdfDocId删除数据 DELETE FROM pdf_formula WHERE PDF_DOCID = pdfDocId ; DELETE FROM pdf_image WHERE PDF_DOCID = pdfDocId ; DELETE FROM pdf_table WHERE PDF_DOCID = pdfDocId ; DELETE FROM pdf_paragraph WHERE PDF_DOCID = pdfDocId ; DELETE FROM pdf_addendum_section WHERE PDF_DOCID = pdfDocId ; DELETE FROM pdf_addendum_chapter WHERE PDF_DOCID = pdfDocId ; DELETE FROM pdf_addendum WHERE PDF_DOCID = pdfDocId ; DELETE FROM pdf_section WHERE PDF_DOCID = pdfDocId ; DELETE FROM pdf_backcover WHERE PDF_DOCID = pdfDocId ; DELETE FROM pdf_catalog WHERE PDF_DOCID = pdfDocId ; DELETE FROM pdf_chapter WHERE PDF_DOCID = pdfDocId ; DELETE FROM pdf_coverpage WHERE PDF_DOCID = pdfDocId ; DELETE FROM pdf_descriptioin_info WHERE PDF_DOCID = pdfDocId ; DELETE FROM pdf_foreword WHERE PDF_DOCID = pdfDocId ; DELETE FROM pdf_introduction WHERE PDF_DOCID = pdfDocId ; DELETE FROM pdf_maintext WHERE PDF_DOCID = pdfDocId ; DELETE FROM pdf_modify_details WHERE PDF_DOCID = pdfDocId ; DELETE FROM pdf_reference_doc WHERE PDF_DOCID = pdfDocId ; DELETE FROM standard_formal_catalogstructure WHERE PDF_DOCID = pdfDocId ; DELETE FROM standard_formal_element WHERE PDF_DOCID = pdfDocId ; DELETE FROM standard_samples_notes WHERE PDF_DOCID = pdfDocId ; DELETE FROM pdf_document WHERE id = pdfDocId; DELETE FROM lkstcs_operations_log WHERE PDF_DOCID = pdfDocId; DELETE FROM standard_complie_record WHERE PDF_DOCID = pdfDocId ; END create procedure UpdatePdfElementStdNo ( IN stdNo varchar(1000), IN oldStdNo varchar(1000) ) BEGIN #更新标准号 UPDATE pdf_addendum SET STANDARD_NO = stdNo WHERE STANDARD_NO = oldStdNo; UPDATE pdf_addendum_chapter SET STANDARD_NO = stdNo WHERE STANDARD_NO = oldStdNo; UPDATE pdf_addendum_section SET STANDARD_NO = stdNo WHERE STANDARD_NO = oldStdNo; UPDATE pdf_backcover SET STANDARD_NO = stdNo WHERE STANDARD_NO = oldStdNo; UPDATE pdf_catalog SET STANDARD_NO = stdNo WHERE STANDARD_NO = oldStdNo; UPDATE pdf_chapter SET STANDARD_NO = stdNo WHERE STANDARD_NO = oldStdNo; UPDATE pdf_coverpage SET STANDARD_NO = stdNo WHERE STANDARD_NO = oldStdNo; UPDATE pdf_descriptioin_info SET STANDARD_NO = stdNo WHERE STANDARD_NO = oldStdNo; UPDATE pdf_foreword SET STANDARD_NO = stdNo WHERE STANDARD_NO = oldStdNo; UPDATE pdf_formula SET STANDARD_NO = stdNo WHERE STANDARD_NO = oldStdNo; UPDATE pdf_image SET STANDARD_NO = stdNo WHERE STANDARD_NO = oldStdNo; UPDATE pdf_introduction SET STANDARD_NO = stdNo WHERE STANDARD_NO = oldStdNo; UPDATE pdf_maintext SET STANDARD_NO = stdNo WHERE STANDARD_NO = oldStdNo; UPDATE pdf_modify_details SET STANDARD_NO = stdNo WHERE STANDARD_NO = oldStdNo; UPDATE pdf_paragraph SET STANDARD_NO = stdNo WHERE STANDARD_NO = oldStdNo; UPDATE pdf_reference_doc SET STANDARD_NO = stdNo WHERE STANDARD_NO = oldStdNo; UPDATE pdf_section SET STANDARD_NO = stdNo WHERE STANDARD_NO = oldStdNo; UPDATE pdf_table SET STANDARD_NO = stdNo WHERE STANDARD_NO = oldStdNo; UPDATE standard_formal_catalogstructure SET STANDARD_NO = stdNo WHERE STANDARD_NO = oldStdNo; UPDATE standard_formal_element SET STANDARD_NO = stdNo WHERE STANDARD_NO = oldStdNo; UPDATE pdf_document SET STANDARD_NO = stdNo WHERE STANDARD_NO = oldStdNo; UPDATE standard_complie_record SET STANDARD_NO = stdNo WHERE STANDARD_NO = oldStdNo; END
以上两段代码为更新和删除数据的存储过程,
调用:
public void update(String sNo1, String sNo2) {
String updateSQL= "{call UpdatePdfElementStdNo(?,?)}";//存储过程的名字
getSession().createSQLQuery(updateSQL).setString(0, sNo1).setString(1, sNo2).executeUpdate();
}
本文出自 “shihou” 博客,谢绝转载!
以上是关于mysql存储过程及(java调用)的主要内容,如果未能解决你的问题,请参考以下文章