Hoppa till huvudinnehållet

Can I display a DataLink with no results?

Kommentarer

2 kommentarer

  • John Nerge
    So if I understand correctly, right now you're using the data link as the title of your search result, so if there's no match on the data link you get a search result with a blank title?

     

    If that's true, then how about using a CASE statement in SQL to handle? Something along the lines of

     

    CASE

     

    WHEN [AnnexationField] is null THEN 'No Future Annexations Found'

     

    ELSE [AnnexationField]

     

    END AS [Annexations]

     

    or, if you're returning a count of events, then

     

    CASE

     

    WHEN Count([AnnexationField]) = 0 THEN 'No Future Annexations Found'

     

    WHEN Count([AnnexationField]) = 1 THEN '1 Future Annexation Found'

     

    ELSE Cast(Count([AnnexationField]) AS VARCHAR) + ' Annexations Found'

     

    END AS [AnnexationsCount]
    0
  • Sean McClurkan
    The title of the Data Link only appears if data is returned from the SQL.  The first selected column appears as a list item.  If no rows are returned, then the entire Data Link is ignored and nothing is displayed.  I needed the Data Link to be displayed with a message letting the user know there was no data for that link.  I ended up with the SQL below which uses an inline view named "x" unioned with a query that returns the message I need WHERE NOT EXISTS any data from the inline view "x".  See below:

     

    WITH x AS

     

    (SELECT initcap(REPLACE(a.account_name, '"')) "Account Owner"

     

                  ,initcap(p.place_text) || ' ' || initcap(p.city) || ', TX  ' || p.zip_code "MailingAddress"

     

      FROM coa_address p

     

     INNER JOIN ccb_account a

     

        ON (p.place_id = a.place_id)

     

     WHERE p.discontinue_date IS NULL

     

       AND a.address_place_id = :placeid)

     

    SELECT * FROM x

     

    UNION ALL

     

    SELECT 'No Utility Account Found' "Account Owner"

     

           ,NULL "MailingAddress"

     

      FROM dual  

     

     WHERE NOT EXISTS (SELECT * FROM x)

     

    This only executes the base SQL statement once, as oppposed to just repeating the first statement with a WHERE NOT EXISTS.  Now, when there are no Utility Accounts for an address, the title of the Data Link appears in the panel with the message "No Utility Accounts Found" when there are none.
    0

Du måste logga in om du vill lämna en kommentar.