当前位置: 首页 > 编程日记 > 正文

Calling Oracle stored procedures from Microsoft.NET

摘自:http://www.c-sharpcorner.com/UploadFile/john_charles/CallingOraclestoredproceduresfromMicrosoftdotNET06222007142805PM/CallingOraclestoredproceduresfromMicrosoftdotNET.aspx
Introduction

This article is intended to illustrate how to illustrate how to call Oracle stored procedures and functions from Microsoft.NET through the Microsoft.NET Oracle provider and its object model residing in the namespace System.Data.OracleClient. I will cover several possible scenarios with advanced examples.

Executing a stored procedure

Let's begin with definitions. A procedure is a module that performs one or more actions. A function is a module that returns a value and unlike procedures a call to a function can exist only as part of an executable such as an element in an expression or the value assigned as default in a declaration of a variable.

The first example illustrates how to call an Oracle procedure passing input parameters and retrieving value by output parameters. For all the examples, we're going to use the default database ORCL which comes with the Oracle database installation. The following code in Listing 1 shows how to create a procedure named count_emp_by_dept which receives as its input parameter the department number and sends as its output parameter the number of employees in this department.

create or replace procedure count_emp_by_dept(pin_deptno number, pout_count out number)
is
begin
 select
count(*) into pout_count
 from scott.emp
 where deptno=pin_deptno;
end count_emp_by_dept;



Listing 1: Creating the procedure  count_emp_by_dept.

Now let's create a console application and add a reference to the assembly System.Data.OracleClient.dll to your project.

The code for this example is illustrated in Listing 2. The first thing to do is to import the object's class residing in the namespace System.Data.OracleClient with the using directive. Then you must set up the parameters and finally call the procedure using ExecuteNonQuery method of the OracleCommand object.

Using System;

using System.Collections.Generic;

using System.Text;

using System.Data.OracleClient;

using System.Data;

namespace CallingOracleStoredProc

{

    class Program

    {

        static void Main(string[] args)

        {

            using (OracleConnection objConn = new OracleConnection("Data Source=ORCL; User ID=scott; Password=tiger"))

            {

                OracleCommand objCmd = new OracleCommand();

                objCmd.Connection = objConn;

                objCmd.CommandText = "count_emp_by_dept";

                objCmd.CommandType = CommandType.StoredProcedure;

                objCmd.Parameters.Add("pin_deptno", OracleType.Number).Value = 20;

                objCmd.Parameters.Add("pout_count", OracleType.Number).Direction = ParameterDirection.Output;

                try

                {

                    objConn.Open();

                    objCmd.ExecuteNonQuery();

                    System.Console.WriteLine("Number of employees in department 20 is {0}", objCmd.Parameters["pout_count"].Value);

                }

                catch (Exception ex)

                {

                    System.Console.WriteLine("Exception: {0}",ex.ToString());

                }

                objConn.Close();

            }

        }

    }

}

Listing 2: The application code calling the stored procedure.

Executing a function

As function is similar to procedures except they return a value, we need to set up a return parameter. Let's see the example.

The following code in Listing 3 shows how to create a function named get_count_emp_by_dept which receives as its input parameter the department number and returns the number of employees in this department. It's very similar to the former procedure in the previous section.

create or replace function get_count_emp_by_dept(pin_deptno number)
 return number
is
 
var_count number;
begin
 select
count(*) into var_count
 from scott.emp
 where deptno=pin_deptno;
 return
var_count;
end get_count_emp_by_dept;

Listing 3: Creating an Oracle function.

Now let's see in the Listing 4 the application code which calls the function. As you can see, we need to define a return parameter to get the returned value. The other part of the code is similar for calling a procedure.

using System;

using System.Collections.Generic;

using System.Text;

using System.Data.OracleClient;

using System.Data;

namespace CallingOracleStoredProc

{

    class Program

    {

        static void Main(string[] args)

        {

            using (OracleConnection objConn = new OracleConnection("Data Source=ORCL; User ID=scott; Password=tiger"))

            {

                OracleCommand objCmd = new OracleCommand();

                objCmd.Connection = objConn;

                objCmd.CommandText = "get_count_emp_by_dept";

                objCmd.CommandType = CommandType.StoredProcedure;

                objCmd.Parameters.Add("pin_deptno", OracleType.Number).Value = 20;

                objCmd.Parameters.Add("return_value", OracleType.Number).Direction = ParameterDirection.ReturnValue;

                try

                {

                    objConn.Open();

                    objCmd.ExecuteNonQuery();

                    System.Console.WriteLine("Number of employees in department 20 is {0}", objCmd.Parameters["return_value"].Value);

                }

                catch (Exception ex)

                {

                    System.Console.WriteLine("Exception: {0}",ex.ToString());

                }

                objConn.Close();

            }

        }

    }

}

Listing 4: The application code calling the function.

Working with cursors

You can use the REF CURSOR data type to work with Oracle result set. To retrieve the result set, you must define a REF CURSOR output parameter in a procedure or a function to pass the cursor back to your application.

Now we're going to define a procedure which opens and sends a cursor variable to our application.

Let's define the package and procedure header as shown in Listing 5.

create or replace package human_resources
as
 type t_cursor is ref cursor;
 procedure
get_employee(cur_employees out t_cursor);
end human_resources;

Listing 5: Creation of the package human_resources and the procedure get_employee.

And now the package definition as shown in Listing 6.

create or replace package body human_resources
as
 procedure
get_employee(cur_employees out t_cursor)
 is
 begin
  open
cur_employees for select * from emp;
 end get_employee;
end human_resources;

Listing 6. The creation of the package body.

Now let's see in Listing 7 the application code calling the procedure inside the package. See the name syntax for calling the procedure contained within a package [package_name].[procedure_name]. In order to get a cursor, you need to define a cursor parameter with the ParameterDirection set up to Output and finally call the ExecuteReader method in the OracleCommand instance.

Using System;

using System.Collections.Generic;

using System.Text;

using System.Data.OracleClient;

using System.Data;

namespace CallingOracleStoredProc

{

    class Program

    {

        private static void prvPrintReader(OracleDataReader objReader)

        {

            for (int i = 0; i < objReader.FieldCount; i++)

            {

                System.Console.Write("{0}\t",objReader.GetName(i));

            }

            System.Console.Write("\n");

            while (objReader.Read())

            {

                for (int i = 0; i < objReader.FieldCount; i++)

                {

                    System.Console.Write("{0}\t", objReader[i].ToString());

                }

                System.Console.Write("\n");

            }

        }

        static void Main(string[] args)

        {

            using (OracleConnection objConn = new OracleConnection("Data Source=ORCL; User ID=scott; Password=tiger"))

            {

                OracleCommand objCmd = new OracleCommand();

                objCmd.Connection = objConn;

                objCmd.CommandText = "human_resources.get_employee";

                objCmd.CommandType = CommandType.StoredProcedure;

                objCmd.Parameters.Add("cur_employees", OracleType.Cursor).Direction = ParameterDirection.Output;

                try

                {

                    objConn.Open();

                    OracleDataReader objReader = objCmd.ExecuteReader();

                    prvPrintReader(objReader);

                }

                catch (Exception ex)

                {

                    System.Console.WriteLine("Exception: {0}",ex.ToString());

                }

                objConn.Close();

            }

        }

    }

}

Listing 7: The application code.

If the procedure returns more than one cursor, the DataReader object accesses them by calling the NextResult method to advance the next cursor.

Let's see the following example.

Listing 8 shows how to create the package header.

create or replace package human_resources
as
 type t_cursor is ref cursor;
 procedure
get_employee_department(cur_employees out t_cursor, cur_departments out t_cursor);
end human_resources;

Listing 8: Package reader.

The package body is shown in Listing 9.

create or replace package body human_resources
as
 procedure
get_employee_department(cur_employees out t_cursor, cur_departments out t_cursor)
 is
 begin
  open
cur_employees for select * from emp;
  open
cur_departments for select * from dept;
 end
get_employee_department;
end human_resources;

Listing 9: Creation of the package body.

Let's see the application code in Listing 10.

using System;

using System.Collections.Generic;

using System.Text;

using System.Data.OracleClient;

using System.Data;

namespace CallingOracleStoredProc

{

    class Program

    {

        private static void prvPrintReader(OracleDataReader objReader)

        {

            for (int i = 0; i < objReader.FieldCount; i++)

            {

                System.Console.Write("{0}\t",objReader.GetName(i));

            }

            System.Console.Write("\n");

            while (objReader.Read())

            {

                for (int i = 0; i < objReader.FieldCount; i++)

                {

                    System.Console.Write("{0}\t", objReader[i].ToString());

                }

                System.Console.Write("\n");

            }

        }

        static void Main(string[] args)

        {

            using (OracleConnection objConn = new OracleConnection("Data Source=ORCL; User ID=scott; Password=tiger"))

            {

                OracleCommand objCmd = new OracleCommand();

                objCmd.Connection = objConn;

                objCmd.CommandText = "human_resources.get_employee_department";

                objCmd.CommandType = CommandType.StoredProcedure;

                objCmd.Parameters.Add("cur_employees", OracleType.Cursor).Direction = ParameterDirection.Output;

                objCmd.Parameters.Add("cur_departments", OracleType.Cursor).Direction = ParameterDirection.Output;

                try

                {

                    objConn.Open();

                    OracleDataReader objReader = objCmd.ExecuteReader();

                    prvPrintReader(objReader);

                    objReader.NextResult();

                    prvPrintReader(objReader);

                }

                catch (Exception ex)

                {

                    System.Console.WriteLine("Exception: {0}",ex.ToString());

                }

                objConn.Close();

            }

        }

    }

}


Listing 10: The application code.

Working with DataSet and DataAdapter

The final example shows how to fill and update a DataSet object through a DataAdapter object.

The first thing to do is create four CRUD procedure to the emp table.  Listing 11 shows how to create the package header.

create or replace package human_resources
as
 
type t_cursor is ref cursor;
 procedure
select_employee(cur_employees out t_cursor);
 procedure insert_employee(p_empno number, p_ename varchar2, p_job varchar2, p_mgr number, p_hiredate date, p_sal number, p_comm number, p_deptno number);
 procedure update_employee(p_empno number, p_ename varchar2, p_job varchar2, p_mgr number, p_hiredate date, p_sal number, p_comm number, p_deptno number);
 procedure delete_employee(p_empno number);
end
human_resources;

Listing 11: The creation of the package header.

Now let's define the package body as shown in Listing 12

create or replace package body human_resources
as
 procedure
select_employee(cur_employees out t_cursor)
 is
 begin
   open
cur_employees for select empno, ename, job, mgr, hiredate, sal, comm, deptno from emp;
 end select_employee;
 procedure insert_employee(p_empno number, p_ename varchar2, p_job varchar2, p_mgr number, p_hiredate date, p_sal number, p_comm number, p_deptno number)
 is
 begin
   update
emp
   set ename=p_ename, job=p_job, mgr=p_mgr, hiredate=p_hiredate, sal=p_sal, comm=p_comm, deptno=p_deptno
   where empno=p_empno;
 end insert_employee;
 procedure update_employee(p_empno number, p_ename varchar2, p_job varchar2, p_mgr number, p_hiredate date, p_sal number, p_comm number, p_deptno number)
 is
 begin
   insert into
emp
   values(p_empno,p_ename,p_job,p_mgr,p_hiredate,p_sal,p_comm,p_deptno);
 end update_employee;
 procedure delete_employee(p_empno number)
 is
 begin
    delete from
emp
    where empno=p_empno;
 end delete_employee;
end human_resources;

Listing 12: The package body creation.

And finally, let's see the application code in Listing 13. As you can see, to fill the data table, we need to define the CRUD (create, read, update, delete) operations through the OracleCommand and associate it to the DataAdapter. I fill the data table, and print out a message with the number of employees so far, and then add a new row representing one employee entity.

using System;

using System.Collections.Generic;

using System.Text;

using System.Data.OracleClient;

using System.Data;

namespace CallingOracleStoredProc

{

    class Program

    {

        static void Main(string[] args)

        {

            using (OracleConnection objConn = new OracleConnection("Data Source=ORCL; User ID=scott; Password=tiger"))

            {

                OracleDataAdapter objAdapter = new OracleDataAdapter();

                OracleCommand objSelectCmd = new OracleCommand();

                objSelectCmd.Connection = objConn;

                objSelectCmd.CommandText = "human_resources.select_employee";

                objSelectCmd.CommandType = CommandType.StoredProcedure;

                objSelectCmd.Parameters.Add("cur_employees", OracleType.Cursor).Direction = ParameterDirection.Output;

                objAdapter.SelectCommand = objSelectCmd;

                OracleCommand objInsertCmd = new OracleCommand();

                objInsertCmd.Connection = objConn;

                objInsertCmd.CommandText = "human_resources.insert_employee";

                objInsertCmd.CommandType = CommandType.StoredProcedure;

                objInsertCmd.Parameters.Add("p_empno", OracleType.Number, 4, "empno");

                objInsertCmd.Parameters.Add("p_ename", OracleType.VarChar, 10, "ename");

                objInsertCmd.Parameters.Add("p_job", OracleType.VarChar, 9, "job");

                objInsertCmd.Parameters.Add("p_mgr", OracleType.Number, 4, "mgr");

                objInsertCmd.Parameters.Add("p_hiredate", OracleType.DateTime,12, "hiredate");

                objInsertCmd.Parameters.Add("p_sal", OracleType.Number, 7, "sal");

                objInsertCmd.Parameters.Add("p_comm", OracleType.Number, 7, "comm");

                objInsertCmd.Parameters.Add("p_deptno", OracleType.Number, 7, "deptno");

                objAdapter.InsertCommand = objInsertCmd;

                OracleCommand objUpdateCmd = new OracleCommand();

                objUpdateCmd.Connection = objConn;

                objUpdateCmd.CommandText = "human_resources.update_employee";

                objUpdateCmd.CommandType = CommandType.StoredProcedure;

                objUpdateCmd.Parameters.Add("p_empno", OracleType.Number, 4, "empno");

                objUpdateCmd.Parameters.Add("p_ename", OracleType.VarChar, 10, "ename");

                objUpdateCmd.Parameters.Add("p_job", OracleType.VarChar, 9, "job");

                objUpdateCmd.Parameters.Add("p_mgr", OracleType.Number, 4, "mgr");

                objUpdateCmd.Parameters.Add("p_hiredate", OracleType.DateTime, 10, "hiredate");

                objUpdateCmd.Parameters.Add("p_sal", OracleType.Number, 7, "sal");

                objUpdateCmd.Parameters.Add("p_comm", OracleType.Number, 7, "comm");

                objUpdateCmd.Parameters.Add("p_deptno", OracleType.Number, 7, "deptno");

                objAdapter.UpdateCommand = objUpdateCmd;

                OracleCommand objDeleteCmd = new OracleCommand();

                objDeleteCmd.Connection = objConn;

                objDeleteCmd.CommandText = "human_resources.delete_employee";

                objDeleteCmd.CommandType = CommandType.StoredProcedure;

                objDeleteCmd.Parameters.Add("p_empno", OracleType.Number, 4, "empno");

                objAdapter.DeleteCommand = objDeleteCmd;

                try

                {

                    DataTable dtEmp = new DataTable();

                    objAdapter.Fill(dtEmp);

                    System.Console.WriteLine("Employee count = {0}", dtEmp.Rows.Count );

                    dtEmp.Rows.Add(7935, "John", "Manager", 7782, DateTime.Now,1300,0,10);

                    objAdapter.Update(dtEmp);

                }

                catch (Exception ex)

                {

                    System.Console.WriteLine("Exception: {0}",ex.ToString());

                }

                objConn.Close();

            }

        }

    }

}

Listing 12: The application code.

转载于:https://www.cnblogs.com/NRabbit/archive/2009/07/10/1736182.html

相关文章:

Https的底层原理

Http协议&#xff1a; 转载于:https://www.cnblogs.com/auldlangsynezh/p/10469587.html

【Linux笔记(002) 】-- centos7 文档操作基本命令

索引&#xff1a; 目录索引 一、cd -- ChangeDirectory a) 切换到 /DemoLM/ 文件夹 b) 回到用户 Home 根目录&#xff1a;是哪个账户登录的就会进入哪个用户的根目录 二、pwd -- PrintWorkingDirectory a) 查看当前工作目录 三、mkdir -- MakeDirectory a) 创建一个 /test/ 目录…

JDBC操作数据库实例

返回目录&#xff1a;《学生信息管理系统&#xff08;JavaJSP&#xff09;》 这里以JDBC操作MySQL数据库为例。 假设有一个名为test的数据库&#xff0c;里面有一张学生表&#xff0c;表名称为student&#xff0c;表结构如下&#xff1a; student表结构表中数据如下&#xff1…

面向JavaScript开发人员的Adobe AIR与Dreamweaver

入门教程&#xff0c;非常详细&#xff0c;CS4里面应该可以省略前面几步直接开发了。 Adobe AIR对于HTML/JavaScript应用程序与桌面的集成有着出色的支持&#xff0c;但除了所有附加功能之外&#xff0c;还需要一些其他工具和技术。这篇文章探讨了使用HTML/JavaScript的Web开发…

在数据显示页面增加按姓名查询功能

在上一章内容《将数据库中表格信息输出到页面上》的基础上&#xff0c;增加按姓名查询功能。 问&#xff1a;怎么在显示学生信息的页面增加按照姓名查询的功能&#xff1f; 答&#xff1a;在显示学生信息的页面&#xff0c;使用<form>标签为用户创建表单&#xff0c;表单…

Spring AOP的一些概念

切面&#xff08;Aspect&#xff09;&#xff1a; 一个关注点的模块化&#xff0c;这个关注点可能会横切多个对象。事务管理是J2EE应用中一个关于横切关注点的很好的例子。 在Spring AOP中&#xff0c;切面可以使用通用类&#xff08;基于模式的风格&#xff09; 或者在普通类中…

有关于Matlab的regionprops函数的PixelIdxList和PixelList的一点解释

上一篇文章&#xff08;点击这里&#xff09;的最后一点说到了regionprops的相关参数的意思&#xff0c;但是总感觉不够明确 现在重新对PixelIdxList和PixelList的内容经过实验之后得到了点启发 1.首先用excel建立了一个如下的表格&#xff0c;然后用mat保存为mat的方式进行加载…

windows 系统无法启动windows event log 服务

windows 系统无法启动windows event log 服务 关键词&#xff1a;无法启动系统事件日志 尝试解决步骤 【1】权限&#xff1a;把如图中logsfile文件等都给local service 【2】把C:\Windows\System32\winevt\Logs下面的文件全部移走到其他文件夹&#xff0c;再启动服务试试看 【…

移动互联网漫谈(3)

1.1WIFI WIFI是无线局域网的一种&#xff0c;全称Wireless Fidelity&#xff0c;又称802.11b标准&#xff0c;它的最大优点就是传输速度较高&#xff0c;可以达到11Mbps&#xff0c;另外它的有效距离也很长&#xff0c;同时也与已有的各种802.11 DSSS设备兼容。今夏最流行的笔…

实现对学生表的删除操作

在上一章内容《数据显示页面》的基础上&#xff0c;增加删除超链接&#xff0c;实现删除功能&#xff1b; 修改内容&#xff1a; 在数据显示页面的表格中&#xff0c;增加一列&#xff0c;列名为“删除”&#xff0c;用来显示删除超链接&#xff1b;为表格的行标签&#xff08…

FRAME与IFRAME

FRAME与IFRAME框架概念 &#xff1a; 所谓框架便是网页画面分成几个框窗&#xff0c;同时取得多个 URL。只需要转载于:https://www.cnblogs.com/vibratea/archive/2009/07/24/1530098.html

react实现全选、取消全选和个别选择

react里面实现全选和取消全选&#xff0c;个别选择等操作&#xff0c;效果如下 代码&#xff1a; import React, {Component} from react export default class Demo extends React.Component{constructor(props,context){super(props,context);this.state {checklist:[{name:…

PAT1036:Boys vs Girls

1036. Boys vs Girls (25) 时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueThis time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students. Input …

NERO7光雕功能

找到NERO 7 PREMIUM的这个版本&#xff1a;Nero-7.10.1.0_chs_trial.exe百度中搜这个文件就找到了&#xff0c;用下面的序列号&#xff1a;1C80-0000-19E5-MA2X-4004-9268-7320&#xff0c;再装上最新版的官方光雕程序&#xff08;集成了加深标签的插件&#xff09;&#xff1a…

hive函数 get_json_object的使用

hive提供了json的解析函数&#xff1a;get_json_object 使用方法 对于jsonArray&#xff08;json数组&#xff09;&#xff0c;如person表的xjson字段有数据&#xff1a; [{"name":"王二狗","sex":"男","age":"25"…

实现对学生信息的增加操作

上一篇博客&#xff1a;《实现对学生表的删除操作》返回目录&#xff1a;《学生信息管理系统&#xff08;JavaJSP&#xff09;》本篇博客将介绍如何实现学生表中学生信息的增加操作。 1、在test1模块的web目录下&#xff0c;新建一个stuAddForm.jsp文件&#xff08;文件内容如…

【BZOJ 3879】SvT

【链接】h在这里写链接 【题意】 给你一个长度为n的字符串以及m个询问。 每个询问询问你所给的一些后缀,所有任意两个后缀之间的lcp的总和; n<5*10^5 ∑t<3*10^6【题解】 按照这些后缀的rank值升序排 ->利用Sa数组 即输入一个x,x--; sort(a1,…

快速计算表达式树

前言 .NET 3.5中新增的表达式树&#xff08;Expression Tree&#xff09;特性&#xff0c;第一次在.NET平台中引入了“逻辑即数据”的概念。也就是说&#xff0c;我们可以在代码里使用高级语言的形式编写一段逻辑&#xff0c;但是这段逻辑最终会被保存为数据。正因为如此&#…

随手拈来尽是折劲额事体

昨天中午&#xff0c;justina同学请我去港丽吃饭&#xff0c;世界顿时美好了&#xff01; 猛地发现&#xff0c;港丽的酸菜鱼竟然非常好吃&#xff0c;除了价钱贵&#xff0c;基本没有缺点了。 吃饭的时候&#xff0c;看到两件有劲的事情&#xff0c;一件比一件更折劲&#xff…

06 面向对象之:反射,双下方法

一、反射 反射的概念是由Smith在1982年首次提出的&#xff0c;主要是指程序可以访问、检测和修改它本身状态或行为的一种能力&#xff08;自省&#xff09;。这一概念的提出很快引发了计算机科学领域关于应用反射性的研究。它首先被程序语言的设计领域所采用,并在Lisp和面向对象…

实现对学生信息的修改操作

返回目录&#xff1a;《学生信息管理系统&#xff08;JavaJSP&#xff09;》 本篇博客主要实现对学生信息的修改操作&#xff1b; 步骤1、在学生信息的显示页面&#xff08;即student.jsp页面&#xff09;中&#xff0c;在表格最后增加一列“修改”超链接&#xff0c;在<tr&…

UML用例图概要(转)

用例图主要用来图示化系统的主事件流程&#xff0c;它主要用来描述客户的需求&#xff0c;即用户希望系统具备的完成一定功能的动作&#xff0c;通俗地理解用例就是软件的功能模块&#xff0c;所以是设计系统分析阶段的起点&#xff0c;设计人员根据客户的需求来创建和解释用例…

Python之迭代器,生成器与装饰器

1》迭代器原理及使用&#xff1a; 1>原理&#xff1a; 迭代器是访问集合元素的一种方式&#xff0c;迭代器对象从集合的第一个元素开始访问&#xff0c;直到所有的元素被访问完结束&#xff1b;迭代器只能往前不会后退&#xff0c;不过这也没什 么&a…

像乔布斯一样演讲

当苹果公司CEO史蒂夫-乔布斯开始今年&#xff08;2008年1月&#xff09;的Macworld时&#xff0c;我们看到他的商业演讲&#xff08;以下简称&#xff1a;演讲&#xff09;水平更上了一层楼。所有人都希 望能够在演讲中能更加简明扼要&#xff0c;乔布斯做到了&#xff0c;并且…

UNICODE使用的一些知识和技巧

UNICODE宏和_UNICODE宏的关系 在windows编程中,经常要编译Unicode版本的程序,方法是工程文件的配置中加上UNICODE或者_UNICODE编译条件,那么到底是用哪一个呢? Jeffrey Richter在《Windows核心编程》中说,_UNICODE宏用于C运行期头文件,而UNICODE宏则用于Windows头文件.当编译源…

编程学习网站收集

目录 1. 菜鸟教程 1.1 Java 教程 1.2 HTML 教程 1.3 CSS 教程 1.4 JavaScript 教程 1.5 JSP 教程 1.6 Servlet 教程 1.7 jQuery 教程 1.8 AJAX 教程 1.9 MySQL 教程 2. 易百教程 3. w3school 在线教程 1. 菜鸟教程 菜鸟教程 (www.runoob.com) 提供了编程的基础技术…

js短路表达式

今天碰见个题目&#xff0c;感觉短路表达式很好用。 题目&#xff1a; 定义一个计算圆面积的函数area_of_circle()&#xff0c;它有两个参数&#xff1a;r: 表示圆的半径&#xff1b;pi: 表示π的值&#xff0c;如果不传&#xff0c;则默认3.14function area_of_circle(r, pi) …

51nod 1065 最小正字段和 解决办法:set存前缀和,二分插入和二分查找

题目&#xff1a; 这题要求大于0的最小字段和&#xff0c;常规O&#xff08;n&#xff09;求最大字段和的方法肯定是没法解的。 我的解法是&#xff1a;用sum[i]存前i项的和&#xff0c;也就是前缀和。 这题就变成了求sum[j]-sum[i]的大于0的最小值( j > i )。 我们可以看到…

著名作者网站论文下载

http://www.cs.wright.edu/~agoshtas/ardyCV.htmlhttp://www.cse.msu.edu/~stockman/http://www.dkfz.de/tbi/people/homepages/rohr/转载于:https://www.cnblogs.com/stoneresearch/archive/2008/11/06/4336753.html

内存与进程管理

这一节的内容有点杂&#xff0c;只能自己手动输入了 1.uname命令用于打印当前系统相关信息&#xff08;内核版本号、硬件架构、主机名称和操作系统类型等&#xff09;。 uname -a显示全部信息 2.cat /etc/redhat-release 查看当前系统版本 3.free -m / -g 查看内存使用状况&…