PL/SQLѧϰ±Ê¼ÇÎå
ÓαêÊÇ´ÓÊý¾Ý¿âÖÐÌáÈ¡³öÀ´µÄÊý¾Ý£¬ÒÔÁÙʱ±íµÄÐÎʽ´æ·ÅÔÚÄÚ´æÖУ¬ÔÚÓαêÖÐÓÐÒ»¸öÊý¾ÝÖ¸Õ룬ÔÚ³õʼ״̬ÏÂÖ¸ÏòÊ׼Ǽ£¬ ÀûÓÃfetchÓï¾äÒƶ¯¸ÃÖ¸Õ룬´Ó¶ø¶ÔÓαêÖеÄÊý¾Ý½øÐи÷ÖÖ²Ù×÷¡£
1.¶¨ÒåÓαê
cursor ÓαêÃû is selectÓï¾ä;
2.´ò¿ªÓαê
open ÓαêÃû;
3.ÌáÈ¡ÓαêÊý¾Ý
fetch ÓαêÃû into ±äÁ¿Ãû1, ±äÁ¿Ãû2, ....;
»ò
fetch ÓαêÃû into ¼Ç¼ÐͱäÁ¿Ãû;
4.¹Ø±ÕÓαê
close ÓαêÃû;
5.ÓαêµÄÊôÐÔ
%isopen
¸ÃÊôÐÔ±êʶÓαêÊÇ·ñ´ò¿ª£¬Èç¹ûûÓдò¿ªÓαê¾ÍʹÓÃfetchÓï¾ä½«Ìáʾ´íÎó¡£
%isfound
¸ÃÊôÐÔ±êʶһ¸öfetchÓï¾äÊÇ·ñÓÐÖµ£¬ÓÐÖµ·µ»Øtrue£¬·ñÔò·µ»Øfalse¡£
%notfound
¸ÃÊôÐÔÓë%isfoundÏà·´¡£
%rowcount
¸ÃÊôÐÔÓÃÓÚ»ñÈ¡ÓαêµÄÊý¾ÝÐÐÊý¡£
ʾÀý£º
set serveroutput on
declare
tempsal scott.emp.sal%type;
cursor mycursor is
select * from scott.emp
where sal>tempsal;
cursorrecord mycursor%rowtype;
begin
tempsal:=800;
open mycursor;
if mycursor%isopen then
fetch mycursor into cursorrecord;
dbms_output.put_line(to_char(cursorrecord.deptno));
dbms_output.put_line(to_char(mycursor%rowcount));
else
dbms_output.put_line('Óα껹δ´ò¿ª');
end if;
end;
Ïà¹ØÎĵµ£º
1¡¢SessionÓÐʲôÖØ´óBUG£¬Î¢ÈíÌá³öÁËʲô·½·¨¼ÓÒÔ½â¾ö£¿
´ð£ºÊÇiisÖÐÓÉÓÚÓнø³Ì»ØÊÕ»úÖÆ£¬ÏµÍ³·±Ã¦µÄ»°Session»á¶ªÊ§£¬¿ÉÒÔÓÃSate server»òSQL ServerÊý¾Ý
¿âµÄ·½Ê½´æ´¢Session²»¹ýÕâÖÖ·½Ê½±È½ÏÂý£¬¶øÇÒÎÞ·¨²¶»ñSessionµÄENDʼþ¡£
2.²úÉúÒ»¸öintÊý×飬³¤¶ÈΪ100£¬²¢ÏòÆäÖÐËæ»ú²åÈë1-100£¬²¢ÇÒ²»ÄÜÖظ´¡£
C# ......
1. ¼òÊö private¡¢ protected¡¢ public¡¢ internal ÐÞÊηûµÄ·ÃÎÊȨÏÞ¡£
´ð . private : ˽ÓгÉÔ±, ÔÚÀàµÄÄÚ²¿²Å¿ÉÒÔ·ÃÎÊ¡£
protected : ±£»¤³ÉÔ±£¬¸ÃÀàÄÚ²¿ºÍ¼Ì³ÐÀàÖпÉÒÔ·ÃÎÊ¡£
public : ¹«¹²³ÉÔ±£¬ÍêÈ«¹«¿ª£¬Ã»ÓзÃÎÊÏÞÖÆ¡£
internal: ÔÚÍ¬Ò ......
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[pagination]
@tblName varchar(255), -- ±íÃû
@strGetFields varchar(1000), -- ÐèÒª·µ»ØµÄÁÐ
@fldName varchar(255), -- ÅÅÐòµÄ×Ö¶ÎÃû
@PageSize int, -- Ò³³ß´ç
@PageIndex int, -- Ò³Âë
@OrderType bit, -- ÉèÖÃÅÅÐòÀàÐÍ, ·Ç 0 Öµ ......
ALTER procedure [dbo].[sp_lock_check]
@spid1 int = NULL,
@spid2 int = NULL
as
set nocount on
if @spid1 is not NULL
begin
select ......