Oracle ´æ´¢¹ý³Ì·µ»Ø½á¹û¼¯ÓÃ
Oracle ´æ´¢¹ý³Ì·µ»Ø½á¹û¼¯Óà ref cursor ʵÏÖ¡£ÊÔÑé²½ÖèÈçÏ£º
1. ½¨Á¢ ref cursor ÀàÐͺ͹ý³Ì
CREATE OR REPLACE PACKAGE types
AS
TYPE ref_cursor IS REF CURSOR;
END;
/
CREATE TABLE STOCK_PRICES(
RIC VARCHAR(6) PRIMARY KEY,
PRICE NUMBER(7,2),
UPDATED DATE );
/
CREATE OR REPLACE FUNCTION sp_get_stocks(v_price IN NUMBER)
RETURN types.ref_cursor
AS
stock_cursor types.ref_cursor;
BEGIN
OPEN stock_cursor FOR
SELECT ric,price,updated from stock_prices WHERE price < v_price;
RETURN stock_cursor;
END;
2. Óà sqlplus ²âÊÔ¹ý³Ì
SQL> var results refcursor
SQL> exec :results := sp_get_stocks(20.0)
SQL> print results
3. ´Ó Java µ÷ÓÃ
import java.sql.*;
import java.io.*;
import oracle.jdbc.driver.*;
public class JDBCDemo {
/**
* Compile-time flag for deciding which query to use
*/
private boolean useOracleQuery = true;
/**
* Class name of Oracle JDBC driver
*/
private String driver = "oracle.jdbc.driver.OracleDriver";
/**
* Initial url fragment
*/
private String url = "jdbc:oracle:thin:@";
/**
* Standard Oracle listener port
*/
private String port = "1521";
/**
* Oracle style of calling a stored procedure
*/
private String oracleQuery = "begin ? := sp_get_stocks(?); end;";
/**
* JDBC style of calling a stored procedure
*/
private String genericQuery = "{ call ? := sp_get_stocks(?) }";
/**
Ïà¹ØÎĵµ£º
ORACLE¿ª·¢¹¤¾ß²ßÂÔ½éÉÜ
ºÜ¶àͬѧÎÊÆðÎÒÃÇOracle ERP¶þ´Î¿ª·¢ÒÔºó»áʹÓÃʲôÑùµÄÓïÑԺͿª·¢¹¤¾ß£¿Ê×ÏÈÎÒÃÇÀ´¿´¿´Oracle¿ª·¢¹¤¾ß²úÆ·µÄ²ßÂÔ
Oracle¿ª·¢¹¤¾ßµÄ²ßÂÔÊÇÌṩÄܹ»¿ª·¢»ùÓÚInternetÄ£ÐÍÏÂÆóÒµÓ¦ÓõÄÈí¼þ¿ª·¢¹¤¾ß£¬Òò´ËOracleÌṩÁËÁ½¸ö²¢ÐеĿª·¢¹¤¾ßÒÔ¼°ÐµĿìËÙWeb¿ª·¢¹¤¾ß£º
Ò»£¬»ùÓÚPL/SQLÓïÑÔ»·¾³µÄ´«Í³¿ ......
Q£ºÎҵıíÖÐÓÐÒ»¸ö×Ö¶ÎÊÇvarchar2(4000) £¬ÆäÖд洢Á˲»ÉÙÖÐÎÄ£¬ÏÖÔÚÓÉÓÚÅŰæÐèÒª£¬ÎÒÏëÕÒ³öº¬Óлسµ·ûµÄ¼Ç¼ɾ³ý»Ø³µ·û£¬ÇëÎʸßÊÖSQLÓï·¨Ôõôд£¿
A£ºOracleÖлسµ·ûÊÇchr(10),¿ÉÒÔʹÓú¯Êýreplace(×Ö¶Î,chr(10),'')
È磺 update x set a=replace(a,chr(10),'')¡£
º¯Êý£º
1.CHR
¸ø³öÕûÊ ......
author£ºskate
time£º2010-05-25
OracleÊý¾Ý¿â¹ÜÀí½Å±¾ËµÃ÷
Oracle ÖеÄÊý¾Ý×ÖµäÊÇÊý¾Ý¿âÖеķdz£ÖØÒªµÄÒ»²¿·Ö£¬ÌṩÁËÏà¹ØÊý¾Ý¿âµÄÐÅÏ¢£¬ËüÊÇËùÓÐOracleÓû§£¨´ÓÓ¦ÓõÄ×îÖÕÓû§¡¢Ó¦ÓõÄÉè¼Æ¿ª·¢Õßµ½Êý¾Ý¿â¹ÜÀíÔ±£©µÄ·Ç³£ÖØÒªµÄÐÅÏ¢À´Ô´¡£Êý¾Ý×ÖµäµÄ´´½¨£¬ÊÇÔÚOracleÊý¾Ý¿â´´½¨Íê±Ïºó£¬ÔËÐÐһЩÏà¹ØµÄÊý¾Ý¿â¹ÜÀí½Å±¾À´Íê ......
CmdÃüÁîÐÐÊäÈëlsnrctl½øÈë¼àÌýģʽ£¬Í¨¹ýset passwordÉèÖÃÃÜÂë¡£
ͨ¹ý change_password ÐÞ¸ÄÃÜÂë¡£
LSNRCTL> help
ÒÔϲÙ×÷¿ÉÓÃ
ÐǺŠ(*) ±íʾÐ޸ķû»òÀ©Õ¹ÃüÁ
start stop &nbs ......
²é¿´oracle·þÎñÆ÷×Ö·û¼¯:select * from nls_database_parameters where parameter = 'NLS_CHARACTERSET'
ʹÓÃPl/SQL ²éѯÊý¾ÝʱÂÒÂë,²åÈëÊý¾ÝʱÂÒÂë
Êý¾Ý¿â·þÎñÆ÷µÄ×Ö·û¼¯ºÍ¿Í»§¶ËµÄ×Ö·û¼¯²»Í¬ËùÔì³ÉµÄ,ÐÞ¸ÄÊý¾Ý¿â¿Í»§¶ËµÄ×Ö·û¼¯ºÍ·þÎñÆ÷µÄ×Ö·û¼¯Ò»ÖÂ
²Ù×÷·½·¨:
oracle 9i :Ð޸ı¾µØ×¢²á±íÖÐORACLE¿Í»§¶Ëµ ......