ibatisÖÐÖ±Ö´ÐÐsql£¬·µ»Ø´æ´¢MapµÄListÀàÐÍ
ibatis×÷Ϊһ¸öÇáÁ¿¼¶µÄorm¹¤¾ßÏÖÔڷdz£Á÷ÐУ¬ÎÒÔÚʹÓÃÖз¢ÏÖ£¬ÓÐʱ½ö½öÏ£Íû·µ»ØÒ»¸öÀàÐÍΪmapµÄlist¾Í¿ÉÒÔÁË£¬
±ÈÈç¼òµ¥µÄ²éѯͳ¼ÆÖ®ÀàµÄ£¬Ã»ÓбØÒª¶¨ÒåÌ«¶àµÄpojo£¬Òò´ËÏëÄܲ»ÄÜÔÚibatisÖÐÖ±½Ó´«ÈësqlÓï¾äÀ´Ö´ÐУ¬È»ºó·µ»ØmapÄØ£¿
´ÓÍøÉÏËÑÁËһϣ¬»¹ÕæÓУ¬ÊµÑé³É¹¦ºó×ܽáһϣ¬´ó¼Ò¹²Í¬½ø²½¡£ ÆäʵºÜ¼òµ¥£¬¾ÍÊÇÔÚÅäÖÃÎļþÖÐÌí¼ÓÒÔϵÄÅäÖã¬
<!-- ²âÊÔSql -->
<select id="sqlQuery" parameterClass="java.lang.String" resultClass="java.util.HashMap">
<![CDATA[
$sql$
]]>
</select>
ʹÓ÷½·¨¾Í¸ü¼òµ¥ÁË£¬Æ´ºÃsqlÓï¾äºó£¬µ÷ÓÃ
sqlMapper.queryForList("sqlQuery", sql)¾ÍµÃµ½Á˲éѯ½á¹û£¬
µ±È»Õâ¸ö½á¹ûΪList£¬²¢ÇÒlistÖеÄÔªËØÎªMapÀàÐÍ£¬Ñ»·List£¬¾ÍµÃµ½²éѯÃ÷ϸ¡£
ÒÔÉÏ·½·¨¶ÔÓÚ·ÖÀà»ã×ÜÀàµÄ²éѯͳ¼Æ¹¦ÄÜÓÈÆäʵÓá£Èç¹ûÖ»ÊÇcount()µÄ»°£¬¾ÍÈ¡ListµÄµÚÒ»¸öÔªËØ¾ÍÐÐÁË¡£ ÎÒÃÇ¿ÉÒÔ°ÑÕâ¸ö·½·¨³é³öÀ´Ð´µ½Ò»¸öutilÀàÖУ¬·½·¨ÈçÏÂ
/**
* ²éѯ²¢·µ»ØList
*/
public static List queryForList(String sql){
List rtn = null;
try{
rtn = sqlMapper.queryForList("sqlQuery", sql);
}catch(SQLException sqle){
sqle.printStackTrace();
}
return rtn;
}
ÕâÑùÓÃÆðÀ´¾Í·½±ã¶àÁË¡£Èç¹û´ó¼Ò»¹ÓÐÆäËüµÄºÃ·½·¨£¬Ò»ÆðÌÖÂÛһϡ£ ÎÒµÄÍÆ¹ã£ºÀÏÀÖÍø
Ïà¹ØÎĵµ£º
et ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER function [dbo].[Get_StrArrayLength]
(
@str varchar(1024), --Òª·Ö¸îµÄ×Ö·û´®
@split varchar(10) --·Ö¸ô·ûºÅ
)
returns int
as
begin
declare @location int
declare @start int
declare @length int
&nbs ......
1: /*
2: ͨ¹ýSQL Óï¾ä±¸·ÝÊý¾Ý¿â
3: */
4: BACKUP DATABASE mydb
5: TO DISK ='C:\DBBACK\mydb.BAK'
6: --ÕâÀïÖ¸¶¨ÐèÒª±¸·ÝÊý¾Ý¿âµÄ·¾¶ºÍÎļþÃû,×¢Òâ:·¾¶µÄÎļþ¼ÐÊDZØÐëÒѾ´´½¨µÄ.ÎļþÃû¿ÉÒÔʹÓÃÈÕÆÚÀ´±êʾ
7:
8: /*
9: ͨ¹ýSQLÓï¾ä»¹ÔÊý¾Ý¿â
10: */
11: USE ma ......
Select CONVERT(varchar(100), GETDATE(), 0): 05 16 2006 10:57AM
Select CONVERT(varchar(100), GETDATE(), 1): 05/16/06
Select CONVERT(varchar(100), GETDATE(), 2): 06.05.16
Select CONVERT(varchar(100), GETDATE(), 3): 16/05/06
Select CONVERT(varchar(100), GETDATE(), 4): 16.05.06
Select CONVERT(varch ......
´æ´¢½ø³Ì¾ÍÊÇ×÷Ϊ¿ÉÖ´ÐжÔÏó´æ·ÅÔÚÊý¾Ý¿âÖеÄÒ»¸ö»ò¶à¸öSQLÃüÁî¡£
¶¨Òå×ÜÊǺܳéÏó¡£´æ´¢½ø³ÌÆäʵ¾ÍÊÇÄÜÍê³ÉÒ»¶¨²Ù×÷µÄÒ»×éSQLÓï¾ä£¬Ö»²»¹ýÕâ×éÓï¾äÊÇ·ÅÔÚÊý¾Ý¿âÖеÄ(ÕâÀïÎÒÃÇ̸ֻSQL SERVER)¡£Èç¹ûÎÒÃÇͨ¹ý´´½¨´æ´¢½ø³ÌÒÔ¼°ÔÚASPÖе÷Óô洢½ø³Ì£¬¾Í¿ÉÒÔ±ÜÃ⽫SQLÓï¾äͬASP´úÂë»ìÔÓÔÚÒ»Æð¡£ÕâÑù×öµÄºÃ´¦ÖÁÉÙÓÐÈý¸ö£º
µÚÒ»¡ ......