PostgreSQL execute statement conditionally by server version -
I am currently writing some installer scripts that are system configuration (web application database server like MySQL, MSSQL and PostgreSQL).
One of those types is PostgreSQL. I am not fluent with this and I would like to know whether it is possible to make a statement in defining / populating a SQL file, for a specific postgre SQL Server version Creates conditional SQL queries
How to make a SQL statement conditional in PGSQL, so that it can be executed only in 9 versions? The command is:
ALTER DATABASE dbname SET bytea_output = 'escape'; The version check is to compare the version with 9 .
Postgrace has a function, even though no major_vesion () is not . Assume that the output string always contains the version number as the number (numbers). Number (numbers) .umber (s) You can write your own cover: create or change function major_version () $ $ (\ d +) \. \ D + \. \ D + $$) Small $$$ SELECT substrings (version ()) returns the letter as small: short; $ Body $ LANGUAGE SQL; Example:
= & gt; Choose major_version (); Major_version --------------- 9 (1 line) However the real issue here is that AFAIK will notify you of your orders in "Pure" SQL The best thing to do is to write some of the stored tasks like this:
Create or Replace Fixed Conditional Invoke () returns empty as $$$ If major_version () = 9 and later postgres SET bytea_output = 'escape'; end if; Return; End; $ Body $ LANGUAGE plpgsql; I think that you should use some scripting language and generate appropriate SQL with it.
Comments
Post a Comment