473,386 Members | 1,757 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,386 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 4470
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.