Page 1 of 3 123 LastLast
Results 1 to 10 of 25

Thread: Long metedata string

  1. #1
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,862

    Long metedata string

    Hi all,
    I'm tryng to apply the metadata to a table field
    Code:
    m_metadata = "alter table myTable modify constraint myTableField metadata " + "[" + cMetaData + "]"		
    exec(m_metadata)
    but if the cMetadata string is too long.. the section fail to load.

    any suggestion?

    thanks
    Fabio

  2. #2
    Senior Member
    Join Date
    Apr 2012
    Location
    Dubai, United Arab Emirates
    Posts
    484
    Can you break it down like this

    omd = object()
    omd.caption = "my caption"
    omd["caption"] = "my caption"
    omd["applyrulesonchange"] = true
    omd["searchfield"] = true
    omd["userselectablesearchfield"] = true

    alter table mytable modify constraint myfield metadata metadata_encode(omd)

  3. #3
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,862
    Thanks, tomorrow I try.
    Fabio

  4. #4
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,739
    As you know character strings are limited to 64k so whenever you try to use strings > 64k it will fail. Even if this was increased it will still have a maximum value.

    This has nothing to do with metadata in particular. It’s basic Scripting.
    Last edited by barrymavin; 2018-11-19 at 23:45.
    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

  5. #5
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,739
    After looking at this again, you are creating it incorrectly.

    You write:

    Code:
    m_metadata = "alter table myTable modify constraint myTableField metadata " + "[" + cMetaData + "]"        
    exec(m_metadata)
    Should be just:

    Code:
    alter table myTable modify constraint myTableField metadata cMetaData
    Also You cannot use [ ] as the character string delimiters as conditional metadata uses them.

    In your code you are actually storing the metadata enclosed in [ and ]. Thats wrong.
    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

  6. #6
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,862
    I've try to use this:
    I set a new object:
    Code:
    Object (refcnt=2)
    (
        [searchfield] => True
        [userselectablesearchfield] => True
        [datamappingget] => keylookup('CAUCONT', 'C_CAUCONT', '{}' ,rpad(c_caucont, 30, ' ') + '  '+des_cau, 'non trovato')
        [autosuggest] => select c_caucont,des_cau,tipo_registro from CAUCONT
        [autosuggestheaders] => Codice causale,Descrizione causale,Tipo Registrazione
        [dialogbuttonaction] => OpenMyTablePicker(this, "CAUCONT", "c_caucont,des_cau,tipo_registro")
        [dialogbutton] => True
        [changedaction] => FieldChange(this, "CAUCONT", "c_caucont,des_cau,tipo_registro")
        [datachangedaction] => FieldDataChanged(this, "CAUCONT", "c_caucont,des_cau,tipo_registro")
    )
    then

    Code:
    m_command alter table movtiv modify constraint C_CAUCONT metadata metadata_encode(oFieldMD)
    but if I try to read the metadata:
    Code:
    Object (refcnt=2)
    (
        [searchfield] => True
        [userselectablesearchfield] => True
        [datamappingget] => keylookup('CAUCONT', 'C_CAUCONT', '{}' ,rpad(c_caucont, 30, ' ') + '  '+des_cau, 'non trovato')
        [autosuggest] => select c_caucont,des_cau,tipo_registro from CAUCONT
        [autosuggestheaders] => Codice causale,Descrizione causale,Tipo Registrazione
        [dialogbuttonaction] => OpenMyTablePicker(this, "CAUCONT", "c_caucont,des_cau,tipo_registro")
        [dialogbutton] => True
        [changedaction] => FieldChange(this, "CAUCONT", "c_caucont,des_cau,tipo_registro")
        [datachangedaction] => FieldDataCha��W�W���Whd�(,W����(hd�(
    )
    how can I solve this problem?

    thanks
    Fabio

  7. #7
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,739
    Hi Fabio,

    If you provide the code that you use we can investigate without having to retype everything in from your screenshot.
    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. #8
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,862
    Hi Barry, right..

    I've rewrite a little code based on the DB "test"
    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)
    
    m_metadata = "oFieldMD = metadata_decode(columnmetadata('" + rtrim(m_columnName) + "'))"
    exec(m_metadata)  				
    ? "read_oFieldMD"
    ? oFieldMD
    the result is:
    Code:
    m_command alter table event modify constraint employeeid metadata metadata_encode(oFieldMD)
    oFieldMD
    
    Object (refcnt=2)
    (
        [searchfield] => True
        [userselectablesearchfield] => True
        [datamappingget] => keylookup("EMLOYEES", "EMLOYEEID", "{}" ,rpad(firstname, 30, " ") + "  " + lastname, "not found")
        [autosuggest] => select id,firstname,lastname from employees
        [autosuggestheaders] => Employee,first name,last name
        [dialogbuttonaction] => OpenMyTablePicker(this, "employees", "id,firstname,lastname")
        [dialogbutton] => True
        [changedaction] => FieldChange(this, "employees", "id,firstname,lastname")
        [datachangedaction] => FieldDataChanged(this, "employees", "id,firstname,lastname")
    )
    read_oFieldMD
    
    Object (refcnt=2)
    (
        [searchfield] => True
        [userselectablesearchfield] => True
        [datamappingget] => keylookup("EMLOYEES", "EMLOYEEID", "{}" ,rpad(firstname, 30, " ") + "  " + lastname, "not found")
        [autosuggest] => select id,firstname,lastname from employees
        [autosuggestheaders] => Employee,first name,last name
        [dialogbuttonaction] => OpenMyTablePicker(this, "employees", "id,firstname,lastname")
        [dialogbutton] => True
        [changedaction] => FieldChange(this, "employees", "id,firstname,lastname")
        [datachangedaction] => FieldDataChanged(this, "employees", "id,firstname,lastname��W<��UWH��
    ��8��
    H��
    
    )
    if you play with the legth of the line
    eg:
    [autosuggestheaders] => Employee,first name,last name

    or

    [autosuggestheaders] => EmployeeID,first name,last name

    you can see the starting wrong char change the start position

    thanks
    Fabio

  9. #9
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,739
    Can you explain to me why you are using exec() to execute commands? I see no point in that at all. Have you tried you executing the command normally.
    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. #10
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,862
    Hi Barry,
    I use a exec beacuse I compose the command into a loop, for each table, for each field.. based on a setup reading other table.

    I've try also with:
    alter table event modify constraint employeeid metadata metadata_encode(oFieldMD)

    the problem is the lenght or oFieldMD

    I've also try to divide the command:

    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")'
    
    
    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)
    
    oFieldMD = object()
    
    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)
    
    m_metadata = "oFieldMD = metadata_decode(columnmetadata('" + rtrim(m_columnName) + "'))"
    exec(m_metadata)  				
    ? "read_oFieldMD"
    ? oFieldMD
    but the second "alter table" clean the previous..

    thanks
    Fabio

Page 1 of 3 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