CREATE OR REPLACE PROCEDURE proc_Insert_BookKindList
(
temTypeName nvarchar2,
temParent int
)
AS
ncount number;
begin
--SELECT COUNT (*) INTO ncount FROM BookKindList fm1 where EXISTS (SELECT BookKindName from BookKindList fm2 where fm2.BookKindName=temTypeName);--判斷是否存
SELECT count(*) INTO ncount FROM BookKindList where BookKindName=temTypeName;
if ncount<=0 then
begin
INSERT INTO BookKindList (BookKindName,BookKindParent) VALUES(temTypeName,temParent);
commit;
end;
else
begin
SELECT BookKindID INTO ncount FROM BookKindList where BookKindName=temTypeName;
dbms_output.put_line('存在相同的记录,添加不成功!'||ncount);
end;
end if;
Exception
When others then
dbms_output.put_line('存在问题,添加不成功!'||ncount);
Rollback;
end proc_Insert_BookKindList; --测试 oracle 11g 涂聚文 20150526
exec proc_Insert_BookKindList ('油彩画',3); drop PROCEDURE proc_Insert_BookKindOut; CREATE OR REPLACE PROCEDURE procInsertBookKindOut --添加返回ID
(
temTypeName nvarchar2,
temParent number,
temId out number
)
AS
ncount number;
reid number;
begin
--SELECT COUNT (*) INTO ncount FROM BookKindList fm1 where EXISTS (SELECT BookKindName from BookKindList fm2 where fm2.BookKindName=temTypeName);--判斷是否存
SELECT count(*) INTO ncount FROM BookKindList where BookKindName=temTypeName;
if ncount<=0 then
begin
INSERT INTO BookKindList (BookKindID,BookKindName,BookKindParent) VALUES(BookKindList_SEQ.nextval,temTypeName,temParent);
select BookKindList_SEQ.currval into reid from dual;
temId:=reid;
dbms_output.put_line('添加成功!'||temId);
commit;
end;
else
begin
SELECT BookKindID INTO ncount FROM BookKindList where BookKindName=temTypeName;
dbms_output.put_line('存在相同的记录,添加不成功!'||ncount);
temId:=0;
end;
end if;
Exception
When others then
begin
dbms_output.put_line('存在问题,添加不成功!'||ncount);
temId:=0;
Rollback;
end;
end procInsertBookKindOut; --测试 oracle 11g 涂聚文 20150526
declare
mid number:=0;
nam nvarchar2(100):='黑白画';
par number:=3;
begin
--proc_Insert_BookKindOut(nam in nvarchar2,par in int,mid in out int);
procInsertBookKindOut(nam,par ,mid);
if mid>0 then
dbms_output.put_line('添加成功!输出参数:'||mid);
else
dbms_output.put_line('存在相同的记录,添加不成功!输出参数:'||mid);
end if;
end;

  csharp 调用:

///<summary>
/// 追加记录
///</summary>
///<param name="BookKindListInfo"></param>
///<returns></returns>
public int InsertBookKindList(BookKindListInfo bookKindList)
{
int ret = 0;
try
{
OracleParameter[] par = new OracleParameter[]{
new OracleParameter("temTypeName",OracleType.NVarChar,1000),
new OracleParameter("temParent",OracleType.Number,4),
};
par[0].Value = bookKindList.BookKindName;
par[1].Value = bookKindList.BookKindParent;
ret = OracleHelper.ExecuteSql("proc_Insert_BookKindList", CommandType.StoredProcedure, par);
}
catch (OracleException ex)
{
throw ex;
}
return ret;
}
/// <summary>
/// 追加记录返回
/// </summary>
/// <param name="authorList"></param>
/// <param name="authorID"></param>
/// <returns></returns>
public int InsertBookKindOutput(BookKindListInfo bookKindList, out int bookKindLID)
{
bookKindLID = 0;
int ret = 0;
try
{
OracleParameter[] par = new OracleParameter[]{
new OracleParameter("temTypeName",OracleType.NVarChar,1000),
new OracleParameter("temParent",OracleType.Number,4),
new OracleParameter("temId",OracleType.Number,4),
};
par[0].Value = bookKindList.BookKindName;
par[1].Value = bookKindList.BookKindParent;
par[2].Direction = ParameterDirection.Output;
ret = OracleHelper.ExecuteSql("proc_Insert_BookKindOut", CommandType.StoredProcedure, par);
if (ret > 0)
{
bookKindLID =int.Parse(par[2].Value.ToString());
}
}
catch (OracleException ex)
{
throw ex;
}
return ret;
}

  

 /// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
BookKindListInfo bookKindListInfo = new BookKindListInfo();
BookKindListBLL bookKindListBLL = new BookKindListBLL();
bookKindListInfo.BookKindParent =(int)this.numericUpDownBookKindParent.Value;
bookKindListInfo.BookKindName = this.textBoxBookKindName.Text.Trim(); int k = 0;
k = bookKindListBLL.InsertBookKindList(bookKindListInfo);
if (k > 0)
{
MessageBox.Show("ok");
}
else
{
MessageBox.Show("no");
} }
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, EventArgs e)
{
BookKindListInfo bookKindListInfo = new BookKindListInfo();
BookKindListBLL bookKindListBLL = new BookKindListBLL();
bookKindListInfo.BookKindParent = (int)this.numericUpDownBookKindParent.Value;
bookKindListInfo.BookKindName = this.textBoxBookKindName.Text.Trim();
int ou = 0;
int k = 0;
k = bookKindListBLL.InsertBookKindOutput(bookKindListInfo,out ou);
if (k > 0)
{
MessageBox.Show("ok:id"+ou.ToString());
}
else
{
MessageBox.Show("no");
}
}

  

sql: Oracle 11g create procedure的更多相关文章

  1. sql: Oracle 11g create table, function,trigger, sequence

    --书藉位置Place目录 drop table BookPlaceList; create table BookPlaceList ( BookPlaceID INT PRIMARY KEY, -- ...

  2. Oracle 11g 中SQL性能优化新特性之SQL性能分析器(SQLPA)

    Oracle11g中,真实应用测试选项(the Real Application Testing Option)提供了一个有用的特点,叫SQL性能分析器(SQL Performance Analyze ...

  3. Oracle 11g R2性能优化 SQL TRACE

    作为Oracle官方自带的一种基本性能诊断工具,SQL Trace可以用来评估当前正在运行的SQL语句的效率,同时为该语句生成统计信息等,并保存这些信息到指定路径下的跟踪文件(trace)当中.SQL ...

  4. PL/SQL Developer连接本地Oracle 11g 64位数据库和快捷键设置

    1.登录PL/SQL Developer 这里省略Oracle数据库和PL/SQL Developer的安装步骤,注意在安装PL/SQL Developer软件时,不要安装在Program Files ...

  5. SQL SERVER 2008向ORACLE 11G迁移示例

    来源于:http://www.cnblogs.com/hiizsk/ 由SQL SERVER 2008向ORACLE 11G迁移过程记录之一-表 使用Oracle Sql Developer将SQL ...

  6. In Oracle 11g, how to change the order of the results of a sql without “order by”?(转)

    oracle 11g 当sql语句中不加order by的时候,好像是按rowid的顺序返回结果的.我也看过一些相关的文档,oracle的官方意思就是不加order by,就不保证输出的顺序. 那么, ...

  7. 使用Oracle Sql Developer将SQL SERVER 2008数据库移植到Oracle 11g

    ORACLE官方提供的Sql Developer自带的Oracle Migration Workbench. 什么是Oracle SQL Developer?在官方页面上,是这样介绍它的: Oracl ...

  8. Oracle 11g XE 与 Oracle SQL Developer 的配置与使用(重制版)

    Oracle 11g XE 与 Oracle SQL Developer 的配置与使用(重制版) 前提概要 项目上需求要适应Oracle数据库,当然这和某EF框架也有关. 因为Oracle 的表名和列 ...

  9. PL/SQL Developer连接本地Oracle 11g 64位数据库

    转摘:http://www.cnblogs.com/ymj126/p/3712727.html 用于学习,笔记,以备后用. 1.登录PL/SQL Developer 这里省略Oracle数据库和PL/ ...

随机推荐

  1. Linux 下的 netfilter 认识与常规操作

    Linux 下的 netfilter 认识与常规操作 前言 博客写到今天,1年7个月.可是包含所有写作经历,这个时间线可以达到三年. 上次更新了一篇 "镇站之宝" ,也是本站阅读量 ...

  2. 调用ajax的返回值,需要再ajax之外的函数体里return,以及同步异步问题

    <html> <head> <meta charset="utf-8"/> <script src="js/jquery-1.1 ...

  3. Handover

    In brief, eNodeB select one MME based on IE: Relative MME Capacity in S1 Setup Response, S-GW and P- ...

  4. Linux常用快捷键、文件管理和查询

    有话要说 为什么要用Linux?要用Linux的原因太多,想说说不完啊.如果你说用Linux只是为了装逼,那证明你真的还很菜.不排除有装逼了因素,那也只占非常少的比例,可以忽略不计.我们反问一下,为什 ...

  5. 剑指offer——面试题32.1:分行从上到下打印二叉树

    void BFSLayer(BinaryTreeNode* pRoot) { if(pRoot==nullptr) return; queue<BinaryTreeNode*> pNode ...

  6. Mono for android彻底退出程序

    江门-花哥(996777016) 2013/8/11 12:00:54怎样彻底退出程序?求代码我用这个代码,退出不了,打开进程管理器,进程还在运行北京-穷丫小子(55413726) 2013/8/11 ...

  7. Fetch使用方法

    前言: fetch是用来取代传统的XMLHttpRequest的. 它的优点很多,包括链式调用的语法.返回promise等. 什么是fetch? fetch api是基于promise的设计,它是为了 ...

  8. 重签名android测试包

    我的一个例子:jarsigner -digestalgSHA1 -sigalg MD5withRSA -keystore C:\Users\sunyang\.android\debug.keystor ...

  9. Mac版sublime text右键open in browser 不能识别中文名解决办法

    问题描述: Mac下sublime text下打开中文命名的html文件,右键open in browser,浏览器无反应. 解决思路: 要么适应软件,要么改进软件来适应. 1.  将中文名的html ...

  10. python-单链表的实现

    #!/usr/bin/python class Node(object): def __init__(self,value,next=None): self.value,self.next=value ...