Skip to main content

4GL's virtues (Part 2) Intergration with SQL

4GL makes code that would be difficult to write purely in SQL easy ,
plus it adds extra capabilities that would not be possible.

The following is a select loop that retrieves the result set
of a SQL query row by row and then manipulates it inside the loop.
Inside the loop you are free to use more SQL queries or 4GL code or mix them both!

For example, you can test conditions using if..then..else statements, assign values to host variables, load a tablefield or update tables in the database!

select   h_c_ylik = c_ylik,
         h_no_seir = no_seir,
         h_ps = ps,
         h_sxolia = sxolia
  from  mlax
  where end_axr='Ο'
  {
  if h_no_seir = '' then
     update mlax m
     set ps = ps + :h_ps
     where end_axr = ''  and
           no_seir = '' and
           c_ylik = :h_c_ylik;
     inquire_ingres (h_rowcount = rowcount,
                     h_errorno=errorno);
     if h_errorno!=0 then 
        rollback;
      callframe err_handler;
     endif;    
     if h_rowcount = 0 then
        insert into mlax
        (c_ylik,no_seir,end_axr,ps,sxolia)
        values
        (:h_c_ylik,'','',:h_ps,:h_sxolia);
        inquire_ingres (h_rowcount = rowcount,
                        h_errorno=errorno);
      if h_errorno!=0 then 
                   rollback;
           callframe err_handler;
               endif;
     endif;       
    else
       insert into mlaxr
       (c_ylik,no_seir,end_axr,ps,sxolia)
       values
       (:h_c_ylik,:h_no_seir,'',:h_ps,:h_sxolia);
       inquire_ingres (h_rowcount = rowcount,
                       h_errorno=errorno);
       if h_errorno!=0 then 
          rollback;
          callframe err_handler;
       endif;
    endif;
  };





There are many situations like this that make evident that 4GL is a rapid development tool

Comments

Popular posts from this blog

Open Source Is Not Just About Software

  It's about infrastructure as well, something that although not attracting the limelight, is as important as the open source software it hosts. Today the stewards of the largest open source registries in the world have issued an open letter demanding urgent reform in how open source infrastructure is funded, maintained, and operated.  https://www.i-programmer.info/news/136-open-source/18334-open-source-is-not-just-about-software.html

Europe Gets Its Own LLM

  EuroLLM is a fully open-sourced large language model made in Europe and built to support all twenty-four official EU languages. While several European states have separately produced their own LLMs, such as Greece's "Meltemi" or the recent offering from Switzerland "Apertus", there was no solution that catered for the languages of all 24 states belonging to the EU block. The time has come for this status to change with the appearance of EuroLLM, a foundational model that supports them all. https://www.i-programmer.info/news/105-artificial-intelligence/18448-europe-gets-its-own-llm.html

With MCP Docs Servers You'll Never Run Out Of Fresh Documentation

  MCP has changed the way you interact with your tools overnight. Now it targets your documentation. Wouldn't be great to have the latest and updated code samples and documentation of your favorite framework and libraries ready at your fingertips? Plus, be able to talk to it in natural language? https://www.i-programmer.info/news/90-tools/18248-with-mcp-docs-servers-youll-never-run-out-of-fresh-documentation-.html