Reporting on Research Notes and the Full Bio Report

Hi everyone,

 

I’m looking for a bit of SQL that will join the separate lines in TX_CUST_NOTES based on their serial order. I figured that, before making something up, there must be someone out there whose already put it together. Am I wrong?

 

Alternatively, I was poking around trying to find the stored procedure for the component of the Full Bio report that reports on Research Notes. Unfortunately, there doesn’t appear to be documentation on that report, so I haven’t had much luck. If you know the SP for that sub-report, I’m sure I could find the SQL there, too.

 

Thanks in advance,

 

Rey

 

--

A. Rey Pamatmat

Tessitura Manager

The Public Theater

425 Lafayette Street

New York, NY 10003

(212) 539-8739

rpamatmat@publictheater.org

 

  • Here's for a report we have:

    CREATE procedure [dbo].[lrp_dev_notes]

    ( @start_dt datetime

    )

    as

    declare @cust_notes table

    ( cust_notes_no int,

    customer_no int,

    esal1_desc varchar(55),

    description varchar(30),

    created_by char(8),

    create_dt datetime,

    last_updated_by char(8),

    last_update_dt datetime,

    notes varchar(255),

    serial_order int

    )

    insert into @cust_notes

    ( cust_notes_no,

    customer_no,

    esal1_desc,

    description,

    created_by,

    create_dt,

    last_updated_by,

    last_update_dt,

    notes,

    serial_order

    )

    select

    a.cust_notes_no,

    a.customer_no,

    d.esal1_desc,

    c.description,

    a.created_by,

    a.create_dt,

    a.last_updated_by,

    a.last_update_dt,

    b.notes,

    b.serial_order

    from tx_cust_notes a

    join tx_cust_notes_ext b on a.cust_notes_no = b.cust_notes_no

    join tr_cust_notes_type c on a.note_type = c.id

    join tx_cust_sal d on a.customer_no = d.customer_no and d.signor = 0

    where a.create_dt >= @start_dt

    or a.last_update_dt >= @start_dt

    order by a.cust_notes_no, b.serial_order

    select distinct

    cust_notes_no,

    customer_no,

    esal1_desc,

    description,

    created_by,

    create_dt,

    last_updated_by,

    last_update_dt,

    (select '' + notes from @cust_notes a where a.cust_notes_no = b.cust_notes_no order by customer_no for xml path('')) as notegroup

    from @cust_notes b

    group by cust_notes_no,

    customer_no,

    esal1_desc,

    description,

    created_by,

    create_dt,

    last_updated_by,

    last_update_dt


    ================================
    Lucie Spieler
    IT Development and Training Manager
    Editor, Season Program
    Florida Grand Opera
    ------------------------
    8390 NW 25th Street
    Miami, FL 33122-1504

    305-854-1643 x.1521 phone
    305-856-1042 fax
    800-741-1010 ticket office
    lspieler@fgo.org
    www.fgo.org
  • It’s a little bit of RBAR as far as SQL optimization is concerned, but a scalar function called FS_GET_CUST_NOTES takes care of the serialization in AP_CUST_NOTES_BIO.

     

    Here’s the code from it:

    --

    Select      a.customer_no,

                a.cust_notes_no,

                a.note_type,

                c.description,

                a.create_dt,

                a.last_update_dt,

                a.created_by,

                a.last_updated_by,

                notes = [dbo].FS_GET_CUST_NOTES(a.cust_notes_no)

    From [dbo].tx_cust_notes a

          JOIN [dbo].vrs_cust_notes_type c on a.note_type = c.id

          LEFT JOIN [dbo].FT_SPLIT_LIST(@note_types, ',') x on a.note_type = x.element

    Where       customer_no = @customer_no

    and c.ok_to_print = 'Y'

    and   (@note_types is NULL or x.element > 0)

    Order By c.description, a.last_update_dt desc

     

    From: Tessitura Technical Forum [mailto:forums-technical@tessituranetwork.com] On Behalf Of A. Rey Pamatmat
    Sent: Wednesday, December 01, 2010 12:15 PM
    To: Ryan Creps
    Subject: [Tessitura Technical Forum] Reporting on Research Notes and the Full Bio Report

     

    Hi everyone,

     

    I’m looking for a bit of SQL that will join the separate lines in TX_CUST_NOTES based on their serial order. I figured that, before making something up, there must be someone out there whose already put it together. Am I wrong?

     

    Alternatively, I was poking around trying to find the stored procedure for the component of the Full Bio report that reports on Research Notes. Unfortunately, there doesn’t appear to be documentation on that report, so I haven’t had much luck. If you know the SP for that sub-report, I’m sure I could find the SQL there, too.

     

    Thanks in advance,

     

    Rey

     

    --

    A. Rey Pamatmat

    Tessitura Manager

    The Public Theater

    425 Lafayette Street

    New York, NY 10003

    (212) 539-8739

    rpamatmat@publictheater.org

     




    This message was sent automatically to you by www.tessituranetwork.com because you subscribed to the Tessitura Technical Forum. You may reply to this message to post to the Technical forum or visit the site to search, read and post to the forums. In the interest of keeping the forum posts from becoming cluttered, we encourage you to delete previous message text from your reply before sending. Thank you!

  • Ryan, as always, THANKS! I feel like every other post on this forum is, “Thank you, Ryan.” Should we just change its name to the Tessitura Thanking Ryan Forum?

     

    Rey

     

    From: Tessitura Technical Forum [mailto:forums-technical@tessituranetwork.com] On Behalf Of Ryan Creps
    Sent: Wednesday, December 01, 2010 1:15 PM
    To: Rey Pamatmat
    Subject: RE: [Tessitura Technical Forum] Reporting on Research Notes and the Full Bio Report

     

    It’s a little bit of RBAR as far as SQL optimization is concerned, but a scalar function called FS_GET_CUST_NOTES takes care of the serialization in AP_CUST_NOTES_BIO.

     

    Here’s the code from it:

    --

    Select      a.customer_no,

                a.cust_notes_no,

                a.note_type,

                c.description,

                a.create_dt,

                a.last_update_dt,

                a.created_by,

                a.last_updated_by,

                notes = [dbo].FS_GET_CUST_NOTES(a.cust_notes_no)

    From [dbo].tx_cust_notes a

          JOIN [dbo].vrs_cust_notes_type c on a.note_type = c.id

          LEFT JOIN [dbo].FT_SPLIT_LIST(@note_types, ',') x on a.note_type = x.element

    Where       customer_no = @customer_no

    and c.ok_to_print = 'Y'

    and   (@note_types is NULL or x.element > 0)

    Order By c.description, a.last_update_dt desc

     

    From: Tessitura Technical Forum [mailto:forums-technical@tessituranetwork.com] On Behalf Of A. Rey Pamatmat
    Sent: Wednesday, December 01, 2010 12:15 PM
    To: Ryan Creps
    Subject: [Tessitura Technical Forum] Reporting on Research Notes and the Full Bio Report

     

    Hi everyone,

     

    I’m looking for a bit of SQL that will join the separate lines in TX_CUST_NOTES based on their serial order. I figured that, before making something up, there must be someone out there whose already put it together. Am I wrong?

     

    Alternatively, I was poking around trying to find the stored procedure for the component of the Full Bio report that reports on Research Notes. Unfortunately, there doesn’t appear to be documentation on that report, so I haven’t had much luck. If you know the SP for that sub-report, I’m sure I could find the SQL there, too.

     

    Thanks in advance,

     

    Rey

     

    --

    A. Rey Pamatmat

    Tessitura Manager

    The Public Theater

    425 Lafayette Street

    New York, NY 10003

    (212) 539-8739

    rpamatmat@publictheater.org

     




    This message was sent automatically to you by www.tessituranetwork.com because you subscribed to the Tessitura Technical Forum. You may reply to this message to post to the Technical forum or visit the site to search, read and post to the forums. In the interest of keeping the forum posts from becoming cluttered, we encourage you to delete previous message text from your reply before sending. Thank you!




    This message was sent automatically to you by www.tessituranetwork.com because you subscribed to the Tessitura Technical Forum. You may reply to this message to post to the Technical forum or visit the site to search, read and post to the forums. In the interest of keeping the forum posts from becoming cluttered, we encourage you to delete previous message text from your reply before sending. Thank you!

  • An off-topic question.. 

    Is FT_SPLIT_LIST more efficient than the "where charindex" method of dealing with multi-valued parameters?

  • In my not-anywhere-close-to-a-true-laboratory testing, I’ve not noticed much of a difference.

    -Ryan

     

    From: Tessitura Technical Forum [mailto:forums-technical@tessituranetwork.com] On Behalf Of David Woodall
    Sent: Wednesday, December 01, 2010 2:25 PM
    To: Ryan Creps
    Subject: RE: [Tessitura Technical Forum] Reporting on Research Notes and the Full Bio Report

     

    An off-topic question.. 

    Is FT_SPLIT_LIST more efficient than the "where charindex" method of dealing with multi-valued parameters?

    From: Ryan Creps <bounce-ryancreps9649@tessituranetwork.com>
    Sent: 12/1/2010 12:12:38 PM

    It’s a little bit of RBAR as far as SQL optimization is concerned, but a scalar function called FS_GET_CUST_NOTES takes care of the serialization in AP_CUST_NOTES_BIO.

     

    Here’s the code from it:

    --

    Select      a.customer_no,

                a.cust_notes_no,

                a.note_type,

                c.description,

                a.create_dt,

                a.last_update_dt,

                a.created_by,

                a.last_updated_by,

                notes = [dbo].FS_GET_CUST_NOTES(a.cust_notes_no)

    From [dbo].tx_cust_notes a

          JOIN [dbo].vrs_cust_notes_type c on a.note_type = c.id

          LEFT JOIN [dbo].FT_SPLIT_LIST(@note_types, ',') x on a.note_type = x.element

    Where       customer_no = @customer_no

    and c.ok_to_print = 'Y'

    and   (@note_types is NULL or x.element > 0)

    Order By c.description, a.last_update_dt desc

     

    From: Tessitura Technical Forum [mailto:forums-technical@tessituranetwork.com] On Behalf Of A. Rey Pamatmat
    Sent: Wednesday, December 01, 2010 12:15 PM
    To: Ryan Creps
    Subject: [Tessitura Technical Forum] Reporting on Research Notes and the Full Bio Report

     

    Hi everyone,

     

    I’m looking for a bit of SQL that will join the separate lines in TX_CUST_NOTES based on their serial order. I figured that, before making something up, there must be someone out there whose already put it together. Am I wrong?

     

    Alternatively, I was poking around trying to find the stored procedure for the component of the Full Bio report that reports on Research Notes. Unfortunately, there doesn’t appear to be documentation on that report, so I haven’t had much luck. If you know the SP for that sub-report, I’m sure I could find the SQL there, too.

     

    Thanks in advance,

     

    Rey

     

    --

    A. Rey Pamatmat

    Tessitura Manager

    The Public Theater

    425 Lafayette Street

    New York, NY 10003

    (212) 539-8739

    rpamatmat@publictheater.org

     




    This message was sent automatically to you by www.tessituranetwork.com because you subscribed to the Tessitura Technical Forum. You may reply to this message to post to the Technical forum or visit the site to search, read and post to the forums. In the interest of keeping the forum posts from becoming cluttered, we encourage you to delete previous message text from your reply before sending. Thank you!




    This message was sent automatically to you by www.tessituranetwork.com because you subscribed to the Tessitura Technical Forum. You may reply to this message to post to the Technical forum or visit the site to search, read and post to the forums. In the interest of keeping the forum posts from becoming cluttered, we encourage you to delete previous message text from your reply before sending. Thank you!

  • It's an interesting question.  I would have thought that the list function was more efficient and our earlier testing showed that it was, but I found some web code where the charindex method was noticeably faster.  I think it depends where you are using it and I think it's in a WHERE clause that charindex is the winner.  Which makes some sense because the optimizer spends a lot of time evaluating WHERE clauses and probably doesn't normally like to see function calls there.  But as they always say, results may vary.