From: | "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com> |
---|---|
To: | finecur <finecur(at)yahoo(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: quote in string |
Date: | 2008-05-22 22:45:47 |
Message-ID: | dcc563d10805221545h263bdb9cw3b6708e50cb8ece0@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, May 21, 2008 at 11:36 AM, finecur <finecur(at)yahoo(dot)com> wrote:
> Hi, I have a function and it's interface is :
>
> my_flexible_sql_function(cmd)
>
> where cmd is another sql command. I call this function like this:
>
> select * from my_flexible_sql_function('select * from employee where
> id < 100')
>
> Inside this functioin, I will first retrieve all data by calling
> 'select * from employee where id < 100' and do some calculation about
> the result and then return.
>
> No I run into a problem, I need to call it like this:
>
> select * from my_flexible_sql_function('select * from employee where
> dep ='Eng' ')
>
> But looks like there is a problem to include a string inside the cmd.
> The way I write 'Eng' is not right. Is there a way to include quote in
> string?
Assuming you're running a fairly recent pgsql version (8.0 and up) you
can use $$ quoting:
select * from my_flexible_sql_function($$select * from employee where
dep ='Eng' $$)
From | Date | Subject | |
---|---|---|---|
Next Message | Adam Rich | 2008-05-22 22:57:11 | Re: Results of stored procedures in WHERE clause |
Previous Message | Raymond O'Donnell | 2008-05-22 22:07:36 | Re: Extracting \ Generate DDL for existing object permissions |