[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

In reference to the error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified. That error means that the Data Source Name (DSN) you are specifying in your connection configuration is not being found in the windows registry. It is important that your ODBC driver’s executable and linking format (ELF) is … Read more

Return rows matching elements of input array in plpgsql function

This works: CREATE OR REPLACE FUNCTION avg_purchases(last_names text[] = ‘{}’) RETURNS TABLE(last_name text, avg_purchase_size float8) LANGUAGE sql AS $func$ SELECT last_name, avg(purchase_size)::float8 FROM purchases WHERE last_name = ANY($1) GROUP BY last_name $func$; Call: SELECT * FROM avg_purchases(‘{foo,Bar,baz,”}weird_name”$$”}’); Or (example with dollar-quoting): SELECT * FROM avg_purchases($x${foo,Bar,baz,”}weird_name’$$”}$x$); How to quote string literals: Insert text with single quotes … Read more

How do I query using fields inside the new PostgreSQL JSON datatype?

Postgres 9.2 I quote Andrew Dunstan on the pgsql-hackers list: At some stage there will possibly be some json-processing (as opposed to json-producing) functions, but not in 9.2. Doesn’t prevent him from providing an example implementation in PLV8 that should solve your problem. (Link is dead now, see modern PLV8 instead.) Postgres 9.3 Offers an … Read more