oracle中pl/sql编程 编写1+2+3+。。。。+100的和??

yadegougou 2010-12-06 11:13:10
oracle中pl/sql编程 编写1+2+3+。。。。+100的和??
小妹要考试了 这个不会啊?哪个大侠会啊???
...全文
1232 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
luoyoumou 2010-12-07
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 lxyzxq2008 的回复:]

SQL code

select sum(rownum) sum101 from dual connect by rownum <=100
----------------------------------------------------------
5050


拜膜楼主,您太有分了~
[/Quote]

-- 不错:一个 connect by 搞定......
Dream_1986 2010-12-07
  • 打赏
  • 举报
回复

declare
ssum number;
begin
ssum := 0;
for i in 1 .. 100 loop
ssum := ssum + i;
end loop;
dbms_output.put_line(ssum);
end;
lxyzxq2008 2010-12-06
  • 打赏
  • 举报
回复 1

select sum(rownum) sum101 from dual connect by rownum <=100
----------------------------------------------------------
5050

拜膜楼主,您太有分了~
心中的彩虹 2010-12-06
  • 打赏
  • 举报
回复
[Quote=引用楼主 yadegougou 的回复:]
oracle中pl/sql编程 编写1+2+3+。。。。+100的和??
小妹要考试了 这个不会啊?哪个大侠会啊???
[/Quote]

SQL> set serveroutput on
SQL> declare
2 c_sum number:=0;
3 begin
4 for i in 1..100 loop
5 c_sum:=c_sum+i;
6 end loop;
7 dbms_output.put_line(c_sum);
8 end;
9 /
5050

PL/SQL 过程已成功完成。




minitoy 2010-12-06
  • 打赏
  • 举报
回复
SQL> set serveroutput on
SQL>
SQL> declare
2 v_num number;
3 i number;
4 begin
5 i := 0 ;
6 v_num := 0;
7 loop
8 exit when i = 101;
9 v_num := i + v_num;
10 i := i + 1;
11 end loop;
12 dbms_output.put_line(v_num);
13 end;
14 /

5050

PL/SQL procedure successfully completed

SQL>
minitoy 2010-12-06
  • 打赏
  • 举报
回复
SQL> set serveroutput on
SQL>
SQL> declare
2 v_num number;
3 i number;
4 begin
5 i := 0 ;
6 v_num := 0;
7 loop
8 exit when i = 101;
9 v_num := i + v_num;
10 i := i + 1;
11 end loop;
12 dbms_output.put_line(v_num);
13 end;
14 /

5050

PL/SQL procedure successfully completed

SQL>
  • 打赏
  • 举报
回复
--小妹妹,不用重复发帖哦

declare
cnt number:=0;
begin
for i in 1..100 loop
cnt:=cnt+i;
end loop;
dbms_output.put_line(cnt);
end;
njlywy 2010-12-06
  • 打赏
  • 举报
回复

declare
cnt number:=0;
begin
for i in 1..100 loop
cnt:=cnt+i;
end loop;
dbms_output.put_line(cnt);
end;
谢谢大家的支持,我会陆续上传相关电子书 由于体积较大,本书分两卷压缩,请都下载完再解压! Oracle 11g SQLPL SQL从入门到精通 pdf格式电子书 下载(一) http://download.csdn.net/source/3268267 Oracle 11g SQLPL SQL从入门到精通 pdf格式电子书 下载(二) http://download.csdn.net/source/3268312 内容简介   本书是专门为oracle应用开发人员提供的sqlpl/sql编程指南。通过学习本书,读者不仅可以掌握oracle常用工具oracle universal installer、net comfiguration assistant、sql developer、sql*plus的作用及使用方法,而且可以掌握sql语句和pl/sql的各种基础知识和高级特征(记录类型、集合类型、对象类型、大对象类型)。   除了为读者提供编写sql语句和开发pl/sql块的方法外,本书还为应用开发人员提供了一些常用的pl/sql系统包。通过使用这些pl/sql系统包,应用开发人员可以开发出功能更强大的数据库应用程序。本书不仅适合sqlpl/sql初学者,也适合于有经验的oracle应用开发人员。 前言 第一部分 sqlpl/sql相关工具  第1章 在windows 平台上安装oracle database 11g  第2章 配置网络服务名  第3章 使用sql database  第4章 使用sql*plus 第二部分 sql  第5章 sqlpl/sql综述  第6章 简单查询  第7章 sql单行函数  第8章 操纵数据  第9章 复杂查询  第10章 管理常用对象 第三部分 pl/sql  第11章 pl/sql基础  第12章 访问oracle  第13章 编写控制结构  第14章 使用复合数据类型  第15章 使用游标  第16章 异常处理 . 第17章 本地动态sql  第18章 pl/sql过程  第19章 pl/sql函数  第20章 pl/sql包  第21章 触发器  第22章 使用对象类型 第四部分 pl/sql系统包  第23章 使用大对象  第24章 读写os文件  第25章 开发多媒体应用  第26章 开发web应用  第27章 dbms_sq动态sql  第28章 管理统计  第29章 使用数据库资源管理器  第30章 数据加密和解密  第31章 使用调度程序  第32章 使用flashback  第33章 使用重定义联机表  第34章 修正损坏块  第35章 使用日里民挖掘  第36章 使用管道  第37章 使用精细访问控制  第38章 使用精细审计  第39章 使用预警事件  第40章 转换rowid  第41章 其他常用包 习题答案
作者:Steven Feuerstein, Bill Pribyl 出版日期:October 1, 2009 出版社:O'Reilly 页数:1226 ISBN:ISBN-10: 0596514468 ISBN-13: 978-0596514464 文件格式:PDF 文件大小:15.06 MB Review If you’re doing database application development in the Oracle environment, you’re going to have to know PL/SQL, the company’s extended query and update language. If you want your programs to exploit the special capabilities of Oracle software, you’ll need to know the language well. That’s where the third edition of Oracle PL/SQL Programming comes into play. It’s an absolutely comprehensive reference (as well as a rather extensive tutorial) on PL/SQL, ideally suited to answering your questions about how to perform some programming tasks and reminding you of the characteristics of functions, triggers, and other elements of the database programmer’s toolkit. The new edition covers calls to Java methods from within PL/SQL programs, autonomous transactions, object type inheritance, and the new Timestamp and XMLType data types. There’s also more information about server internals–the way PL/SQL programs are run–than before, better enabling readers to optimize their code for fast and safe execution. Steven Feuerstein takes care to explain, with prose and example code, the characteristics of PL/SQL elements. In explaining number conversions, for example, he explores Oracle’s different ways of formatting numbers, then details the behavior of the to_number function under different conditions (with and without a specified format model, and with National Language Support information attached). It’s a helpful approach that will have readers using the index to locate places in which Feuerstein mentions language elements of interest. –David Wall Topics covered: How to use Oracle PL/SQL in all its manifestations through Oracle9i. Fundamentals of program structure (loops, cases, exceptions, etc.) and execution get attention, as do data types, transaction management, triggers, and the object-oriented aspects of the language. There’s also coverage of calls to external Java and C programs. –This text refers to the Paperback edition. Product Description This book is the definitive reference on PL/SQL, considered throughout the database community to be the best Oracle programming book available. Like its predecessors, this fifth edition of Oracle PL/SQL Programming covers language fundamentals, advanced coding techniques, and best practices for using Oracle’s powerful procedural language. Thoroughly updated for Oracle Database 11g Release 2, this edition reveals new PL/SQL features and provides extensive code samples, ranging from simple examples to complex and complete applications, in the book and on the companion website. This indispensable reference for both novices and experienced Oracle programmers will help you: Get PL/SQL programs up and running quickly, with clear instructions for executing, tracing, testing, debugging, and managing PL/SQL code Optimize PL/SQL performance with the aid of a brand-new chapter in the fifth edition Explore datatypes, conditional and sequential control statements, loops, exception handling, security features, globalization and localization issues, and the PL/SQL architecture Understand and use new Oracle Database 11g features, including the edition-based redefinition capability, the function result cache, the new CONTINUE statement, fine-grained dependency tracking, sequences in PL/SQL expressions, supertype invocation from subtypes, and enhancements to native compilation, triggers, and dynamic SQL Use new Oracle Database 11g tools and techniques such as PL/Scope, the PL/SQL hierarchical profiler, and the SecureFiles technology for large objects Build modular PL/SQL applications using procedures, functions, triggers, and packages

17,140

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧