472,358 Members | 1,947 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

How do I get query result(select e.g.) from a dynamic command(EXECUTE)?

Hi,

I want to do a select in dynamic command, something like:

TRIGGER FUNCTION
DECLARE
table_name_suffix text;
temp_result RECORD;
temp_result2 RECORD;

....

BEGIN
--initialization of table_name_suffix(from TG_RELNAME e.g.)
select into temp_result from
''fixed_table_name_prefix''||table_name_suffix where another_table_name =
abc;

--Then I want to use part of the result as part of the table name for my
next query
select into temp_result2 from
''fixed_table_name_prefix''||temp_result.anotherta blename;

END

I know that SELECT INTO doesn't support dynamic command, EXECUTE does. But
if I EXECUTE a select query, how do I get
the select result from it?

Many thanks,

Wei Wang
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 22 '05 #1
2 4396
Sorry. I just found it in the documentation. FOR-IN-EXECUTE or
OPEN-FOR-EXECUTE.
----- Original Message -----
From: "Wei Wang" <ww***@cam.ac.uk>
To: "pgsql" <pg***********@postgresql.org>
Sent: Thursday, February 19, 2004 11:50 AM
Subject: [GENERAL] How do I get query result(select e.g.) from a dynamic
command(EXECUTE)?

Hi,

I want to do a select in dynamic command, something like:

TRIGGER FUNCTION
DECLARE
table_name_suffix text;
temp_result RECORD;
temp_result2 RECORD;

...

BEGIN
--initialization of table_name_suffix(from TG_RELNAME e.g.)
select into temp_result from
''fixed_table_name_prefix''||table_name_suffix where another_table_name =
abc;

--Then I want to use part of the result as part of the table name for my next query
select into temp_result2 from
''fixed_table_name_prefix''||temp_result.anotherta blename;

END

I know that SELECT INTO doesn't support dynamic command, EXECUTE does. But
if I EXECUTE a select query, how do I get
the select result from it?

Many thanks,

Wei Wang
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 22 '05 #2
On Thursday 19 February 2004 11:50, Wei Wang wrote:
Hi,

I want to do a select in dynamic command, something like:
[snip] I know that SELECT INTO doesn't support dynamic command, EXECUTE does. But
if I EXECUTE a select query, how do I get
the select result from it?

FOR record | row IN EXECUTE text_expression LOOP
statements
END LOOP;

It's in the manuals, but that's about all they say on the subject
--
Richard Huxton
Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: B Love | last post by:
I am wondering if I can have a dynamically generated report based upon the results of a query (in Access2000). Any ideas? Related to that (if that cannot be done) can the output of a query...
10
by: pw | last post by:
Hi, Is that possible if the crosstab query is dynamic? Doesn't seem so as I have to specify the control source for the text boxes and the number of columns may change, along with their field...
0
by: starace | last post by:
I have designed a form that has 5 different list boxes where the selections within each are used as criteria in building a dynamic query. Some boxes are set for multiple selections but these list...
3
by: bjaj | last post by:
Hi I need some help to my VBA code. I want to open a query in Edit mode Change a parameter and then save the qyery and close it. A)I now how to do open the query in editmode docmd.openquery...
10
by: s.subbarayan | last post by:
Dear all, I happen to come across this exciting inspiring article regarding memory leaks in this website: http://www.embedded.com/story/OEG20020222S0026 In this article the author mentions:...
2
by: planetthoughtful | last post by:
Hi All, I'd like to place a subreport onto a report that draws its records from a UNION query. When I design the query and view the records all looks fine. However, when I put the query as...
0
by: qarmoe | last post by:
Please open the Screen Print (attached), else it's not gonna makes sense... http://download.yousendit.com/A61005CA7194C418 SELECT DISTINCT MSysObjects.Name FROM MSysObjects WHERE...
1
by: onlymukti4u | last post by:
Hi, I have a form page having two listboxes, One is having three teachers names and other having few students names...What exactly I want is, by clicking the respective Teacher names only their...
5
by: ravindarjobs | last post by:
hello friends, i am using ms access 2003. i have a form. and i want to show the results of a query output in the form. the query is dynamic. it changes often. for this purpose data grid...
0
by: Martin Ruprecht | last post by:
Hi, I do have a big problem: We are creating a reporting tool for logistic solutions using Crystal Reports. I actually am programming a history report. There are millions of lines in the...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

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.