473,396 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Return dynamically created table from function

Hello,

I have created one function which create dynamically pivot table .Now I want to return that table from function. Generally we return table with fixed number of columns with data type, But now I don know no of columns.Table will create dynamically and want to return that table. What should I do?
Please suggest.
Apr 28 '16 #1
2 6100
Hello,
I am working on postgresql database. Please help for solution.
Apr 28 '16 #2
Here is function

Expand|Select|Wrap|Line Numbers
  1. CREATE OR REPLACE FUNCTION get_records()
  2.   RETURNS setof text AS
  3. $BODY$
  4. DECLARE
  5. query TEXT;
  6. table_name character varying;
  7. result text;
  8. BEGIN
  9. create temp table testing(a integer,b integer);
  10. insert into testing values(1,2);
  11. insert into testing values(3,4);
  12. table_name = 'testing';
  13. create table test as select * from testing;
  14. Perform (get_records_test('test')::test).* ;
  15. drop table testing;
  16. drop table test123;
  17. END;
  18. $BODY$
  19.  
  20.  
  21.  
  22.  
  23. CREATE OR REPLACE FUNCTION get_records_test(table_name text)
  24.   RETURNS SETOF text AS
  25. $BODY$
  26. DECLARE
  27. query TEXT;
  28. BEGIN
  29. query = format('SELECT  %s::text FROM %s', table_name, table_name);
  30. raise notice 'Query(%)',query;
  31. RETURN QUERY EXECUTE query;
  32. END;
  33. $BODY$
Apr 28 '16 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Thomas | last post by:
Hi, I'm having a problem with the dynamically created inputfields in Internet Explorer. The situation is the following: - I have a dynamically created table with a textbox in each Cell. - It...
1
by: martin | last post by:
Hi, I have the following code in my page load event that creates a table on the web page. The trouble is that after a postback such as a button click on the page the table is not retained but...
0
by: Luis Esteban Valencia | last post by:
-- How do I add an activeX control to a dynamically created table? LUIS ESTEBAN VALENCIA MICROSOFT DCE 3. MIEMBRO ACTIVO DE ALIANZADEV http://spaces.msn.com/members/extremed/
4
by: Newbee | last post by:
I'm using a table (dynamically generated at runtime) for formatting wherein I have text in the first column, and textboxes in the second column. For example, (1,1) might have the string "Last Name"...
1
by: r_mun | last post by:
Hello, I think it would be an interesting issue to everyone. What I'd like to do is simply change the style of my dynamically created table cell. I have written the following code to...
3
by: ashish ranjan | last post by:
Hi there, I created dynamic table from server page which contain all data from a table in database along with a column which contails a checkbox with each row.then i send this response to client...
5
Tann3r
by: Tann3r | last post by:
Apache.v2.2.4, MySQL.v5.0.27, PHP5.2.1 I have a table of projects which has been dynamically created from an SQL query. I have several dropdown boxes which have been populated from other tables...
1
by: kavithavr | last post by:
hello I have created a table dynamically with four fields on that two fields are option buttons in VB.net. Using panel control i have displayed the table. My question is, there is no events for...
2
by: Conrad Lender | last post by:
On 2008-10-10 19:56, T.G. wrote: This doesn't work at all, at least not in Firefox. When any of the "up" or "down" links is clicked, the following error occurs: clickedRow.removeNode is not a...
2
by: semomaniz | last post by:
I have created two tables dynamically and have added textboxes inside the table. now i am trying to retrieve the data from the the textboxes and i am getting a null reference error. I am not sure why...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.