dynamic-sql Questions
3
Solved
How do I structure an SQL statement to run across multiple flat unrelated tables and display the result with the result of the select and the name of the table where the result came from.
The sce...
Ragtime asked 18/3, 2014 at 9:33
1
I have a plpgslq function which does some data processing and would like to write a for loop, however my table name is not known at design time. Is there any possible way to achieve this? Here is s...
Dunaville asked 7/1, 2014 at 7:8
2
Solved
CREATE OR REPLACE FUNCTION drop_now()
RETURNS void AS
$BODY$
DECLARE
row record;
BEGIN
RAISE INFO 'in';
FOR row IN
select relname from pg_stat_user_tables
WHERE schemaname='public' AND relna...
Traduce asked 25/11, 2013 at 12:42
1
Solved
I am trying to find the number of distinct values in each column of a table. Declaratively that is:
for each column of table xyz
run_query("SELECT COUNT(DISTINCT column) FROM xyz")
Finding the ...
Dosimeter asked 23/11, 2013 at 17:41
2
Solved
Recently I needed to move objects from PostgreSQL's default schema "public" to another schema. I found this post which shows how to move tables which was great, but I also need to move the function...
Cover asked 2/10, 2013 at 22:46
1
Solved
I am adjusting some PL/pgSQL code so my refcursor can take the table name as parameter. Therefore I changed the following line:
declare
pointCurs CURSOR FOR SELECT * from tableName for update;
wi...
Peck asked 16/9, 2013 at 14:22
1
Solved
It must be simple, but I'm making my first steps into Postgres functions and I can't find anything that works...
I'd like to create a function that will modify a table and / or column and I can't ...
Croix asked 22/8, 2013 at 15:2
1
Solved
I'm in a trigger context and trying to get following snippet to work.
execute format('insert into %I (user_name, action, new_values, query)
values (''%I'', ''i'', hstore(($1).*), current_query()...
Snood asked 20/8, 2013 at 18:39
1
Using PostgreSQL, column values from a table for 1st record are stored in a record variable. for ex: let the variable be: recordvar
recordvar.columnname
gives the value of the column name specif...
Ambience asked 10/8, 2013 at 7:40
1
Solved
I have a situation where I want to return the join between two views. and that's a lot of columns. It was pretty easy in sql server. But in PostgreSQL when I do the join. I get the error "a column ...
Emulsify asked 25/7, 2013 at 17:32
2
Solved
I'm attempting to write an area of a function in PL/pgSQL that loops through an hstore and sets a record's column(the key of the hstore) to a specific value (the value of the hstore). I'm using Pos...
Hilaryhilbert asked 9/7, 2013 at 11:59
4
Solved
I have a Postgres function:
create function myfunction(integer, text, text, text, text, text, text) RETURNS
table(id int, match text, score int, nr int, nr_extra character varying, info characte...
Elene asked 27/6, 2013 at 21:22
2
Solved
Please bear with me as this is my first post.
I'm trying to run the COPY command in PostgreSQL-9.2 to add a tab delimited table from a .txt file to a PostgreSQL database such as:
COPY raw_data F...
Slapdash asked 3/5, 2013 at 20:56
2
Solved
I am trying to update a bunch of columns in a DB for testing purposes of a feature. I have a table that is built with hibernate so all of the columns that are created for an embedded entity begin w...
Alexine asked 2/5, 2013 at 17:28
1
Solved
I am trying to write a function to load csv data into a table. I want the input argument to be the path to the file.
CREATE OR REPLACE FUNCTION public.loaddata(filepathname varchar)
RETURNS void A...
Khedive asked 15/4, 2013 at 15:51
2
Solved
Given the following schema:
create table account_type_a (
id SERIAL UNIQUE PRIMARY KEY,
some_column VARCHAR
);
create table account_type_b (
id SERIAL UNIQUE PRIMARY KEY,
some_other_column VA...
Mumble asked 11/3, 2013 at 15:58
1
Solved
I have created the following function to return set of columns based on parameters of that function:
CREATE OR REPLACE FUNCTION getColumns(IN _column1 text, IN _column2 text, IN _column3 text, IN ...
Separator asked 5/2, 2013 at 15:30
6
Ad hoc queries vs stored procedures vs Dynamic SQL. Can anyone say pros and cons?
Vikkivikky asked 29/5, 2010 at 10:19
1
Solved
Possible Duplicate:
Postgres Dynamic Query Function
I wish to use the returned string from the query below as a table name for other query.
SELECT 'backup_' || TO_CHAR(CURRENT_DATE,'...
Fatality asked 8/11, 2012 at 12:37
1
Solved
I am calling Stored procedure from Trigger and I get the following error:
Dynamic SQL is not allowed in stored function or trigger
Why is this happening, the dynamic SQL is being executed in S...
Floodgate asked 12/7, 2012 at 15:0
2
Solved
The following is part of a plpgsql function. The problem is that the result of source_geom and target_geom is a character varying data type, and therefore I need to surround the both source_geom an...
Impenitent asked 20/10, 2012 at 16:54
8
Solved
In my stored procedure I declared two table variables on top of my procedure. Now I am trying to use that table variable within a dynamic sql statement but I get this error at the time of execution...
Trod asked 7/1, 2011 at 14:12
4
Basically, I have a table that stores column names with some restrictions: infos, and another one that stores the values for those columns: info_data. I want to get a table which has the columns fr...
Tanganyika asked 25/5, 2012 at 9:19
3
Solved
I have a stored procedure which generates and executes a piece of dynamic T-SQL which, once built up, looks like this
SELECT
tblUsers.strUserName AS [Username]
,tblUsers.strEmail AS [Email]
,t...
Bibliopole asked 30/8, 2012 at 16:2
2
Solved
How can I write a stored procedure that contains a dynamically built SQL statement that returns a result set? Here is my sample code:
CREATE OR REPLACE FUNCTION reporting.report_get_countries_new ...
Pulsatory asked 14/8, 2012 at 8:2
© 2022 - 2024 — McMap. All rights reserved.