Returning dynamic results from a view

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • powercrazy
    New Member
    • Jul 2007
    • 3

    Returning dynamic results from a view

    All,
    We have a situation where we have a view that selects data from a table. Lets say the colums are:
    BEGIN_TIMESTAMP , END_TIMESTAMP, UNIQUE_KEY, etc....

    there is alot of other logic that goes on in the view to create the output dataset we need, suffice to say we're stuck on one particular aspect. In the situation whereby the BEGIN_TIMESTAMP and END_TIMESTAMP cross an hour - I.e. BEGIN_TIMESTAMP = '01/01/2007 3:55' and END_TIMESTAMP = '01/01/2007 4:05' we will need to split that into two returned rows, One with BEGIN_TIMESTAMP = '01/01/2007 3:55' and END_TIMESTAMP = '01/01/2007 4:00' - the second row having BEGIN_TIMESTAMP = '01/01/2007 4:00' and END_TIMESTAMP = '01/01/2007 4:05'.

    The crux of the issue is that we'd like to do all of this in a self-contained manner not using a temporary table if possible because of the nature of the datasource we are tapping into. Can we do this sort of logic directly within the view or directly within a procedure/function that the view uses without involving temporary tables?

    Looking for any insight you guys may have...
  • powercrazy
    New Member
    • Jul 2007
    • 3

    #2
    Folks,
    Any help would be greatly appreciated! If I haven't given enough information here, please let me know.

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      It will be bettter to use a procedure for the purpose as it involvs some critical logic to implement..

      Read the data from the table using a cursor.

      Comment

      • powercrazy
        New Member
        • Jul 2007
        • 3

        #4
        What we have currently implemented is the view calls a stored procedure - the procedure gathers the data from the table(s) in question - the issue is, how does the stored procedure return the results including newly added rows? I.e. can we create an outbound cursor and manually populate it based on the original cursor and our additional logic?

        Comment

        Working...