At first sight, the sequence of your values matches the sequence of your properties.

transforming your input from 

fecha1|nombreProfesional1|centro1|secuencia1|hora1|bloque1|acto1|lug....

to

'fecha1','nombreProfesional1','centro1','secuencia1','hora1','bloque1','acto1','lug....

in an exercise for beginners.
Next  I would use SQL to insert the record

INSERT  INTO  
EsquemasDatos_DragoAP.ConsultarCitas (fecha1,nombreProfesional1,centro1,secuencia1,hora1,bloque1,acto1,lug....)

VALUES ('fecha1','nombreProfesional1','centro1','secuencia1','hora1','bloque1','acto1','lug....)
 

An that's it!

Listing of the columns is only necessary if you distrust the class compiler
or if you want to prevent problems with later sequence changes in the class definition.
In any case, it should reflect the sequence of your data input, independent of sequence in class.

I'd suggest to use one of the ResultSet classes and avoid embedded SQL.
The whole SQL statement can be composed as a single string  and then processed .

more on INSERT and variations

 

The Native API connects to IRIS by starting a background JOB
In namespace %SYS you can have access to every fresh started  job.
The routine name is %ZSTART.mac.
You have to create it if not existing yet or to adapt it.
My example is just reduced to your case.
Writing a log in global ^%CHECK is just for testing.
I used Native API and also Studio for testing.

%ZSTART ; User startup routine.
#; cannot be invoked directly
    quit SYSTEM ;
#; InterSystems IRIS starting
    quit
JOB ;
#; JOB'd process begins
    new ipaddr,halt
    set ipaddr=$system.Process.ClientIPAddress()
    set halt=(ipaddr="172.17.0.2")
    set ^%CHECK($I(^%CHECK))=$lb(halt,$job,$ZDT($zts,3,,3),ipaddr,$znspace,$io)
#; add here all checking for allowed IP Address
#; halt if access is not allowed
    if halt halt
    quit
CALLIN ;
#; connect over CALLIN
    quit
LOGIN ;
    quit

This is a test result with Studio and 2 Native API. One  blocked and the other allowed.

^%CHECK=5
^%CHECK(1)=$lb(0,"15044","2020-09-03 16:22:54.667","192.168.0.9","USER","|TRM|:|15044")
^%CHECK(2)=$lb(0,"17100","2020-09-03 16:23:41.247","192.168.0.9","%SYS","|TCP|51773|17100")
^%CHECK(3)=$lb(0,"9880","2020-09-03 16:24:20.612","192.168.0.9","%SYS","|TCP|51773|9880")
^%CHECK(4)=$lb(1,"19544","2020-09-03 16:24:41.925","172.17.0.2","%SYS","|TCP|51773|19544")
^%CHECK(5)=$lb(0,"3268","2020-09-03 16:25:27.691","172.17.0.3","%SYS","|TCP|51773|3268") 

let's have  your  binary  input in variable data 

JAVA                                  ObjectScript
byte[] data = new byte[1024];                                            ;
Bytebuf buf  = new ByteBuf(data)      set buf=data              ; make your work copy  
byte type = buf.read()                set type=$extract(buf)    ; if type = character 
                                      set type=$ascii(buf)      ; if type = binary
int len = buf.ReadInt()               set len=$zlascii($extract(buf,2,5))           ; if order low->high
                                      set len=$zlascii($reverse($extract(buf,2,5))) ; li order high->low
 
byte[] bodyBuff = new byte[len]       
buf.Read(bodyBuff)                    
String str = new String(strBody)      set str=$extract(buf,6,*) ; take rest of buf


from the description there are 2 open points:

  • is type a binary value or a character   
  • for length it could be
  • -         low byte first   so 515  => x/02 03 00 00  ;  default
  • -  or high byte first  so  515 => x/00 00 02 03   ;  need to reverse order

therefore I have added both variants

This is a late reply and the content my explain why.
There is a set of available classes and methods to fulfill your requirements.
Though you have to be careful as there are side conditions to be considered that require special attention.

You have to wrap these class methods in some routine or class and then plug it into the standard task manager.

From your question I understand 4 different tasks:

  • Compact globals in a database   (=force global to make better use of data blocks) ##Class(SYS.Database). Compact(..............)
  • Return unused space for a database (=truncate DB) ##class(SYS.Database).ReturnUnusedSpace(........)
  • Defragment a database (=make Blocks contiguous)  ##class(SYS.Database).Defragment(........) ##class(SYS.Database.BackgroundDefragment).Start(........)  ;;[not so useful for task manager]
  • Compact free space in a database (=really returns disk space) ##class(SYS.Database).FileCompact.(........) ##class(SYS.Database.BackgroundFileCompact).Start(........)  ;;[not so useful for task manager]

The official documetation also has some examples.
My personal favorite is routine DATABASE.int in namespace %SYS
It covers all these functions for interactive use and illustrates also all possible requirements and limits in detail.
The labels you should check are:
COMPACT()
DBTruncat()
DEFRAG()
FileCompact()

This might also explain why there is not just a method out of the box.

Dear @Sylvain Guilbaud 
As this is the oldest unanswered question I found I'll give it a try:
One of the most attractive features of DeepSee is its close link to the Caché (now IRIS) database using 
the DSTIME mechanics for updates.
With an external linked DB you don't have this "built-in" support.
Other DB's have similar features but including them requires some "art work".
And that doesn't seem to happen so often.

On the other hand the question was never expired nor closed.
It might happen that new results (almost 5 years later) show up now as it moves to the front.

J'espère que tu vas bien et en bonne santé!  yes
Salutations de Vienne,

Robert (toujours actif) wink

@Oliver Wilms 
#1) make  sure your ECP Server is willing to accept ECP AplicationServers: 

#2) on your Application Server define your Data Server

%SYS>set Name="MainServer"
%SYS>set Properties("Address")="127.0.0.1" 
%SYS>set Properties("Port")=1972
%SYS>s Status=##Class(Config.ECPServers).Create(Name,.Properties)
%SYS>zw Status
Status=1

see docs: class Config.ECPServers

#3) connect to your Data Server

%SYS>set ecpstate=##class(SYS.ECP).GetServerConnState(Name)
%SYS>zw ecpstate
ecpstate=1      ;; Not Connected
%SYS>set tSC=##class(SYS.ECP).ServerAction(Name,3)   ;; 3 -  Change to Normal
 %SYS>zw tSC
tSC=1
%SYS>set ecpstate3=##CLASS(SYS.ECP).GetServerConnState(Name)
%SYS>ZW ecpstate3
ecpstate3=5   ;; 5 - Normal

see docs: class SYS.ECP

#4) now in SMP:

make sure your / is really just a / and not surrounded by some nonprinting stuff
do a check e.g on https://www.xmlvalidation.com/ 

(ending at line 1 character 183)  could also mean you are missing
<?xml version="1.0" encoding="UTF-8"?>  as first line.

next possible trap: your xml is not encode in UTF-8  (but in some other [windows?]
code after modification with Notepad.exe or similar.

A test with 102,794 rows confirmed the performance difference.
#1)  on index xitm
Rows selected: 61320 Global Ref: 488,861 Commands: 5.244,585 Cached Query: %sqlcq.CACHE.cls16

#2) on index ycol
Rows selected: 61320 Global-Ref: 133,812 Commands: 3.909,205 Cached Query: %sqlcq.CACHE.cls13 

Reducing the query output to SELECT COUNT(ID) makes the difference even more dramatic
#1) Performance: 0.457 sec  Global-Ref: 574,193 Commands: 2.138,695
#2) Performance: 0.082 sec  Global-Ref: 205,973 Commands:   724,288

This might make your task easier

^EDLIST("DIAG", "X123")=" internal health"
^EDLIST("DIAG", "X234")=" External health"
. . . 

So you will need this Function / Method to Update your segment:
The class is just a container for the method

Class ED.Update [abstract] {
/// assumption you have the full Segment already in a string
ClassMethod AddDescription(ByRef segment as %String) as %Boolean
{  set code=$piece(segment,"^")
   if $data(^EDLIST("DIAG",code),value)#10 set $piece(segment,"^",2)=value
        quit $test }
}

now all you have to do

/// ...  get the segment from DG1
    if  ##class(ED.Update).AddDescription(.segment)  {
          /// .....Update the segment in DG1
   }

If the code is not defined you just skip the update

The most simple way  is to redirect your I/O to a TCPport where another job provides you with the expected input:
#1) have a listener:  (any port, I use 7777 for the example)

set listen="|TCP|7777"
open listen:(:7777):0  if '$test write "port busy",! quit
use listen read request
while request'="/*  your end condition */" {
    /* match request for correct reply */
    write reply,!

        }
close listen
     

#2) at your report side all you have to do is

set server =  "|TCP|7777"
open server:("127.0.0.1":7777):0
if '$test write "port busy",! /* termination sequence */ quit
use server

/* launch your program */

here the listener sits on the same machine but it could be any reachable IP-address.
the only critical point is if your program fiddles around changing $IO

 

it is not possible within the same class as you break the uniqueness of names.

But if you have class A1 with Method MX(....)  
you can create class A2 Extends A1 and overload Method MX as you like or need.
You still can call MX of class A1 from class A2 using ##super()

All with the assumption that neither class A1 nor Method MX is FINAL