_SQL := 'SELECT TmessageId FROM tmpBids WHERE TphoneNumber = ' || quote_literal(phoneNumber) || ' AND Tbid = ' || aBid; FOR rec IN EXECUTE _SQL LOOP bidCount := rec._qv; END LOOP;
This works ok as long as the SELECT query returns rows. Of course, if it returns multiple rows bidCount variable will hold just the last row value, but the design of application is like that so the query from the start returns only one row, or returns no rows. Of course, if it returns no rows, I'm presented with an error, saying: ERROR: record "rec" has no field "_qv" This is logical. My question would be is there a way around this withouth first doing SELECT COUNT(*) FROM tmbBids WHERE ..., and then if COUNT(*) is zero THEN bidCount := NULL ELSE if COUNT(*) is not zero then do SELECT from the begining? Mike -- Mario Splivalo Mob-Art [EMAIL PROTECTED] "I can do it quick, I can do it cheap, I can do it well. Pick any two." ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster