bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Structured Variables - a DB use case


From: Hans-Peter Sorge
Subject: Structured Variables - a DB use case
Date: Wed, 16 Dec 2020 13:28:49 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0

Hi

I have created a DB example exploring structured variables:

⍝ setting the connect parameters
MY_DB.DB_CONNECT.DB_NAME←'db_name'
MY_DB.DB_CONNECT.DB_HOST←'172.0.0.1'
MY_DB.DB_CONNECT.DB_USER←'me'
MY_DB.DB_CONNECT.DB_PASSWD←'t0tal53(rt'

⍝ Do the connect. Use root name only. 
BD_CONNECT.DB_HNDL←SQL_CON BD_CONNECT


[0]   H← SQL_CON C; ∆SQL; q; c; con_str
[1]   q←"'" ⋄ c←"', '"
[2]   ∆SQL←'' ⍝ testing only.  Replace ∆SQL by SQL  to execute the command.
[3]   con_str ← ∊'CONNECT(' q C.DB_NAME c C.DB_HOST c C.DB_USER c C.DB_PASSWD q ')'
[4]   H←∆SQL con_str
    ∇

⍝ test internals
      SQL_CON MY_DB.BD_CONNECT
  CONNECT('db_name', '172.0.0.1', 'me', 't0tal53(rt')


⍝ my be ....
MY_DB.TABLE_NAME.SELECT ← 'SELECT * FROM TABLE WHERE KEY = ''val'' '
result ← SQL MY_DB.TABLE_NAME.SELECT

In this case the variable-root-name MY_DB serves as container for all variables being used in conjunction with DB named MY_DB.


Best Regards
Hans-Peter


reply via email to

[Prev in Thread] Current Thread [Next in Thread]