ESQL

1 program Added 2026-02-27T10:00:00Z Agent: claude-codeModel: claude-sonnet-4-6WebSearch: enabled Evidence Report issue View issues
Aliases: Extended SQL, IBM Message Broker ESQL
Provenance: commit 7c07921613 · authored 2026-02-27T20:23:28+01:00 · agent claude-code · model claude-sonnet-4-6

Sources mentioning this language

1 source · not in taxonomy (canonical name didn't match any upstream)
LLM (this repo) · 1

Related languages

Extended ML (0.26)EFL (0.21)EXAPT (0.20)Extended Pascal (0.20)EBF (0.20)

LLM-contributed programs

String Utility Functions

Provenance: commit 7c07921613 · authored 2026-02-27T20:23:28+01:00 · agent claude-code · model claude-sonnet-4-6 · WebSearch enabled
code.esql · added: 2026-02-27T10:00:00Z
 CREATE FUNCTION padding(IN string CHAR, IN length1 INT ) RETURNS CHAR
   -- This Function will pad a string to a specific length. There are 2 cases:
   -- String too short: add spaces:   'abcd'         --> 'abcd  '
   -- String too long: truncate:      'abcdefghijkl'    --> 'abcdef'
   BEGIN
      DECLARE padding CHAR;
      IF LENGTH( string ) <= length1 THEN         -- 'Batch', 10 --> 'Batch     '
         SET padding = LEFT( string || SPACE( 1000 ), length1 );
      ELSE
         SET padding = string;       -- 'ItemDescription', 10 --> 'ItemDescri'
      END IF;
      RETURN padding;
   END;

   CREATE FUNCTION crlf() RETURNS CHAR   BEGIN
      RETURN CAST( X'0D0A' AS CHAR CCSID 819 );   -- Carriage Return, Line Feed (Linux&Windows)
   END;
   CREATE FUNCTION lf() RETURNS CHAR BEGIN
      RETURN CAST( X'0A' AS CHAR CCSID 819 );      -- Line Feed (Linux only)
   END;

   CREATE FUNCTION crlfCcsidEncoding(IN ccsid INT, IN encoding INT) RETURNS CHAR
   BEGIN
      -- For Linux&Windows: '0D0A',
      -- '0D' for Windows only
      RETURN CAST( X'0D0A' AS CHAR CCSID ccsid ENCODING encoding );
   END;

   CREATE FUNCTION selectSubField(sourceString CHAR, delimiter CHAR, targetStringPosition INT) RETURNS CHAR
   -- This function returns a substring at parameter position TargetStringPosition within the
   -- passed parameter SourceString.  An example of use might be:
   -- selectSubField(MySourceField,' ',2) which will select the second subfield from the
   -- field MySourceField delimited by a blank.  If MySourceField has the value
   -- "First Second Third" the function will return the value "Second"
   BEGIN
      DECLARE delimiterPosition INT;
      DECLARE currentFieldPosition INT 1;
      DECLARE startNewString INT 1;
      DECLARE workingSource CHAR sourceString;
      SET delimiterPosition = POSITION( delimiter IN sourceString );
      WHILE currentFieldPosition < targetStringPosition AND delimiterPosition <> 0 DO
         SET startNewString = delimiterPosition + LENGTH( delimiter );
         SET workingSource = SUBSTRING( workingSource FROM startNewString );
         SET delimiterPosition = POSITION( delimiter IN workingSource );
         SET currentFieldPosition = currentFieldPosition + 1;
      END WHILE;
      IF currentFieldPosition < targetStringPosition THEN
         SET workingSource = NULL;
      ELSEIF delimiterPosition > 0 THEN
         -- Remove anything following the delimiter from the string
         SET workingSource = SUBSTRING( workingSource FROM 1 FOR delimiterPosition - 1 );
      END  IF;
      RETURN workingSource;
   END;

   CREATE FUNCTION countCharInChar(IN char1 CHAR, IN char2 CHAR) RETURNS INT
   -- Returns the number of occurences of char1 in char2
   -- E.g.:     ('A', 'ABCDABCDABCD')    --> 3
   --           ('ABC', 'ABCDABCD')    --> 2
   --         ...
   BEGIN
      DECLARE count INT 0;
      IF char1 IS NOT NULL AND char2 IS NOT NULL THEN
         DECLARE position1 INT POSITION( char1 IN char2 REPEAT count+1 );
         WHILE position1 <> 0 DO
            SET count = count + 1;
            SET position1 = POSITION( char1 IN char2 REPEAT count+1 );
         END WHILE;
      END IF;
      RETURN count;
   END;

Contribute — propose a file extension

Tell us where to find evidence about ESQL (mapped to pl/esql). A reference URL is required; at least one of extension or program code must be provided too. A maintainer reviews each submission via a draft PR before anything lands.
Optional: attach a program from that URL
If the reference URL points at a single source file you'd like to add as an example program, paste it below. The workflow will write it under languages/ESQL/programs/<sha>/. Keep under ~200 lines.
(or open the pre-filled issue directly)
← Espruino Essence →