Passthrough Query which Returns 0 records...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ryanjkoffler
    New Member
    • Dec 2008
    • 2

    Passthrough Query which Returns 0 records...

    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
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32666

    #2
    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.

    Comment

    • ryanjkoffler
      New Member
      • Dec 2008
      • 2

      #3
      Would this be a good example of a case where you would want to use a stored procedure?

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32666

        #4
        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.

        Comment

        Working...