From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
---|---|
To: | SamPost <everywhereboy(at)yahoo(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Help with dynamic SQL |
Date: | 2002-09-03 00:07:47 |
Message-ID: | 20020903100747.A17354@svana.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I don't know anything about SQL functions, but it seems to me for the
behaviour indicated that quote_ident is for quoting *identifiers* not
queries not identifiers in queries. Try leaving the quote_ident out
altogether.
Hope this helps,
On Mon, Sep 02, 2002 at 04:41:04PM -0700, SamPost wrote:
> I've been working on this function that processes the
> results of another SQL statement passed in to it. The
> function is called "tagged_results_query" and I'm
> having errors near here:
>
> sql ALIAS FOR $1;
> .
> .
> .
> FOR pid_relevancy IN EXECUTE ''SELECT page_id,
> sum(relevancy) as relevancy FROM (''
> || quote_ident(sql)
> || '') AS res ''
> || quote_ident(tags_code)
> || '' GROUP BY page_id ORDER BY relevancy DESC;''
> LOOP
>
> The problem is, I'm trying to execute the SQL
> statement in the variable sql (alias for $1), but when
> I use quote_ident(sql) it truncates my SQL statement
> to 32 characters, and when I double-quote it
> (''sql''), it uses 'sql' literally, and not the value
> of the variable sql. When I quadruple-quote it
> (''''sql'''') it says "parse error at or near $1".
>
> Basically what I need is a quote_ident that doesn't
> truncate at all, so I can pass in long SQL queries
> (100+ chars) to be executed and formatted by my
> function. Any ideas?
>
> Thanks,
>
> Sam Post
>
> =====
> Sam Post
> Synapse Interaction Facilitator
> *MyndSparqz Services*
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Finance - Get real-time stock quotes
> http://finance.yahoo.com
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> There are 10 kinds of people in the world, those that can do binary
> arithmetic and those that can't.
From | Date | Subject | |
---|---|---|---|
Next Message | Martijn van Oosterhout | 2002-09-03 00:12:45 | Re: SET? What? |
Previous Message | SamPost | 2002-09-02 23:41:04 | Help with dynamic SQL |