Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÈçºÎ´Ó PL/SQL ´æ´¢º¯Êý·µ»ØÊý×é

ÈÕÆÚ£º2003 Äê 2 Ô 19 ÈÕ
Íê³É´Ë·½·¨Ö¸ÄϺó£¬ÄúÓ¦¸ÃÄܹ»£º
ÔÚ Oracle Êý¾Ý¿âÖд´½¨ VARRAY
ʹÓà oracle.sql.ARRAY Àà
´Ó Java ·ÃÎÊ VARRAY
¼ò½é
±¾ÎĵµÑÝʾÈçºÎ´Ó PL/SQL º¯Êý·µ»ØÊý×é²¢´Ó java Ó¦ÓóÌÐò·ÃÎÊËü¡£Êý×éÊÇÒ»×éÓÐÐòµÄÊý¾ÝÔªËØ¡£ VARRAY ÊÇ´óС¿É±äµÄÊý×é¡£Ëü¾ßÓÐÊý¾ÝÔªËصÄÅÅÁм¯£¬²¢ÇÒËùÓÐÔªËØÊôÓÚͬһÊý¾ÝÀàÐÍ¡£Ã¿¸öÔªËض¼¾ßÓÐË÷Òý£¬ËüÊÇÓëÔªËØÔÚ VARRAY ÖеÄλÖÃÏà¶ÔÓ¦µÄÒ»¸öÊý×Ö¡£ VARRAY ÖÐÔªËصÄÊýÁ¿ÊÇ VARRAY µÄ“´óС”¡£ÔÚÉùÃ÷ VARRAY ÀàÐÍʱ£¬±ØÐëÖ¸¶¨Æä×î´óÖµ¡£
ÔÚ´Ë·½·¨Ö¸ÄÏÖУ¬PL/SQL ´æ´¢º¯Êý´Ó SCOTT ģʽµÄ EMP ±íÖÐÈ¡³öËùÓйÍÔ±µÄÐÕÃû£¬ÒÔÕâЩÐÕÃû´´½¨Ò»¸öÊý×é²¢½«Æä·µ»Ø¡£´Ó Java Ó¦ÓóÌÐòµ÷ÓÃ´Ë PL/SQL ´æ´¢º¯Êý£¬ÏòÓû§ÏÔʾ¹ÍÔ±µÄÐÕÃû¡£
Èí¼þÐèÇó
Oracle9i Database version 9.0.1 »ò¸üа汾¡£Äú¿É´Ó Oracle ¼¼ÊõÍøÏÂÔØ Oracle9i Êý¾Ý¿â¡£
JDK1.2.x »ò¸ü¸ß°æ±¾¡£¿É´Ó´Ë´¦ÏÂÔØ¡£
Oracle9i JDBC Çý¶¯³ÌÐò¡£JDBC Çý¶¯³ÌÐò¿É´Ó ORACLE_HOME/jdbc/lib ´¦»ñµÃ¡£Ò²¿É´Ó´Ë´¦ÏÂÔØ¡£
ÔÚÊý¾Ý¿âÖд´½¨Ò»¸ö SQLVARRAY ÀàÐÍ£¬ÔÚ±¾ÀýÖУ¬ËüÊÇ VARCHAR2 ÀàÐÍ¡£ ×÷Ϊ scott/tiger Óû§Á¬½Óµ½Êý¾Ý¿â£¬²¢ÔÚ SQL Ìáʾ·û´¦Ö´ÐÐÒÔÏÂÃüÁî¡£
SQL>CREATE OR REPLACE TYPE EMPARRAY is VARRAY(20) OF VARCHAR2(30)
SQL>/
È»ºó´´½¨ÏÂÃæµÄº¯Êý£¬Ëü·µ»ØÒ»¸ö VARRAY¡£
CREATE OR REPLACE FUNCTION getEmpArray RETURN EMPARRAY
AS
l_data EmpArray := EmpArray();
CURSOR c_emp IS SELECT ename from EMP;
BEGIN
FOR emp_rec IN c_emp LOOP
l_data.extend;
l_data(l_data.count) := emp_rec.ename;
END LOOP;
RETURN l_data;
END;
ÔÚÊý¾Ý¿âÖд´½¨º¯Êýºó£¬¿ÉÒÔ´Ó java Ó¦ÓóÌÐòµ÷ÓÃËü²¢ÔÚÓ¦ÓóÌÐòÖлñµÃÊý×éÊý¾Ý¡£ÏÂÃæ¸ø³ö´úÂë¶Î£¬´Ó Java Ó¦ÓóÌÐòÖ´ÐÐ PL/SQL ´æ´¢º¯Êý¡£µ¥»÷´Ë´¦²é¿´ÍêÕûµÄÓ¦ÓóÌÐòÔ´´úÂë¡£
public static void main( ) {
.........
.........
OracleCallableStatement stmt =(OracleCallableStatement)conn.prepareCall
( "begin ?:= getEMpArray; end;" );
// The name we use below, EMPARRAY, has to match the name of the
// type defined in the PL/SQL Stored Function
stmt.registerOutParameter( 1, OracleTypes.ARRAY,"EMPARRAY" );
stmt.executeUpdate();
// Get the ARRAY


Ïà¹ØÎĵµ£º

fastreport´òÓ¡´úÂë¼°SQLºÏ²¢×ֶεÄÓï¾ä

 procedure Tform1.Button5Click(Sender: TObject);
var
  p:pointer;
  FrfStr:string;
begin
  inherited;
  Screen.Cursor:=MYCURSORWAITHAND;
  with cdsPrint do
  begin
    Active:=false;
    //Õâ¸öSQLÓÃÓÚ½«remarkÖеļǼºÏ²¢µ½Ò»Æ ......

Ô·ݴ¦Àí¼°SQLʱ¼äÌõ¼þinstrº¯Êý

    YearCode:=yearof(Date);
      MonthCode:=monthof(Date);
      if  MonthCode>9 then
        FTime1:=inttostr(YearCode)+inttostr(MonthCode)
      else
 &nb ......

ÓÃJavaдµÄMy SQL²Ù×÷·â×°Àà

Kagula
2009-11-17
 
¹Ø¼ü´Ê
    Java My SQL
 
¸ÅÒª£º
    ¶ÔMy SQL²Ù×÷·â×°µÄJavaÔ´ÂëʾÀý¡£
 
ÒªÇó»·¾³£º
    J2SE1.5 + Eclipse3.4.2
 
ÕýÎÄ£º
Ïȵ½ÍøÉÏÏÂÔØmysql-connector-java-5.0.8-bin.jar£¬²¢°ÑËü·Åµ½ÄãµÄJava ProjectµÄUser Lib ......

SQL ½ØÈ¡×Ö·û´®£¬ÖÐÎÄËãÁ½¸ö×Ö·ûµÄ·½·¨

--SQL ½ØÈ¡×Ö·û´®·½·¨£¬ÖÐÎÄËãÁ½¸ö×Ö·ûµÄ·½·¨¡£
--·½·¨¸úË®¸çѧϰµÄ£¬Ö§³ÖÒ»ÏÂË®¸çµÄ²©¿Í
--http://hi.csdn.net/link.php?url=http://blog.csdn.net%2Fwufeng4552
--Ë®¸ç×î½üлÁ˺ö಩¿Í£¬ÓÐʱ¼äÒ»¶¨È¥ºÃºÃѧϰ
--LEFT() ºÍSUBSTRING()¶¼Êǽ«ºº×ÖËãÒ»¸ö×Ö·ûÀ´ËãµÄ
--Èç¹û²»¼Æ½ÏµÄ»°£¬ÍƼöʹÓÃÕâÁ½¸öϵͳº¯Êý
IF OBJE ......

SQLÁª±í¸üУ¬Áª±í²éѯ

ûÓÐÒýÓùØϵµÄ±í
 £±.¡¡Áª±í¸üÐÂ
update  a set a.education = '±¾¿Æ' from NT_UserInfo a ,NT_User b where  a.UserID=b.UserID and b.email = 'carlfan2008@163.com'
£².¡¡Áª±í²éѯ
select a.*,b.* from nt_user as a, nt_userinfo as b where a.userid = b.userid and Email = 'carlfan2008@163.com ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ