http://weblogs.sqlteam.com/jeffs/archive/2004/03/22/1085.aspx
CREATE PROCEDURE ReturnPage(@Select varchar(1000), @OrderBy varchar(1000),
@StartRow int, @EndRow int)
AS
BEGIN
declare @ColList varchar(2000);
declare @Where varchar(2000);
declare @i int;
declare @i2 int;
declare @tmp varchar(1000);
declare @dec varchar(1000);
declare @f varchar(100);
declare @d varchar(100);
declare @Symbol char(2);
declare @SQL varchar(5000);
declare @Sort varchar(1000);
set @Sort = @OrderBy + ', '
set @dec = ''
set @Where = ''
set @SQL = ''
set @i = charindex(',' , @Sort)
while @i != 0
begin
set @tmp = left(@Sort,@i-1)
set @i2 = charindex(' ', @tmp)
set @f = ltrim(rtrim(left(@tmp,@i2-1)))
set @d = ltrim(rtrim(substring(@tmp,@i2+1,100)))
set @Sort = rtrim(ltrim(substring(@Sort,@i+1,100)))
set @i = charindex(',', @Sort)
set @symbol = case when @d = 'ASC' then '>' else '<' end +
case when @i=0 then '=' else '' end
set @dec = @dec + 'declare @' + @f + ' sql_variant; '
set @ColList = isnull(replace(replace(@colList,'>','='),'<','=') + ' and ','') +
@f + @Symbol + ' @' + @f
set @Where = @Where + ' OR (' + @ColList + ') '
set @SQL = @SQL + ', @' + @f + '= ' + @f
end
set @SQL = @dec + ' ' +
'SET ROWCOUNT ' + convert(varchar(10), @StartRow) + '; ' +
'SELECT ' + substring(@SQL,3,7000) + ' from (' + @Select + ') a ORDER BY ' +
@OrderBy + '; ' + 'SET ROWCOUNT ' +
convert(varchar(10), 1 + @EndRow - @StartRow) + '; ' +
'select * from (' + @Select + ') a WHERE ' +
substring(@Where,4,7000) + ' ORDER BY ' + @OrderBy + '; SET ROWCOUNT 0;'
exec(@SQL)
END
Angry Marshmellows
Tuesday, December 09, 2008
Monday, December 08, 2008
Thursday, October 30, 2008
Tuesday, September 30, 2008
Friday, September 26, 2008
quacl.style.left=width/2.25;
quacl.style.top=height/2.5;
quacl.position="fixed";
Element.show('quacl');
function getScreenMiddleHeight(){
var screenW = 640, screenH = 480;
if (parseInt(navigator.appVersion)>3) {
screenH = screen.height;
}
else if (navigator.appName == "Netscape"
&& parseInt(navigator.appVersion)==3
&& navigator.javaEnabled()
)
{
var jToolkit = java.awt.Toolkit.getDefaultToolkit();
var jScreenSize = jToolkit.getScreenSize();
screenH = jScreenSize.height;
}
return screenH/2;
}
function getScreenMiddleWidth(){
var screenW = 640;
if (parseInt(navigator.appVersion)>3) {
screenW = screen.width;
}
else if (navigator.appName == "Netscape"
&& parseInt(navigator.appVersion)==3
&& navigator.javaEnabled()
)
{
var jToolkit = java.awt.Toolkit.getDefaultToolkit();
var jScreenSize = jToolkit.getScreenSize();
screenW = jScreenSize.width;
}
return screenW/2;
}
quacl.style.top=height/2.5;
quacl.position="fixed";
Element.show('quacl');
function getScreenMiddleHeight(){
var screenW = 640, screenH = 480;
if (parseInt(navigator.appVersion)>3) {
screenH = screen.height;
}
else if (navigator.appName == "Netscape"
&& parseInt(navigator.appVersion)==3
&& navigator.javaEnabled()
)
{
var jToolkit = java.awt.Toolkit.getDefaultToolkit();
var jScreenSize = jToolkit.getScreenSize();
screenH = jScreenSize.height;
}
return screenH/2;
}
function getScreenMiddleWidth(){
var screenW = 640;
if (parseInt(navigator.appVersion)>3) {
screenW = screen.width;
}
else if (navigator.appName == "Netscape"
&& parseInt(navigator.appVersion)==3
&& navigator.javaEnabled()
)
{
var jToolkit = java.awt.Toolkit.getDefaultToolkit();
var jScreenSize = jToolkit.getScreenSize();
screenW = jScreenSize.width;
}
return screenW/2;
}
Thursday, September 25, 2008
Tuesday, September 23, 2008
Tomcat datasource connection pooling
http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html#Non%20DBCP%20Solutions
http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html#Non%20DBCP%20Solutions
private static void initializeDataSource(String whichOne) throws NamingException, SQLException{
logger.debug("entering initializeDataSource("+whichOne+")");
try{
InitialContext ic = new InitialContext();
if(whichOne.equals(AppHelper.SC_DEFAULT_DS_CON)){
//if (dataSource == null)
dataSource = (DataSource) ic.lookup(whichOne);
}
}catch (NamingException ne){
throw new NamingException("NamingException while looking" +
" up DataSource Connection " + whichOne
+ ": \n" + ne.getMessage());
}
logger.debug("leaving initializeDataSource()");
}
Subscribe to:
Posts (Atom)