My PL/SQL practice 8/2/10
SQLPlus :http://www.orafaq.com/wiki/SQL*Plus_FAQ
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/sqloperations.htm
1. Transfer values from a sql scripts:
CNT=`sqlplus -s username/password1@dbname @getUVQuery_NULLCNT`;
Note : Remeber to use option "-s" (-s or -silent -- start sqlplus in silent mode. Not recommended for beginners!)
if not use "-s" , will return something as below :
SQL*Plus: Release 10.2.0.3.0 - Production on Tue Feb 9 11:03:08 2010
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
0
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
2.getUVQuery_NULLCNT.sql
set term off
column cnt noprint new_value total
SELECT count(inquiry_id) cnt
from inquire_all_current a
WHERE FORM_COMPLETE_STATUS = 'Y'
and ITEM_POPULATE_STATUS = 'N'
and expand_type='uvall'
and uv_query is null
ORDER BY INQUIRY_ID ASC;
set term on
prompt &total
exit
3. Define cursor and use cursor:
DECLARE
CURSOR cur IS
SELECT inquiry_id
from inquire_all_current a
WHERE FORM_COMPLETE
Ïà¹ØÎĵµ£º
1¡¢ÔÚÊý¾Ý¿â½¨±íµÄʱºò×Ö¶ÎÖ±½ÓÉèÖÃΪDATETIMEÀàÐÍ£»
2¡¢Ö´ÐвåÈëµÄʱºòʹÓÃÈçÏÂÓï¾ä£º
PreparedStatement pstmt = conn.prepareStatement("insert into guestbook(gst_user,gst_title,gst_content,gst_ip,gst_time) values(?,?,?,?,getdate())");
3¡¢Òª°ÑÈÕÆÚ´ÓÊý¾Ý¿âÖÐÈ¡³ö£¬Ö´ÐÐÈçÏÂÓï¾ä£º
......
1 ÓÃUNIONÌæ»»OR (ÊÊÓÃÓÚË÷ÒýÁÐ)
ͨ³£Çé¿öÏÂ, ÓÃUNIONÌæ»»WHERE×Ó¾äÖеÄOR½«»áÆ𵽽ϺõÄЧ¹û. ¶ÔË÷ÒýÁÐʹÓÃOR½«Ôì³ÉÈ«±íɨÃè. ×¢Òâ, ÒÔÉϹæÔòÖ»Õë¶Ô¶à¸öË÷ÒýÁÐÓÐЧ.
Èç¹ûÓÐcolumnûÓб»Ë÷Òý, ²éѯЧÂÊ¿ÉÄÜ»áÒòΪÄãûÓÐÑ¡ÔñOR¶ø½µµÍ. ÔÚÏÂÃæµÄÀý×ÓÖÐ, LOC_ID ºÍREGIONÉ϶¼½¨ÓÐË÷Òý.
¸ßЧ: SELECT LOC_ID , LOC_DESC , ......
select *from student
select student_id from student
select student_id ,student_name from student
select student_id student_name from student ½«student_name ×÷Ϊstudent_idµÄ±ðÃû´¦Àí
È磺 select student_id a from student
select a=student_id from student
´Óstudent±íÖзֱð¼ ......
Èç¹û°´ÕÕpowerdesignerµÄĬÈÏÑ¡Ïî,Éú³ÉµÄsql²»ÄÜÔÚmysqlÖÐÕýÈ·ÔËÐÐ.]
¾¹ý±¾ÈËÑо¿·¢ÏÖÒª×öÈçÏÂÐÞ¸Ä:
1.aftercreateÑ¡Ïî¸ÄΪ
.foreach_item(OutReferences)
.ifnot (%hasFKIndex%)
/*==============================================================*/
/* Index: ......
ÔÚsql Server ´Ó¿ª·¢»·¾³ÍùÉú²ú»·¾³²¿Êðʱ£¬ÒòΪ¿Í»§ÄÇÀïÓõÄÊÇÓ¢ÎÄ°æ±¾£¬ËùÒÔ´´½¨Êý¾Ý¿âÒÔºó£¬ÒªÉèÖÃÒ»ÏÂÊý¾Ý¿âÅÅÐò¹æÔò¡£
µ«ÊÇÔÚ´æ´¢¹ý³ÌÖУ¬ÓеijÌÐòԱʹÓÃÁËÁÙʱ±í£¬ÒòΪÁÙʱ±íÊÇ´æ´¢ÔÚϵͳÊý¾Ý¿âtempdbÖУ¬Èç¹ûϵͳÁÙʱÊý¾Ý¿âûÓнøÐÐÅÅÐò¹æÔòµÄÉèÖ㬳ÌÐò»¹Êdzö´í£¬½â¾ö°ì·¨¾ÍÊÇÉèÖÃÁÙʱÊý¾Ý¿âµÄÅÅÐò¹æÔò»òÕß´´½¨ÁÙÊ ......