Pages

Search This Blog

Thursday, September 27, 2007

[T-SQL] Proper case function in SQL Server

CREATE FUNCTION PROPERCASE
(
--The string to be converted to proper case
@input varchar(8000)
)
--This function returns the proper case string of varchar type
RETURNS varchar(8000)
AS
BEGIN
IF @input IS NULL
BEGIN
--Just return NULL if input string is NULL
RETURN NULL
END
--Character variable declarations
DECLARE @output varchar(8000)
--Integer variable declarations
DECLARE @ctr int, @len int, @found_at int
--Constant declarations
DECLARE @LOWER_CASE_a int, @LOWER_CASE_z int, @Delimiter char(3), @UPPER_CASE_A int, @UPPER_CASE_Z int
--Variable/Constant initializations
SET @ctr = 1
SET @len = LEN(@input)
SET @output = ''
SET @LOWER_CASE_a = 97
SET @LOWER_CASE_z = 122
SET @Delimiter = ' '
SET @UPPER_CASE_A = 65
SET @UPPER_CASE_Z = 90
WHILE @ctr <= @len
BEGIN
--This loop will take care of reccuring white spaces
WHILE CHARINDEX(SUBSTRING(@input,@ctr,1), @Delimiter) > 0
BEGIN
SET @output = @output + SUBSTRING(@input,@ctr,1)
SET @ctr = @ctr + 1
END
IF ASCII(SUBSTRING(@input,@ctr,1)) BETWEEN @LOWER_CASE_a AND @LOWER_CASE_z
BEGIN
--Converting the first character to upper case
SET @output = @output + UPPER(SUBSTRING(@input,@ctr,1))
END
ELSE
BEGIN
SET @output = @output + SUBSTRING(@input,@ctr,1)
END
SET @ctr = @ctr + 1
WHILE CHARINDEX(SUBSTRING(@input,@ctr,1), @Delimiter) = 0 AND (@ctr <= @len)
BEGIN
IF ASCII(SUBSTRING(@input,@ctr,1)) BETWEEN @UPPER_CASE_A AND @UPPER_CASE_Z
BEGIN
SET @output = @output + LOWER(SUBSTRING(@input,@ctr,1))
END
ELSE
BEGIN
SET @output = @output + SUBSTRING(@input,@ctr,1)
END
SET @ctr = @ctr + 1
END
END
RETURN @output
END

Wednesday, September 26, 2007

[Cognos] Script for renaming prompt buttons

var pstr1=document.formWarpRequest.elements;
for(var i=0;i {
if(pstr1[i].value=='Finish')
{
pstr1[i].value='Run';
}

}

Thursday, September 20, 2007

[Cognos] Scripts

Script for Work Wrapping
document.formWarpRequest._oLstChoicescompparam[0].text = 'All';

Script for first day of the month

var pstr1=document.formWarpRequest.elements;
var lastdate=new Date();

lastdate.setDate(lastdate.getDate()-(lastdate.getDate()-1));
var gsMonthNames = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');

for(var i=0;i {
if(pstr1[i].name=='txtDateFromDate')
{
var vDay = lastdate.getDate();
var vMonth = lastdate.getMonth()+1;
var vYearLong = (lastdate.getFullYear());
var vDateString = gsMonthNames[vMonth-1]+" "+vDay+", "+vYearLong;
pstr1[i].value=vDateString;
}

}

Script for last day of the month

var pstr1=document.formWarpRequest.elements;
var lastdate=new Date();

lastdate.setDate(lastdate.getDate());
var gsMonthNames = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var gsDay=new Array(31,28,31,30,31,30,31,31,30,31,30,31)
for(var i=0;i {
if(pstr1[i].name=='txtDateToDate')
{
var vDay = lastdate.getDate();
var vMonth = lastdate.getMonth()+1;
var vYearLong = (lastdate.getFullYear());
var vDateString = gsMonthNames[vMonth-1]+" "+gsDay[vMonth-1]+", "+vYearLong;
pstr1[i].value=vDateString;
}

}

Monday, September 10, 2007

[Cognos] Important Material

Path with parameter

http://KHIPC117/cognos8/cgi-bin/cognos.cgi?b_action=xts.run&m=portal/report-viewer.xts&method=execute&m_obj=content/package[@name='VICTORS']/folder[@name='Orders']/report[@name='Order Count by Date Range']&amp;amp;amp;amp;p_ENT_NUM=32&&run.prompt=true&ui.action=run&&nh=0&&tb=0

Path without parameter

http://KHIPC135/cognos8/cgi-bin/cognos.cgi?b_action=xts.run&m=portal/report-viewer.xts&method=execute&m_obj=/content/package[@name='VICTORS']/folder[@name='Clients']/folder[@name='Client Pricing']/report[@name='Client Pricing']&amp;amp;amp;run.prompt=true&ui.action=run&&nh=0&&tb=0