Re: Help with dynamic SQL
От | Martijn van Oosterhout |
---|---|
Тема | Re: Help with dynamic SQL |
Дата | |
Msg-id | 20020903100747.A17354@svana.org обсуждение исходный текст |
Ответ на | Help with dynamic SQL (SamPost <everywhereboy@yahoo.com>) |
Список | 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@postgresql.org so that your > message can get through to the mailing list cleanly -- Martijn van Oosterhout <kleptog@svana.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.
В списке pgsql-general по дате отправления: