Creating a string with hiearchical data

This is being done in Crystal 8 will all updates applied.
I have a database with records that are linked to a series of "folders" that are hierarchical in nature as shown below:
Folder 1:
     Folder 1.1
          Folder 1.1.1
Folder 2
    Folder 2.1
All of the folders can have data records attached to them.
The database represents the folder structure in a table with the following attributes:
Folder ID   (integer)
Folder Name (String)  (such as "Folder 1"
Folder Parent ID (integer)
(other non-related fields)
If the folder is at the root level, then the value in Folder Parent ID is 0, otherwise, it is the Folder ID of the parent folder.
I need to be able to create a string field that displays the path for any given folder that I can insert into a group header or footer, or into a report header if the report deals with records in a single folder.  Desired format for the  string is: 
"Folder 1> Folder 1.1> Folder 1.1.1"
I need to be able to display at least 6 levels of folder indentation.
I have tried several ways to create a formula that will reliably produce the desired string, and can get close, but cannot completely address the problem.  My most successful approach was to put multiple instance of the table into the report and link the Folder Parent ID of one level to the Folder ID of the next level down and then use the data to build the string with a formula like this:
Local StringVar Result := {portfolio_master.portfolio_name};
local stringvar ExitLoop := "1" ;
if  ExitLoop = "1" then
    Result := {portfolio_master_1.portfolio_name} + "> " + Result
else
    ExitLoop := "0";
if {portfolio_master_1.parent_id} NE 0 AND ExitLoop = "1" then  // NE replaces Crystal not equal symbol which will not show
    Result := {portfolio_master_2.portfolio_name} + "> " + Result
else
    ExitLoop := "0";
if {portfolio_master_2.parent_id} NE 0 and ExitLoop = "1" then
    Result := {portfolio_master_3.portfolio_name} + "> " + Result
else
    ExitLoop := "0";
if {portfolio_master_3.parent_id} NE 0 and ExitLoop = "1" then
    Result := {portfolio_master_4.portfolio_name} + "> " + Result
else
    ExitLoop := "0";
if {portfolio_master_4.parent_id} NE 0 and ExitLoop = "1" then
    Result := {portfolio_master_5.portfolio_name} + "> " + Result
else
    ExitLoop := "0";
Result;
This formula works so long as the folder in question is exactly 5 levels deep.  Changing the nature of the links(inner join, left outer join etc.) between the instances of the table in the Database Expert changes the data that is visible, but I can't find a combination that will show ALL of the needed information for all of the folders. 
I understand that this is a brute force approach, and that there must be a different way to skin the cat.  My preference would be to "walk the tree" with a loop structure, but I don't see any way to do the needed data look up within the loop.
Any suggestions would be greatly appreciated!
Thanks,
L. Jasmann
Edited by: ljasmann1 on Jun 23, 2010 9:09 PM
Edited by: ljasmann1 on Jun 23, 2010 9:33 PM

I have been working to adapt the code provided above to my application.  Although I have worked with Crystal for quite a while, this is the first time that I have attempted to use SQL in Crystal... and it is just not working.. probably because I am no doing something very basic.
Here is  the code as currently set up in the SQL Formula Editor.  Only major difference from the code provided above is that the ID fields are integers instead of strings, and the field that I want to print out is a string field separate from the ID fields....  I have substituted the field names from the table I am referencing for the ones in the code above.  The table that I am using has been selected using the Database Expert.
DECLARE @Value int, @pf int, @FolderPath VarChar(MAX)
SET @Value = "portfolio_master"."portfolio_id"
SELECT @pf = "portfolio_master"."parent_id" FROM portfolio_master WHERE "portfolio_master"."portfolio_id" = @Value
SET @FolderPath = "portfolio_master"."portfolio_name"
WHILE @pf <> 0
BEGIN
SET @Value = @pf
SELECT @pf = "portfolio_master"."parent_id" FROM portfolio_master WHERE "portfolio_master"."portfolio_id" = @Value
SET @FolderPath = "portfolio_master"."portfolio_name" + ' > ' + @FolderPath
END
SELECT @FolderPath AS FolderPath
When I test the SQL statement it errors out on the very first statement (the DECLARE statement).  If I substitute a different statement in front of the DECLARE statement, it errors on that statement.
Here is the error that I get back. The database is using MS SQL Server.
Error in compiling SQL Expression:
Failed to retrieve data from the database.
Details:  ADO Error Code:  0x80040e14
Source:  Microsoft OLE db Provider for SQL Server
Description:  Incorrect syntax near the keyword u2018DECLAREu2019,
SQL State:  42000
Native Error:  156 [Database Vendor Code:  156].
Any pointers would be greatly appreciated...
Thanks,
Larry Jasmann

Similar Messages

  • How to create a report with survey data

    Hi All,
    I need to create a report with survey data in below format. Can anyone help me how to display the summary in this format.
    Swapna

    Hi Swapna,
    According to your description, you want to create a report with survey data and display the summary.
    Reporting Services is used for rendering the report with data retrieved from datasource. In Reporting Services, we can retrieve data from the datasource then design a report, after the report processed, data is fixed on the report. So it’s not supported
    to have the end users selection and do summary. For your requirement, it’s can’t be achieved currently.
    If you have any question, please feel free to ask.
    Best regards,
    Qiuyun Yu
    Qiuyun Yu
    TechNet Community Support

  • How to create a String with a specific size?

    how to create a String with a specific size?
    For example I want to create different Strings with the size of 100 , 1000 or 63k byte?

    String are immutable so just initialize it with the number of characters you want.
    You might want to look at java.lang.StringBuffer and see if that's what you want.

  • Creating a String with repeated chars

    Is there a way to create a String with N repeated chars without using a loop?
    I want to create something like "aaaaaaaaaa" without having to do:
        StringBuffer s = new StringBuffer();
        for(int i = 0; i< 10; i++){
          s.append("a");
        }

    Ahh, Groovy.
    #! /usr/bin/groovy
    s = 'a' * 10
    assert s == 'aaaaaaaaaa'http://groovy.codehaus.org/
    :o)

  • Problem creating line chart with character data

    Post Author: burkartt
    CA Forum: Charts and Graphs
    CR Developer v. 11.5.0.313
    I want to create a line chart with data from a SQL2K table to show how much server time each application uses per day. All data is defined a character.
    HWA,4/24/2007,01:44.6HWA,4/25/2007,12.28HWB,4/24/2007,4.6HWC,4/24/2007,55.55HWC,4/25/2007,01:22.3HWE,4/24/2007,01:16.1HWE,4/25/2007,0.59
    I want one horizontal line per application where the X-axis represents the date and the Y-axis represents the server time. I have tried all column combinations for "On Change Of" and "Show Value(s)". What confuses me is why are Count and Discount the only Summary Options for the "Show Value(s)" data?
    Thank you,
    tim

    Post Author: V361
    CA Forum: Charts and Graphs
    I created a group based on date, day, then created the chart and put it in the group footer, on change of server, show sum of time, you will get a seperate chart for each day.  I am not sure if this will help, or will just do.  Since you have CR XI, you may want to look at the gauge chart also....

  • Want to create Monthly chart with weekly data.

    Hi all.  I'd like to create a chart that graphs data over the course of a month similar to this:
    but where the data for the chart is only gathered once a week.  I know from reading in the forums (and trying myself) that if you have missing data fields in your table, you end up with individual points that aren't connected to each other.  So I assume that the solution has something to do with how the chart is labeled?
    Can someone clue me in on how to build a chart that shows each day (as above), but connects weekly data fields (as below):
    Thanks.
    Andy

    Hi Barry.
    It looks like what you're describing is what I've already managed to figure out.  The problem I'm having is that I want the bottom row of numbers (currently 3, 10, 17, 24) to be the days of an entire month (ie: March 1-31).  Then have the values in the chart correspond to the proper day (3, 10, 17, 24).
    Here's what happens if I create a table with all the days of the month, but only weekly fields filled in:
    I realize that Numbers doesn't automatically connect the dots when there are empty fields in a table.  But I can't seem to get to a point where I can have the graph show the entire month, but with a line connecting each of the weekly values.
    I thought that I could do it by creating a custom label for the X axis.  Here's what I tried:
    But of course that didn't work, because the chart still only shows 4 labels (due to the table only having 4 categories).  It just renamed the first four labels.

  • Creating Purchase Requistion with Configuration Data

    Hi Guys,
    I am interested in creating purchase requisition (BUS2105) with configuration data (Charatceristics). However, the BAPI BAPI_REQUISITION_CREATE does not have any interface to pass the config data.
    I tried using BAPI BAPI_OBJCL_CHANGE/CREATE to assign characteristics to to the requisition with no success.
    Any suggestion is welcomed.
    Thanks
    Yogi

    Hi,
    Dont think Shipping data will be there in Material Master. U probably need to chk the shipping details for the customer instead.
    Regards,
    Bikash

  • How to create a String with comma ?

    Hi All,
    I have a table with 10 records(employee name) and i have to make a string
    with comma delimiter and at the end with "."
    Can anybody tell me how to write a Java program for this ?
    Thanks in advance.

    // I believe the following example gives you the answer.
    class stringEG {
         public static void main(String args[]) {
         String emprs[] ={"1","2","3","4","5","6","7","8","9","10"};
         String vempname = "";
         for(int i=0; i<emprs.length; i++) {
         if(i == (emprs.length-1))
              vempname = vempname + emprs[i] + ".";
         else
              vempname = vempname + emprs[i] + ", ";
         System.out.println("vempname : "+vempname);
    Here dont assume that I asked you to get all the results and putting
    it into the string arrays. But its a simple example to suit your requirement.
    The half-way coding below answers your question, I hope.
    vempname = "";
    while (emprs.next()) {
    if(emprs.isLast())
    vempname = vempname + emprs.getString("empname") + ".";
    else
    vempname = vempname + emprs.getString("empname") + ", ";
    // nats.

  • How to create a string with numbers, separated by ",".

    Hello!
    I have a start number and a end number. For example 101 and 110.
    Now I want to create a string containing all numbers between 101 and 110 separated by comma(",").
    (101,102,103 .......,110)
    Any smart suggestions?

    Hello EKrille,
    I changed the vi from tst to give the same results on both options...
    Best regards,
    GerdW
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome
    Attachments:
    string.vi ‏26 KB

  • Creating hair/string with trapcode particular

    hi
    currently trying to put together a graphic which includes string gently blowing in the wind from text
    i am using trapcode particular to put this together, but am open to suggestion in terms of other software.
    the reasoning for using particular as i like the use of gravity and turbulence which could create an effect of string blowing in the wind..a difficulty i am having is creating a line of particles to create the string, i have tried increasing the particles per second...put the dots aren't joining up!
    man i hope this makes sense to someone!
    AE 7, trapcode particular, 1.5 MAC
    oh...have a merry christmas!
    cheers
    Nate

    I've posted a preset at the page below:
    http://homepage.mac.com/aaron.s.cobb/FileSharing1.html
    It's called "Particular Streamer". I've put an expression on the Particles Per Second to make it easy to set it to multiples of the frame rate (this keeps the particles from jittering). Just put a whole number in there, and the expression will make particular spit out that many particles per frame.

  • Create XLS file with XML data

    Hello,
    Is there Java libraries to create Excel files from XML data, like FOP that creating PDF files ?
    Another question : where can I find the javadoc of FOP's classes, particularly org.apache.fop.apps.Driver class ? Because I can't find it on http://xml.apache.org
    Thanks

    Use http://jakarta.apache.org/poi/

  • How to create a group with multiple data fields

    Post Author: RichS
    CA Forum: Formula
    Using CR XI.  Using CSV input from ODBC text driver.  No problems here.
    There are 3 fields that I want the same group by action.  Is this possible?) 
    If any one of these 3 fields change I want some header information and column fieldnames to display.  The header information I only want displayed on the first page (on the change) and the column fieldnames to display on every page.  I have played around with things like "InRepeatedGroupHeader" and "report group header on each page".  I am not getting all the results that I am looking for though.
    I want report to look like:
    Page header stuff  (to display on every page)  This data consists of some fields that will have static data and will display on every page.  And it consists of 3 non-static fields that I want to group on. 
    Group header stuff that I only want displayed on the first page on a change from one of the 3 fields mentioned above.
    Column headings that I want displayed on every page.
    Details data
    Group footer stuff (details not important for this)
    I get the expected output (column headings displayed on every page, and group header stuff display on the first page on each group change) with one group field.  But I want the group change to happen for all 3 fields.
    It seems simple but I can't find a way to create a "group" so if "field1 or field2 or field3" change, I get the same "group by" action.  I just need to know how to get the expected action.
    I expect that I might have some terms mixed up and/or some important information that would aide you in helping me.  If that is the case please re-post and I will add any missing or mis-stated information.
    Thanks,

    Post Author: V361
    CA Forum: Formula
    I am slightly confused, but perhaps you can create a formula
    Then group on the formula.  If this is not what you want, could you post some sample data, with the desired results.

  • Read,write and create word document with list data

    Hi,
    My requirement is that I have a custom list called List1 and which has a 4 (suppose XName, location, phone, email)columns and also have a Template document(.dot). If I click on save button , new document has to create from the Template document(.dot) and
    should modify the content depends on list columns.
    For that I need to read the document , find out the text where XName , location,,phone, email and replace with the list item data(user entered data). 
    Can anybody please refer links for read,write and create word document?
    Thanks in advance.

    Yes, you can using Office Open XML. I found it to be a lot more cumbersome and in the end not a money saving approach:
    https://msdn.microsoft.com/en-us/library/office/bb448854.aspx?f=255&MSPPError=-2147217396
    Kind regards,
    Margriet Bruggeman
    Lois & Clark IT Services
    web site: http://www.loisandclark.eu
    blog: http://www.sharepointdragons.com

  • Some questions about creating web animations with lighter data and exporting to vector Flash format.

    Hi, I will be creating animations in After Effects mostly using Illustrator vector files and will be exporting to SWF or XFL for using the animations on the web.
    One of the priorities is light data as possible to provide viewers with slower connections with better experience. However the animation should also impress and I need to find a balance between performance and possible imagery.  The animations may have sound and voice narrative.
    I need help with understanding which type of non-vector data is heavier than others. Non-vector image data or sound and voice? And from non-vector image data is some of it lighter or heavier than other - for example motion blur vs smooth gradient vs many colors?
    I would greatly appreciate any suggestions, tips, pointers, etc.,

    Hi, I will be creating animations in After Effects mostly using Illustrator vector files and will be exporting to SWF or XFL for using the animations on the web.
    One of the priorities is light data as possible to provide viewers with slower connections with better experience. However the animation should also impress and I need to find a balance between performance and possible imagery.  The animations may have sound and voice narrative.
    I need help with understanding which type of non-vector data is heavier than others. Non-vector image data or sound and voice? And from non-vector image data is some of it lighter or heavier than other - for example motion blur vs smooth gradient vs many colors?
    Let's do a little "Myth Busters" on that one, shall we?
    Vector data is per se not "lighter" than pixel data. You could have complex paths for which storing the information of the individual nodes takes up more space than a pixel image of the object.
    Dynamic rasterization of vector data costs CPU performance and may in effect make things more slow than just playing a series of pixel images. That would apply to anything from path strokes to gradients.
    All your pretty AI vectors don't mean anything if they are constructed in such a way that either AE or Flash need to rasterize them on import. Anything from converting Bezier paths to paths consisting of dense linear segments to converting fills, patterns, gradient meshes and so on to pixel data
    Pixels are pixels. It does not matter whether they are gradients, mothionblur or just non-antialiased shapes. Flash doesn't care and neither image format that may be used in Flash stores any more or less info. They only differ in their methods, but in the end it's for you to decide whether you use JPEG, PNG8 or PNG24. They all have their pros and cons.
    It makes a difference, if data is embedded in an SWF or if it is externally linked just as it makes a difference whether you enforce audio sync or not, playing every frame or not.
    So for all intends and purposes, it's still up to you to make up your own mind and find the best solution. And Rick has a point - if you're really that concerned about efficiency, then do it in Flash or Flash Catalyst and consider the options there that may help like GPU accelerated layer styles for drop shadows etc., dynamic text or your vector data remaining vector in teh first place.
    Mylenium

  • Creating a View with "clipped" data

    Hi all,
    I'm wondering if someone might know if it's possible to have clipped data in a view without clipping the original data that the view is drawing from.
    The problem we have is that we have a full dataset that we need to keep in a complete state (as a table in Oracle). We want to be able to create a View that will display a subset of data from this table, however, some of the objects in the full dataset cross a boundary and for these objects, we want the View to only show the part of the object within that boundary.
    I know we can clip the original layer but we ideally need to keep that layer untouched and do the clipping on-the-fly in the View. Is this possible?
    Thanks for any help you can give,
    Cheers, Paul

    Do you want to:
    create view my_clip
    as
    select a.id,
    a.attribute,
    mdsys.sdo_intersection(a.geometry,b.geometry,0.005) as geometry
    from mycliparea b,
    mytable a
    where sdo_anyinteract(a.geometry,b.geometry) = 'TRUE'
    Now this will work but to get performance you will have to do one of two things:
    1. Create a function based index. See doco or other postings in this forum for examples
    of how to do this.
    2. Change the view from an ordinary view to a materialized view. And then create
    a normal spatial index on the computed shape. (I recommend the use of
    these as against ordinary views.)
    However, Bryan is right, the problem with SDO_INTERSECTION is that it can return:
    1. Polygons;
    2. Lines;
    3. Points;
    4. Compound objects containing one or more of the above.
    If you want polygons only, then you need to extract them.
    <selfpromtion>
    I have written a set of extraction functions that do this which are available for free.
    Contact me at "spatialdbadvisor at netspace dot net dot au" or "simon at spatialdbadvisor dot com"
    </selfpromotion>
    The correct view definition using one of my functions would be:
    create view my_clip
    as
    select a.id,
    a.attribute,
    geom.ExtractPolygon(
    mdsys.sdo_intersection(a.geometry,b.geometry,0.005))
    as geometry
    from mycliparea b,
    mytable a
    where sdo_anyinteract(a.geometry,b.geometry) = 'TRUE'
    regards
    S

Maybe you are looking for