Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Browse by Tags · View All
SQL Server 119
#SQLServer 88
Oracle 70
#SQL SERVER 35
BRH 31
SQL Server 2012 29
denali 23
#TSQL 19
TSQL 19
C# 15

Archive · View All
October 2011 31
November 2011 30
September 2011 30
August 2011 18
December 2011 15
July 2011 13
June 2011 8
May 2012 4
April 2012 3
January 2010 3

Day 3: Overlay function in PostgreSQL

Dec 3 2011 6:21AM by Niladri Biswas   

Purpose:To replace substring from a specified position to a specified position.

Syntax:Overlay(string placing string from int [for int])

Example

Select Overlay('www.beyondnational.com' Placing 'relational' From 11 For 8) "Overlay Example"
/* Result */

Overlay Example
---------------
www.beyondrelational.com

As can be figure out that national has been replaced by relational. The replacement started from position 11 and should continue till 8.So the characters between 11 to 19 (11+8) are national and those should be replaced by relational.

Though we donot have in our SQL Server such a function, but we can always create our own. Here is my attempt

CREATE FUNCTION [dbo].[Overlay]
(
   -- Add the parameters for the function here
   @InputString varchar(4000)
   ,@ReplaceString varchar(100)
   ,@From int
   ,@For int
)
RETURNS VARCHAR(4000)

AS
BEGIN
	-- Declare the return variable here
	Declare @OutputString   VARCHAR(4000)

	Select  @OutputString = Stuff(@InputString,@From,@For,@ReplaceString) 

	-- Return the result of the function
	RETURN @OutputString

END

Usage

Declare @Initialstr varchar(100) = 'www.beyondnational.com'
Declare @Replacestr varchar(100) = 'relational'
Declare @from int = 11
Declare @for int = 8

Select dbo.Overlay(@Initialstr,@Replacestr,@from,@for)  "Overlay Example"

/*Result */
Overlay Example
---------------
www.beyondrelational.com

Hope this helps

Tags: PostgreSQL, #SQL SERVER,


Niladri Biswas
7 · 21% · 6710
1
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

"Day 3: Overlay function in PostgreSQL" rated 5 out of 5 by 1 readers
Day 3: Overlay function in PostgreSQL , 5.0 out of 5 based on 1 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]