Friday 17 November 2017

ESQL Functions

UUIDASCHAR
A function that returns a universally unique identifiers (UUID) as a CHARACTER value.

DECLARE uuid CHAR;

SET uuid =  UUIDASCHAR(source_blob_uuid);
SET uuid =  UUIDASCHAR;

If (source_blob_uuid) is not specified, UUIDASCHAR creates a UUID and returns it as a CHARACTER value. ed.
If (source_blob_uuid) is specified, UUIDASCHAR converts an existing BLOB UUID to the character form.

The result is NULL if a NULL parameter is supplied.

Friday 10 November 2017

ESQL Arrow Notation


The arrow notation (the greater than (>) and less than (<)
symbols) is used to indicate the direction of search and the index to be specified:

SET OutputRoot.DFDL.MyMessage.StringElement1[>] = 'This is the first occurrence of StringElement1';
SET OutputRoot.DFDL.MyMessage.StringElement1[<2] = 'This is the last but one occurrence of
 StringElement1';
SET OutputRoot.DFDL.MyMessage.StringElement1[<1] = 'This is the last occurrence of StringElement1';

You can refer to the last instance of a repeating field using the special [<] array index, and to instances relative to the last (for example, the second to last) as follows:

Field[>] indicates the first element. This is equivalent to Field[1].
Field[<] indicates the last element.
Field[<1] indicates the last element.
Field[<2] indicates the last but one element (the penultimate element).
You can also use the array index [>] to represent the first element, and elements relative to the first element in a similar way.

Friday 3 November 2017

Create an XMLNSC Tree in ESQL

CREATE LASTCHILD OF OutputRoot DOMAIN 'XMLNSC' NAME 'XMLNSC'; 
CREATE LASTCHILD OF OutputRoot.XMLNSC NAME 'FileData'; 
CREATE FIRSTCHILD OF OutputRoot.XMLNSC.FileData NAME 'BlobPayload' value InputRoot.BLOB.BLOB; 
CREATE LASTCHILD OF OutputRoot.XMLNSC.FileData NAME 'Filename' VALUE InputLocalEnvironment.File.Name;
CREATE LASTCHILD OF OutputRoot.XMLNSC.FileData NAME 'Filedir' VALUE InputLocalEnvironment.File.Directory;

The above code will create the following XML payload.

<FileData>
   <BlobPayload>XXX</BlobPayload>
   <Filename>YYY</Filename>
   <Filedir>ZZ</Filedir>
</FileData>