Question: Are there any restrictions on the number of SQL commands?

Hello Global masters.

I am junior developer about Intersystems cache in South Korea.

I want to develop process management program on server.

My code :

TESTPID(IP)    ;
    #include %syPidtab
    Set Rset = ##class(%ResultSet).%New("%SYS.ProcessQuery:ListPids")
    d Rset.Execute()
    &sql(SELECT ClientIPAddress, Pid INTO :ClientIPAddress, :Pid
    FROM %SYS.ProcessQuery 
    WHERE ClientIPAddress = :IP)
    While Rset.Next() 
    {
​    i SQLCODE'=0 w !,"SQL Error "_SQLCODE continue ; 100 means process does not exist (halted)
    I Rset.GetData(1) = Pid D
    . w !,Rset.GetData(1)," ",ClientIPAddress," ",Pid
            //Set rs=$SYSTEM.Process.Terminate(Pid)
            //If rs'=1 {
            //    Write "Terminate Fialure "_" Pid "_Pid,!
            //}
            //Else {
            //    W "Sucess",!
        //    }
    //    }
    }
    d Rset.Close()
    Q

I made it and checked my process on portal and saw number of commands.

and it is over 1,000k.

 Are there any restrictions on the number of SQL commands?

I will use this code on server to manage process. if you guys have any good idea. please tell me about that

thank you for read my clumsy English

  • 0
  • 0
  • 173
  • 4
  • 1

Answers

Welcome to the Caché world!

There is NO limit on commands to be executed !
Don't worry about the number. SQL is consuming a lot of commands.
And Class Queries in %SYS by its nature may even consume more than standard SQL queries.
Just during a quick check of your code example I passed 700k.

A general hint on programming style:
Pls. try to avoid Dot Style and use curly brackets instead. 
This is a very old notation. Not as old as Hieroglyphs, but almost smiley

What I mean. instead of

  I Rset.GetData(1) = Pid D
    . w !,Rset.GetData(1)," ",ClientIPAddress," ",Pid
            //Set rs=$SYSTEM.Process.Terminate(Pid)
            //If rs'=1 {
            //    Write "Terminate Fialure "_" Pid "_Pid,!
            //}
            //Else {
            //    W "Sucess",!
        //    }
    //    }

use 

  I Rset.GetData(1) = Pid {
     w !,Rset.GetData(1)," ",ClientIPAddress," ",Pid
            //Set rs=$SYSTEM.Process.Terminate(Pid)
            //If rs'=1 {
            //    Write "Terminate Fialure "_" Pid "_Pid,!
            //}
            //Else {
            //    W "Sucess",!
        //    }
    //    }
    }

 This makes it much easier for the audience to follow your code, and it is actual coding style,
 

Hello Mr. Cemper 

Thank you for accepting the Cache world! and solved my worried. :)

Hahahaha Yes!! I thought so but my co-woker who work in my office more than me wrote this style ( all of my co-wokers)

so I am learning the style. :'( (Because I have to understand my system's process and code)

I will try curly brackets in 1years but I need time to understand Cache object and my system's process :)

So, I will use this site as much as I can so please help me :)

thank you

Minsu.

p.s And can you tell me how can I improve my skill about cache object ?

I studied web(JAVA with spring framework), mySQL, oracle etc. 

It's too new to me.

Thank you Serdtsev.

Recently I am studying with them, but only with it.

And I never see some project with Intersystems Cache except my systems

So, I really wondering about project architecture and and wanna see code style etc

You can see the code examples and coding style in the sources of namespaces '%SYS' and/or 'SAMPLES'.
But keep in mind that the style of classes written a long time ago differs significantly from style of classes written relatively recently, ex. [$ZT vs try/catch] or [%ResultSet vs %SQL.Statement]