473,405 Members | 2,272 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,405 software developers and data experts.

Returned more than one row error message in a FOR IN EXECUTE loop

I wrote a function that basically executes a dynamic query and returns
True if there is at least one record and false in not.

CREATE OR REPLACE FUNCTION RecordHasChild (table1, CHARACTER,
CHARACTER) RETURNS BOOLEAN AS '
DECLARE
childrec RECORD;
sqlquery text;
BEGIN
sqlquery = ''SELECT field1 FROM '' || $2 || '' WHERE ('' || $2
|| ''.account_no = '' || quote_literal(table1.account_no) || '') AND
('' || $3 || '') LIMIT 1'';

FOR childrec IN EXECUTE sqlquery LOOP
RETURN True;
END LOOP;

RETURN False;

END;
' LANGUAGE 'plpgsql';
I use this function in a where clause like RecordHasChild(table1,
'relatedtable', 'relatedtable.somefield = \'some value\'')

The problem I have is I get this error "query "SELECT ..." returned
more than one row". Why is there a problem if the query returns more
than one row ? That's why there is a loop. Any ideas ?

Thanks,
George
Jul 19 '05 #1
0 1778

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

Similar topics

8
by: dw85745 | last post by:
Thanks for responding J French --------- I assume you are finding the hWnd and using SetParent -------------- Yes. Using Shell instead of ShellExecute. Saw another Shell implementation (as...
6
by: Matthew Houseman | last post by:
All, I've created a synonym that points to a package over a database link like so: CREATE SYNONYM API_MYLINK FOR USER.CSAPI_V2@INSTANCE.DOMAIN.COM I've granted execute like so: grant execute...
1
by: Jim Garrison | last post by:
Oracle has a tech article describing how a Java stored procedure can return a REF CURSOR: http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jdbc/refcur/index.html Here's the...
0
by: Geraint Evans | last post by:
Hi All, I am trying to access a Transform Data Task in a DTS by double clicking it. When I do, I get a message similar to "HResult of 0x80004005 (-2147467259) returned Unexpected error...
1
by: Beau | last post by:
Hi all, thanks in advance. Ok, heres the story. What is happening...... -------------------------------- I've got an ASP page that loops. It loops in order to get data in different,...
6
by: Dino Vliet | last post by:
Hi there, I want to put a number of records (variable number depending on a attribute of a table) into a certain table with a trigger statement. I have created the follwing trigger: CREATE...
0
by: John | last post by:
Hi, I am getting this error message The remote server returned an error: (405) Method Not Allowed. while trying to execute the following code: Dim myReq As HttpWebRequest =...
32
by: lovecreatesbea... | last post by:
In C++ Primer 4th, sec 3.3.2, it states that C++ programmers use != rather than < in a for loop. The following small snippet erases punctuations in a string. It works well with < used in the for...
1
by: endriu | last post by:
Hi I want to recive some data from db2 (as400) using ado.net in visual basic. Also i want to access them by stored procedure that return a cursor. So, i create very simple stored procedure on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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,...
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...

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.