Re: [SQL] quotes etc
On 02/22/2011 04:18 PM, Adrian Klaver wrote:
On Tuesday, February 22, 2011 12:26:41 pm John Fabiani wrote:
> Hi,
> I would have thought that there would be a simple built-in function that
> would escape the quotes as ('D' Andes') to ('D\' Andes'). But I did not
> see anything?
>
> I am I wrong?
>
> Johnf
Dollar quoting ? :
http://www.postgresql.org/docs/9.0/interactive/sql-syntax-lexical.html
4.1.2.4. Dollar-Quoted String Constants
test(5432)aklaver=>SELECT $$D' Andes$$;
?column?
--
D' Andes
I like this $str$$str$ very much!
Vote for this!
--
Lu Ying
--
Sent via pgsql-sql mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
[SQL] Function To Strip HTML
I have the following function that I used in MSSQL. I would like to
create the same function in PostgreSql. I think I am a bit confused on
how to create and set variables in PostgreSql. Can someone give me a
place to start to create something like this?
Thanks
Pam
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[udf_StripHTML]
(@HTMLText VARCHAR(MAX))
RETURNS VARCHAR(MAX)
AS
BEGIN
DECLARE @Start INT
DECLARE @End INT
DECLARE @Length INT
SET @Start = CHARINDEX('<',@HTMLText)
SET @End = CHARINDEX('>',@HTMLText,CHARINDEX('<',@HTMLText))
SET @Length = (@End - @Start) + 1
WHILE @Start > 0
AND @End > 0
AND @Length > 0
BEGIN
SET @HTMLText = STUFF(@HTMLText,@Start,@Length,'')
SET @Start = CHARINDEX('<',@HTMLText)
SET @End = CHARINDEX('>',@HTMLText,CHARINDEX('<',@HTMLText))
SET @Length = (@End - @Start) + 1
END
RETURN LTRIM(RTRIM(@HTMLText))
END
GO
[SQL] Compare two Data bases Structure
How Can I do to compare two structures of data bases ? DBA != DBB I need wich functions and wich tables are not equals thnks
Re: [SQL] Compare two Data bases Structure
Check out DB Solo ... http://www.dbsolo.com/ Does both DDL compare as well as data compare. From: [email protected] [[email protected]] On Behalf Of manuel antonio ochoa [[email protected]] Sent: Wednesday, February 23, 2011 6:03 PM To: [email protected] Subject: [SQL] Compare two Data bases Structure How Can I do to compare two structures of data bases ? DBA != DBB I need wich functions and wich tables are not equals thnks -- Sent via pgsql-sql mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql
Re: [SQL] Function To Strip HTML
I found a way to do this using regular expressions. Found this on another website CREATE OR REPLACE FUNCTION strip_tags(TEXT) RETURNS TEXT AS $$ 2SELECT regexp_replace(regexp_replace($1, E'(?x)<[^>]*?(\s alt \s* = \s* ([\'"]) ([^>]*?) \2) [^>]*? >', E'\3'), E'(?x)(< [^>]*? >)', '', 'g') 3$$ LANGUAGE SQL; From: [email protected] [mailto:[email protected]] On Behalf Of Ozer, Pam Sent: Wednesday, February 23, 2011 3:41 PM To: [email protected] Subject: [SQL] Function To Strip HTML I have the following function that I used in MSSQL. I would like to create the same function in PostgreSql. I think I am a bit confused on how to create and set variables in PostgreSql. Can someone give me a place to start to create something like this? Thanks Pam SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE FUNCTION [dbo].[udf_StripHTML] (@HTMLText VARCHAR(MAX)) RETURNS VARCHAR(MAX) AS BEGIN DECLARE @Start INT DECLARE @End INT DECLARE @Length INT SET @Start = CHARINDEX('<',@HTMLText) SET @End = CHARINDEX('>',@HTMLText,CHARINDEX('<',@HTMLText)) SET @Length = (@End - @Start) + 1 WHILE @Start > 0 AND @End > 0 AND @Length > 0 BEGIN SET @HTMLText = STUFF(@HTMLText,@Start,@Length,'') SET @Start = CHARINDEX('<',@HTMLText) SET @End = CHARINDEX('>',@HTMLText,CHARINDEX('<',@HTMLText)) SET @Length = (@End - @Start) + 1 END RETURN LTRIM(RTRIM(@HTMLText)) END GO
