OracleºÍMSSQLÖÐÑ»·µÄʹÓÃ
ORACLE
CREATE OR REPLACE FUNCTION SETSTATE(OLDVALUE VARCHAR2, POS NUMBER, SVALUE VARCHAR2)
RETURN VARCHAR2
IS
RETURN_VALUE VARCHAR2 (20);
LEN NUMBER(8);
I NUMBER(8);
TEMP_VALUE VARCHAR2(1);
BEGIN
LEN := LENGTH(OLDVALUE);
IF POS > LEN THEN
RETURN 'Ö¸¶¨µÄË÷Òý´óÓÚ×Ö·û´®µÄ³¤¶È£¡';
END IF;
I := 0;
RETURN_VALUE := '';
FOR I IN 1..LEN LOOP
TEMP_VALUE := SUBSTR(OLDVALUE, I, 1);
IF I = POS THEN
TEMP_VALUE := SVALUE;
END IF;
RETURN_VALUE := RETURN_VALUE || TEMP_VALUE;
END LOOP;
RETURN RETURN_VALUE;
END;
MSSQL
IF EXISTS(SELECT * from SYSOBJECTS WHERE NAME = 'SETSTATE')
DROP FUNCTION SETSTATE
GO
CREATE FUNCTION SETSTATE(@OLDVALUE NVARCHAR(20), @POS INT, @SVALUE NVARCHAR(1))
RETURNS NVARCHAR(20)
AS
BEGIN
DECLARE @RETURN_VALUE NVARCHAR(20),
@LENGTH INT,
@I INT,
@TEMP_VALUE NVARCHAR(1);
SET @LENGTH = LEN(@OLDVALUE);
SET @I = 1;
SET @RETURN_VALUE = '';
IF(@POS > @LENGTH)
SET @RETURN_VALUE = @OLDVALUE;
ELSE
BEGIN
WHILE(@I <= @LENGTH)
BEGIN
SET @TEMP_VALUE = SUBSTRING(@OLDVALUE, @I, 1);
IF (@I = @POS)
SET @TEMP_VALUE = @SVALUE;
SET @RETURN_VALUE = @RETURN_VALUE + @TEMP_VALUE;
SET @I = @I + 1;
END
END
RETURN @RETURN_VALUE;
END
GO
Ïà¹ØÎĵµ£º
¶þÁãÁã¾ÅÄêʮԶþÊ®ÈÕ£¬´ò´ÓÈýÄêÇ°ÍƳöOracle¼Ó½ô¼Æ»®ÒÔÀ´£¬¼×¹ÇÎĹ«Ë¾ÒѾÔö¼ÓÁËÆß,000¶à¼ÒÖÎÀíÈí¼þÖÐÐÍÆóÒµ¿Í»§£¬µ±Ç°ÖÐÐÍÆóÒµ¿Í»§×ÜÁ¿ÒѾ³¬¹ý25,000¼Ò¡£
͸¹ýÍƳöÂíÏòÖÐÐÍÆóÒµ¿Í»§µÄOracle¼Ó¿ì¼Æ»®Ð¹¦ÄÜ£¬°üÀ¨ÐÂʽ¼Ó¿ì¼Æ»®½â¾ö·½°¸¡¢OracleÆóÒµ¼ÓËÙÆ÷¡¢²ÆÎñÑ¡¼þºÍµ÷¶È²½ÖèµÈ£¬¼×¹ÇÎÄÔÚ²»Í£¶ÒÏÖ˳Àû¡£
ÃæÁÙÖÐÐÍ ......
Ubuntu9.04ÏÂOracleÊÖ¶¯Æô¶¯Óë×ÔÆô¶¯½Å±¾
Ò»¡¢Æô¶¯Êý¾Ý¿âʵÀý
Java´úÂë
gengzhi
@gengzhi
-desktop:~$ su oracle
oracle@gengzhi
-desktop:~$ sqlplus
" scott/tiger as sysdba"
gengzhi@gengzhi-desktop:~$ s ......
OracleÖк¯ÊýÒÔÇ°½éÉܵÄ×Ö·û´®´¦Àí£¬ÈÕÆÚº¯Êý£¬Êýѧº¯Êý,ÒÔ¼°×ª»»º¯ÊýµÈµÈ£¬»¹ÓÐÒ»ÀຯÊýÊÇͨÓú¯Êý¡£Ö÷ÒªÓУºNVL,NVL2,NULLIF,COALESCE£¬Õ⼸¸öº¯ÊýÓÃÔÚ¸÷¸öÀàÐÍÉ϶¼¿ÉÒÔ¡£
ÏÂÃæ¼òµ¥½éÉÜһϼ¸¸öº¯ÊýµÄÓ÷¨¡£
ÔÚ½éÉÜÕâ¸ö֮ǰÄã±ØÐëÃ÷°×ʲôÊÇoracleÖеĿÕÖµnull
1.NVLº¯Êý
NVLº¯ÊýµÄ¸ñʽÈçÏ£ºNVL(expr1,expr2)
º¬ÒåÊ ......
ÕâÒ»ÕÂÖУ¬ÎÒÃǽ«·ÖÎö¹¹³ÉÊý¾Ý¿âºÍʵÀýµÄ8 ÖÖÎļþÀàÐÍ¡£
ÓëʵÀýÏà¹ØµÄÎļþÖ»ÓУº
²ÎÊýÎļþ£¨parameter file£©£ºÕâЩÎļþ¸æËßOracle ʵÀýÔÚÄÄÀï¿ÉÒÔÕÒµ½¿ØÖÆÎļþ£¬²¢ÇÒÖ¸
¶¨Ä³Ð©³õʼ»¯²ÎÊý£¬ÕâЩ²ÎÊý¶¨ÒåÁËijÖÖÄÚ´æ½á¹¹Óжà´óµÈÉèÖá£ÎÒÃÇ»¹»á½éÉÜ´æ´¢Êý¾Ý¿â²Î
ÊýÎļþµÄÁ½ÖÖÑ¡Ôñ¡£
¸ú×ÙÎļþ£¨trace file£ ......