0

Hi My question is already asked here

But i haven't found any answer there in that link. I don't want any tool to acheive my requirement. I am looking for a simple procedure or query. In that link someone answered about search_columns() procedure. Right now i am using postgresql 9.0.4 version. Can some Postgresql Guru over there can answer this problem

Also Is there any alternative for format() function for 9.1 below versions. I see that the format() function is supported in postresql 9.1 versions and above. Can anybody tell me how to use format function or any alternative to format function for 9.0 or below versions.

Thanks in advance

1

1 Answer 1

1

On old versions you must instead use quote_ident and quote_literal with concatenation operations.

e.g.

format('SELECT %I FROM %I WHERE %I = %L', col1, tbl, col2, val)

becomes

'SELECT '||quote_ident(col1)||' FROM '||quote_ident(tbl)||' WHERE '||quote_ident(col2)||' = '||quote_nullable(val);
Sign up to request clarification or add additional context in comments.

1 Comment

Almost perfect, but %L should be replaced by quote_nullable() postgresql.org/docs/current/static/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.