Sample Header Ad - 728x90

Database Administrators

Q&A for database professionals who wish to improve their database skills

Latest Questions

7 votes
1 answers
15136 views
Are there other ways to select a dynamic list of columns?
I need to let my users specify the list of columns they want to select. So far I know two ways of accomplishing that. **1. Using refcursors** CREATE OR REPLACE FUNCTION selecttestwithcolumnlist( ticker character varying, columnlist character varying) RETURNS refcursor AS $BODY$ DECLARE ref1 refcurso...
I need to let my users specify the list of columns they want to select. So far I know two ways of accomplishing that. **1. Using refcursors** CREATE OR REPLACE FUNCTION selecttestwithcolumnlist( ticker character varying, columnlist character varying) RETURNS refcursor AS $BODY$ DECLARE ref1 refcursor; BEGIN OPEN ref1 FOR EXECUTE 'select ' || ColumnList || ' from Prices WHERE Ticker=$1;' USING Ticker; RETURN ref1; END; $BODY$ LANGUAGE plpgsql VOLATILE This function is very easy to invoke from my Ado.Net client. All I need to do is pass the parameters. However, if I want to test this function from pgAdmin, the result set is open on screen only if I keep my transaction open. This is inconvenient. Of course, it is easy to expose the data as an HTML table or an Excel spreadsheet, but this is kind of a minor inconvenience. **2. Using setof records** CREATE OR REPLACE FUNCTION SelectPrices(colList VARCHAR) RETURNS SETOF record AS $func$ BEGIN RETURN QUERY EXECUTE 'SELECT ' || colList || ' FROM prices ORDER BY Ticker, ASOfDate'; END $func$ LANGUAGE plpgsql; Unfortunately, this complicates my client code. I cannot issue a simple SELECT like this: SELECT price,AsOfdate,ticker FROM SelectPrices('price,AsOfdate,ticker') ; I must explicitly provide the structure of my result set: SELECT price,AsOfdate,ticker FROM SelectPrices('price,AsOfdate,ticker') AS f(price NUMERIC,AsOfdate TIMESTAMP,ticker VARCHAR); This is doable, but inconvenient. Are there other ways to return dynamic column lists? **Edit** to protect against SQL injection, I typically split the comma-separated list and join it against a system view. Anything that is not an actual column name is not returned. I did not mention that originally, just to keep the question short.
A-K (7444 rep)
Nov 8, 2013, 09:42 PM • Last activity: Feb 10, 2022, 05:46 PM
15 votes
1 answers
11472 views
Error: File '' couldn't be removed (error 2: No such file or directory)
I get the following pgAdmin III error every time I restore a database, using pgAdmin III: Error: File '' couldn't be removed (error 2: No such file or directory) See the [pgadmin log][1]. My configuration: > PostgreSQL 9.4.4 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu > 4.8.2-19ubuntu1) 4.8...
I get the following pgAdmin III error every time I restore a database, using pgAdmin III:
Error: File '' couldn't be removed (error 2: No such file or directory)
See the pgadmin log . My configuration: > PostgreSQL 9.4.4 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu > 4.8.2-19ubuntu1) 4.8.2, 64-bit > > Linux 3.19.0-26-generic #28~14.04.1-Ubuntu SMP Wed Aug 12 14:09:17 UTC > 2015 x86_64 x86_64 x86_64 GNU/Linux
byaruhaf (251 rep)
Aug 27, 2015, 11:42 PM • Last activity: May 15, 2017, 10:16 PM
2 votes
0 answers
2573 views
Slony-I creation scripts not available; only joining possible
I try to start Slony replication. I have PostgreSQL 9.3.4, PgAdmin III 1.18.1 and Slony-I 2.2.0-1. I have set the path to Slony to `D:\GIS\PostgreSQL\9.3\share` where I have the Slony files. Whenever I try to create new Slony-I cluster, there is following message on the bottom of the window: `Slony-...
I try to start Slony replication. I have PostgreSQL 9.3.4, PgAdmin III 1.18.1 and Slony-I 2.2.0-1. I have set the path to Slony to D:\GIS\PostgreSQL\9.3\share where I have the Slony files. Whenever I try to create new Slony-I cluster, there is following message on the bottom of the window: Slony-I creation scripts not available; only joining possible. When looking for solution, I found a helpful maillist . Especially first post by Neel Patel was helpful: > Sorry for the late replay, we have checked and it is a bug in pgAdmin > because the name of the sql files got changed in new slony version ( > v2.2.0 ) which is used by the pgAdmin. > > Issue :- > > When we install the slony ( version less than 2.2.0 ) then it will > install below sql files in C:\Program Files\PostgreSQL\9.3\share > folder. > > slony1_base.sql slony1_base.v83.sql slony1_base.v84.sql > slony1_funcs.sql slony1_funcs.v83.sql slony1_funcs.v84.sql > > Now in New version of slony 2.2.0 onwards the name of the above sql > files got changed as below. > > slony1_base.2.2.0.sql slony1_base.v83.2.2.0.sql > slony1_base.v84.2.2.0.sql slony1_funcs.2.2.0.sql > slony1_funcs.v83.2.2.0.sql slony1_funcs.v84.2.2.0.sql > > As we are using above sql files names in pgAdmin to create the new > slony clusters so we need to change in pgAdmin also. Later in the discussion a patch fixing it appeared, but I don't know how to apply it - see my previous question . See that question for the ways I tried. Is there any way to solve this problem other than to install the patch? Help with installing the patch would be also appreciated, but I would prefer it to appear in the linked answer than here, this question should focus on other ways to solve it. EDIT: I tested different versions of PostgreSQL and Slony-I (Slony 2.0.7 on PostgreSQL 9.1 and Slony 2.1.3 on PostgreSQL 9.2) and also pgAdmin 1.16. The same problems occurs everywhere.
Pavel V. (757 rep)
Apr 16, 2014, 09:20 AM • Last activity: Jul 2, 2014, 08:30 AM
1 votes
0 answers
1027 views
How to apply a patch to pgAdmin III 1.18.1 on Windows?
A follow-up question to this one: [How to apply a patch in PostgreSQL on Windows?][1] There is a lot of .patch files distributed everywhere, but no hints how to apply them (at least no hints that wouldn't presume that I am on Linux). Is there any option to install the patch through some GUI? Or do I...
A follow-up question to this one: How to apply a patch in PostgreSQL on Windows? There is a lot of .patch files distributed everywhere, but no hints how to apply them (at least no hints that wouldn't presume that I am on Linux). Is there any option to install the patch through some GUI? Or do I need to use UNIX-like command line? Or to recompile pgAdmin in Visual Studio? If I need some scripting, point me to some manual, please. I have pgAdmin III 1.18.1 and PostgreSQL 9.3.4 on Windows XP (32 bit). EDIT: I'm trying to recompile pgAdmin in Visual Studio (now without the patch - I don't know how to integrate it to the solution, I just try to learn how to recompile it). I reduced the errors raised while trying to rebuild it from 101 to 14, but I have no idea how to handle the rest. So I would appreciate either some tutorial how to recompile pgAdmin in Visual Studio and handle the errors, or any other way how to do it. Or that it is not possible (if so, please back it with some source) and installing Linux and learning with its command line is the only way to apply the patch. EDIT2: I learnt how to understand the patch code (from a manual here ) and apply it manually on the file in the sourcecode. Still it looks as though that compilation is necessary, and there are tens of wxwidgets related errors (it just seemed for a while there are just 14 of them).
Pavel V. (757 rep)
Apr 9, 2014, 10:25 AM • Last activity: Apr 23, 2014, 08:55 AM
0 votes
1 answers
565 views
Guru hints not working in pgAdmin
Guru hints don't work on my pgAdmin (1.18.1) - no hint was ever shown, "Hints" item in "Help" menu is grey and even though I can set options for the hints, the changes won't save - when I open "Options" the next time, both fields are unchecked again. I ran the installer again to "repair" the install...
Guru hints don't work on my pgAdmin (1.18.1) - no hint was ever shown, "Hints" item in "Help" menu is grey and even though I can set options for the hints, the changes won't save - when I open "Options" the next time, both fields are unchecked again. I ran the installer again to "repair" the install, but the hints are still not working. So how to enable the hints?
Pavel V. (757 rep)
Apr 9, 2014, 07:08 AM • Last activity: Apr 10, 2014, 06:29 AM
Showing page 1 of 5 total questions