Oracle PL / SQL Programming

2010-11-11  来源:本站原创  分类:Database  人气:46 

One, if then statement
create or replace procedure IfThenProc is
begin
- Created on 2008-1-19 by ADMINISTRATOR
declare
---- Define a cursor
CURSOR my_cursor IS
SELECT * from master;
---- Define the variables, the data stored by taking the cursor
my_rec my_cursor% ROWTYPE;
begin
---- Open the cursor
OPEN my_cursor;
loop
---- The data into the cursor variable my_rec
FETCH my_cursor INTO my_rec;
---- When the cursor is no data, exit the loop
EXIT WHEN my_cursor% NOTFOUND;

IF my_rec.admin_id> 0 THEN
dbms_output.put_line ('test');
END IF;

END loop;
CLOSE my_cursor;
end;
end IfThenProc;
Two, loop statements
create or replace procedure LoopProc is
begin
declare
- Local variables here
x number;
begin
- Test statements here
x: = 0;
loop
x: = x +1;
dbms_output.put_line (to_char (x));
exit when x = 20;
end loop;
end;
end LoopProc;
Three, while the statement
create or replace procedure WhileProc is
begin
- Created on 2008-1-19 by ADMINISTRATOR
declare
- Local variables here
x number;
begin
- Test statements here
x: = 1;
while x <10
loop
dbms_output.put_line (to_char (x) | | 'has less than 10');
x: = x +1;
end loop;
end;
end WhileProc;
Four, for statement
create or replace procedure ForProc is
begin
- Created on 2008-1-19 by ADMINISTRATOR
begin
- Test statements here
for I IN REVERSE 1 .. 10
loop
dbms_output.put_line ('in =' | | to_char (I));
end loop;
end;
end ForProc;
Fifth, the cursor
create or replace procedure CursorProc is
begin
- Created on 2008-1-19 by ADMINISTRATOR
declare
- Local variables here
cursor c1 is
select admin_name, admin_id from master where rownum <11;
v_name varchar2 (60);
v_id number (7,2);
begin
open c1;
fetch c1 into v_name, v_id;
while c1% found
loop
dbms_output.put_line (v_name | | to_char (v_id));
fetch c1 into v_name, v_id;
end loop;
close c1;
end;
end CursorProc;

相关文章
  • oracle PL / SQL Programming Notes 2010-08-07

    1. The first paradigm: all the attributes are inseparable entities, and that the table to meet 1NF; The second paradigm: allow more than one property as the main code with the third paradigm: there is no dependence of the transfer function, namely, t

  • Oracle PL / SQL Programming Guide Specification 2010-05-11

    1, PL / SQL programming specification of the case As in SQL, as, PL / SQL is not case sensitive. The general guidelines are as follows: Keyword (BEGIN, EXCEPTION, END, IF THEN ELSE, LOOP, END LOOP), the data type (VARCHAR2, NUMBER), the internal func

  • Original: oracle PL / SQL programming based on the <eleven> 2011-04-29

    PL/SQL Is the oracle of the special language , Its standard SQL language extensions .SQL Statements can be nested in a PL / SQL language , Combined processing statement . PL/SQL Program Structure Use the block structure of the organization code. The

  • Original: oracle PL / SQL programming basis <twelve> 2011-04-29

    Cursor : Cursor (cursor) Can be seen as pointing to the result set (a set of rows) Pointers in a row (pointer). In oracle database can be displayed or hidden using the two kinds of cursor . Implicit Cursor : When running a sql statement ,oracle The s

  • Oracle PL / SQL Programming Fundamentals 2010-11-11

    One, if then statement create or replace procedure IfThenProc is begin - Created on 2008-1-19 by ADMINISTRATOR declare ---- Defined cursor CURSOR my_cursor IS SELECT * from master; ---- Define variables, taken from the data stored cursor my_rec my_cu

  • Oracle PL / SQL Programming 2010-11-11

    One, if then statement create or replace procedure IfThenProc is begin - Created on 2008-1-19 by ADMINISTRATOR declare ---- Define a cursor CURSOR my_cursor IS SELECT * from master; ---- Define the variables, the data stored by taking the cursor my_r

  • oracle pl \ sql book recommendations 2010-09-10

    Development for some time, had never used stored procedures, has recently started to write oracle pl \ sql Entry is very easy to find, Reference books: Oracle.PL.SQL.Programming Written in easy to understand, with a small example of O_Reilly Oracle.P

  • Oracle PL / SQL e-books to download 2011-03-17

    Oracle.PL.SQL.Programming.4th.Edition

  • Oracle PL/SQL之嵌套表(Nested Table) 2012-03-09

    Test Code: Connected to Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 Connected as xxpo SQL> CREATE OR REPLACE TYPE color_tab_t AS TABLE OF VARCHAR2(30); 2 / Type created SQL> SQL> CREATE TABLE color_models ( 2 model_type VARCHAR2(12)

  • oracle sum of ten ---PL/SQL Programming 2011-04-18

    PL / SQL Programming PL / SQL is the oracle of the special language, its standard SQL language extension. SQL statements can be nested in a PL / SQL language, and combined treatment statement. PL / SQL program using the block structure of the structu

  • Book: Oracle 11g PL / SQL Programming 2011-09-18

    Oracle 11g PL / SQL Programming

  • oracle pl / sql examples of practice 2010-03-30

    Part I: oracle pl / sql instance of practice (1) First, using the scott / tiger emp table under the user and the dept table to complete the following exercises, table structure described below Staff table emp (empno Staff No. / ename employee name /

  • PL / SQL programming based learning summary 2010-05-27

    PL / SQL Programming 1. How to write and compile PL / SQL Because PL / SQL is embedded in the Oracle server and Oracle development tool, so Oracle client tools and server can write PL / SQL procedure SQL> edit c: \ plsqlblock1.sql; - to build a docum

  • Chapter 5 using Oracle PL / SQL 2011-05-12

    Chapter 4 Oracle synonyms, sequences, views, indexes Chapter 6 Oracle cursor Chapter 5 using Oracle PL / SQL 1, the technical objectives Understanding PL / SQL functions and features Understanding of data types and their usage Understand the logic of

  • PL / SQL Programming 2011-04-10

    "PL / SQL Programming" / * Procedural language / sql * / - 1, procedures, functions, triggers a pl / sql written - 2, procedures, functions, triggers in oracle in - 3, pl / sql is very powerful database procedure language - 4, procedure, functio

  • Finishing: oracle pl / sql cursor entry + + + dynamic array using SQL 2011-06-23

    Transfer to: http://dolphin-ygj.iteye.com/blog/4402041.1 PL / SQL Introduction PL / SQL is the ORACLE procedural language, including a set of data types, conditional structures, loops and exception handling structures, PL / SQL can execute SQL statem

  • PL / SQL Programming - Study Notes 1 - Introduction and Composition 2011-08-25

    A, PL / SQL Programming Introduction to advanced database programming language, access to the ORACLE database, PL / SQL is the ORACLE system's core language. PL / SQL Procedure Language & Structured Query Language PL / SQL stored procedures, SQL lang

  • Oracle PL / SQL exception 2010-03-10

    Oracle PL / SQL exception Named system exception causes ACCESS_INTO_NULL Undefined object CASE_NOT_FOUND CASE If does not contain the appropriate WHEN, and if there are no settings ELSE When COLLECTION_IS_NULL A collection of elements is not initiali

  • Does not appear to delete all the replies show replies show star returns to score back ORACLE PL / SQL string functions. Mathematical functions. Date function 2010-08-04

    ORACLE PL / SQL string functions, math functions, date functions - String functions] [ - String interception substr (field name, the starting point, number) select Name, substr (Name, 2,4), substr (Name, 0,3), substr (Name, -2,3), substr (Name, -2,1)

  • Using oracle pl / sql developer summed up the points 2010-09-04

    Using oracle pl / sql developer summed up the points 1. Only the implementation of the cursor sql statement setting: / Tool / Preferences / SQL Windows / select Auto Select Statement, if not selected, the sql windows have all the sql execution. Note: