Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 25

Thread: Long metedata string

  1. #11
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,739
    Can you use the len() function to see what length the character string is. That will be helpful.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  2. #12
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,862
    m_meta = metadata_encode(oFieldMD)
    ? "metadata_encode"
    ? m_meta
    ? len(m_meta)

    m_meta = searchfield=true;userselectablesearchfield=true;da tamappingget=keylookup("EMLOYEES", "EMLOYEEID", "{}" ,rpad(firstname, 30, " ") + " " + lastname, "not found");autosuggest=select id,firstname,lastname from employees;autosuggestheaders=Employee ID,first name,last name;dialogbuttonaction=OpenMyTablePicker(this, "employees", "id,firstname,lastname");dialogbutton=true;changed action=FieldChange(this, "employees", "id,firstname,lastname");datachangedaction=FieldDa taChanged(this, "employees", "id,firstname,lastname")

    len = 518 char

  3. #13
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,739
    I have no idea what you are doing but i ran this code after correcting the table to employees and its all fine.

    Code:
    close databases 
    open database test 
    use employees exclusive 
    
    
    oFieldMD = object()
    
    
    oFieldMD.searchfield = .t.
    oFieldMD.userSelectableSearchField = .t.		
    
    
    oFieldMD.searchfield = True
    oFieldMD.userselectablesearchfield = True
    oFieldMD.datamappingget = 'keylookup("EMLOYEES", "EMLOYEEID", "{}" ,rpad(firstname, 30, " ") + " $ " + lastname, "not found")'
    oFieldMD.autosuggest = 'select id,firstname,lastname from employees'
    oFieldMD.autosuggestheaders = 'Employee ID,first name,last name'
    oFieldMD.dialogbuttonaction = 'OpenMyTablePicker(this, "employees", "id,firstname,lastname")'
    
    
    
    
    m_MainTable = "employees"
    m_columnName = "employeeid"
    m_command = "alter table " + alltrim(m_MainTable) + " modify constraint " + alltrim(m_columnName) + " metadata metadata_encode(oFieldMD)"
    ? "m_command " + m_command
    ? "oFieldMD"
    ? oFieldMD					
    exec(m_command)
    
    
    ? columnmetadata("employeeid")
    ? len(columnmetadata("employeeid"))
    ? metadata_decode(columnmetadata("employeeid"))
    
    
    oFieldMD = object()
    
    
    oFieldMD.dialogbutton = True
    oFieldMD.changedaction = 'FieldChange(this, "employees", "id,firstname,lastname")'
    oFieldMD.datachangedaction = 'FieldDataChanged(this, "employees", "id,firstname,lastname")'
    
    
    m_MainTable = "employees"
    m_columnName = "employeeid"
    m_command = "alter table " + alltrim(m_MainTable) + " modify constraint " + alltrim(m_columnName) + " metadata metadata_encode(oFieldMD)"
    ? "m_command " + m_command
    ? "oFieldMD"
    ? oFieldMD					
    exec(m_command)
    
    
    ? columnmetadata("employeeid")
    ? len(columnmetadata("employeeid"))
    
    
    m_metadata = "oFieldMD = metadata_decode(columnmetadata('" + rtrim(m_columnName) + "'))"
    exec(m_metadata)  				
    ? "read_oFieldMD"
    ? oFieldMD
    The result is here:

    Name:  Screen Shot 2018-11-21 at 4.19.57 PM.jpg
Views: 13
Size:  82.9 KB

    There is no problem with string length.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  4. #14
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,862
    yes, but this is the running code.. but with wrong result..
    the second "alter table" delete the previous metadata assignment

    try the first code:
    Code:
    close databases 
    open database test 
    use event exclusive 
    
    oFieldMD = object()
    
    oFieldMD.searchfield = .t.
    oFieldMD.userSelectableSearchField = .t.		
    
    oFieldMD.searchfield = True
    oFieldMD.userselectablesearchfield = True
    oFieldMD.datamappingget = 'keylookup("EMLOYEES", "EMLOYEEID", "{}" ,rpad(firstname, 30, " ") + "  " + lastname, "not found")'
    oFieldMD.autosuggest = 'select id,firstname,lastname from employees'
    oFieldMD.autosuggestheaders = 'Employee ID,first name,last name'
    oFieldMD.dialogbuttonaction = 'OpenMyTablePicker(this, "employees", "id,firstname,lastname")'
    oFieldMD.dialogbutton = True
    oFieldMD.changedaction = 'FieldChange(this, "employees", "id,firstname,lastname")'
    oFieldMD.datachangedaction = 'FieldDataChanged(this, "employees", "id,firstname,lastname")'
    
    m_MainTable = "event"
    m_columnName = "employeeid"
    m_command = "alter table " + alltrim(m_MainTable) + " modify constraint " + alltrim(m_columnName) + " metadata metadata_encode(oFieldMD)"
    ? "m_command " + m_command
    ? "oFieldMD"
    ? oFieldMD					
    exec(m_command)
    
    ? "metadata_encode"
    ? metadata_encode(oFieldMD)
    
    m_meta = metadata_encode(oFieldMD)
    ? metadata_decode(m_meta)
    
    m_metadata = "oFieldMD = metadata_decode(columnmetadata('" + rtrim(m_columnName) + "'))"
    exec(m_metadata)  				
    ? "read_oFieldMD"
    ? oFieldMD

  5. #15
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,862
    Hi Josip,
    I've the same problem when the lenght of the object passed to the alter table is too long.

    thanks
    Fabio

  6. #16
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,739
    Im sorry but my example I posted works perfectly fine. Did you try It? If you have an issue submit a ticket with the database and the code to reproduce the problem and we will look into it.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  7. #17
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,739
    This post is a statement on its own with no reference to anything.

    I already told told you about max string lengths so why repeat the same statement.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  8. #18
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,099
    Hi Fabio

    (I deleted my post to which you responded because it was something left in MetaData before my testing).
    Now I deleted all metadata and start testing again with Barry's version (except: open datatabase southwind)

    The first half only: OK
    The second half only: OK

    No non-printable characters.

    Yes, the second one replaces entirely previous metadata, as expected.
    Last edited by josipradnik; 2018-11-21 at 05:59.

  9. #19
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,739
    By using exec() to assign to ofieldmd you are creating a new local variable at a higher level up the stack because LOCAL is ON. Declare it public or private. It looks to be a scoping issue caused by you using exec() which as I mentioned previously is not nescessary.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  10. #20
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,862
    Barry, for me, don't work also the command without exec...

    Code:
    close databases 
    open database test 
    use event exclusive 
    
    oFieldMD = object()
    
    oFieldMD.searchfield = .t.
    oFieldMD.userSelectableSearchField = .t.		
    
    oFieldMD.searchfield = True
    oFieldMD.userselectablesearchfield = True
    oFieldMD.datamappingget = 'keylookup("EMLOYEES", "EMLOYEEID", "{}" ,rpad(firstname, 30, " ") + "  " + lastname, "not found")'
    oFieldMD.autosuggest = 'select id,firstname,lastname from employees'
    oFieldMD.autosuggestheaders = 'Employee ID,first name,last name'
    oFieldMD.dialogbuttonaction = 'OpenMyTablePicker(this, "employees", "id,firstname,lastname")'
    oFieldMD.dialogbutton = True
    oFieldMD.changedaction = 'FieldChange(this, "employees", "id,firstname,lastname")'
    oFieldMD.datachangedaction = 'FieldDataChanged(this, "employees", "id,firstname,lastname")'
    
    ? "oFieldMD"
    ? oFieldMD					
    alter table event modify constraint employeeid metadata metadata_encode(oFieldMD)
    
    ? "metadata_encode"
    ? metadata_encode(oFieldMD)
    
    m_meta = metadata_encode(oFieldMD)
    ? metadata_decode(m_meta)
    
    oFieldMD = metadata_decode(columnmetadata('employeeid'))
    ? "read_oFieldMD"
    ? oFieldMD

Page 2 of 3 FirstFirst 123 LastLast

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us