Regarding Extract Function

Hi,

I have  a local variable that holds data like this.

local!data:[id:122,month:12,numberofdays:2]; [id:123,month:1,numberofdays:4]; [id:124,month:12,numberofdays:6]; 

while extracting the "numberofdays"  from the above format  by using extract function like this

local!january:extract(local!data,"month:1,numberofdays:","]") 

I am getting this error.please check this image.

 

Your suggestions are valuable

 

Thanks and Regards,

Divya

  Discussion posts and replies are publicly visible

Parents
  • What type is local!data? Your code works well if it's a text variable. For instance, this returns 4:

    extract("[id:122,month:12,numberofdays:2]; [id:123,month:1,numberofdays:4]; [id:124,month:12,numberofdays:6];","month:1,numberofdays:","]")

    My guess is that local!data isn't a string but an array of either dictionaries or CDTs, in which case you'd be better off using something other than extract. Either a combination of index and wherecontains, or just using find would be better in that case.

    If you want to stick to using extract for whatever reason, just convert it to string before passing it to extract.
Reply
  • What type is local!data? Your code works well if it's a text variable. For instance, this returns 4:

    extract("[id:122,month:12,numberofdays:2]; [id:123,month:1,numberofdays:4]; [id:124,month:12,numberofdays:6];","month:1,numberofdays:","]")

    My guess is that local!data isn't a string but an array of either dictionaries or CDTs, in which case you'd be better off using something other than extract. Either a combination of index and wherecontains, or just using find would be better in that case.

    If you want to stick to using extract for whatever reason, just convert it to string before passing it to extract.
Children