Connecting Tech Pros Worldwide Forums | Help | Site Map

Passthrough Query which Returns 0 records...

Newbie
 
Join Date: Dec 2008
Posts: 2
#1: Dec 22 '08
Hello...

I have a single passthrough query where the possiblity for it to return zero records exists. If zero records will be returned, is there a way to add some logic that will catch this and return one record with all fields filled with zeros instead of returning no records at all? If possible I would like to contain everything with-in this one query.

NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,764
#2: Dec 22 '08

re: Passthrough Query which Returns 0 records...


I don't believe so.

It's sort of possible to create the situation with a UNION query and some selection criteria that loses the manual record if any others exist. I can't think of any way that would allow the query to run other than in a crippled way though (Checking the record count causes it to run again). Very messy. Basically, unless this is an overriding requirement, I wouldn't go there.

PS. We are talking SQL here. VBA has no such restrictions, but then you can't easily fit that logic into a query.
Newbie
 
Join Date: Dec 2008
Posts: 2
#3: Dec 23 '08

re: Passthrough Query which Returns 0 records...


Would this be a good example of a case where you would want to use a stored procedure?
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,764
#4: Dec 23 '08

re: Passthrough Query which Returns 0 records...


This doesn't sound much like an Access question if we're going there.

Yes. In SQL Server you can define a Cursor which can be tested and returned only if not empty. Otherwise a more simple and static cursor could be returned in its stead.
Reply