pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Billy G. Allie <Bill.Allie@mug.org>
To: Chris Newman <chris@lightwood.demon.co.uk>
Cc: pgsql-interfaces@hub.org
Subject: Re: [INTERFACES] Character mode forms designer
Date: Sat, 11 Jul 1998 00:23:18 -0400
Message-ID: <199807110423.AAA05422@bgalli.mug.org> (raw)
In-Reply-To: <199807102257.XAA14169@lightwood.demon.co.uk>

I create character mode applications using a tool available on System 5 
Release 4 based UNIXs (UnixWare, Solaris and others) call FMLI [ Form and Menu 
Language Interpreter ].  Communication with the database is through a program 
I wrote that is similar to psql, but is designed to function as a co-process 
with FMLI.
The program (I call 'getsql') receives SQL queries via STDIN and sends the 
results to STDOUT with each field delimited by a TAB or, optionally, any other 
character.  After all the rows have been output, a end of rows sentinal is 
output to let FMLI that there are no more rows.  Also, special care is taken 
to ensure that the output buffers are flushed.

I have also used this program to allow programs such as 'awk' and 'ksh' to 
interacte with postgreSQL by running getsql with STDIN and STDOUT attached to 
named pipes.

The following shows how I connect to postgreSQL with FMLI.

    banner="CMS Version 2.1"
    title="WLECOME TO"
    columns = 35
    rows=7
    text="
     The Choir Management System

     Copyright 1995
     Billy G. Allie
     All Rights Reserved."
    slk_layout=4-4
    # Create the pipe to the database.
    `cocreate -i PGSQL -e '*** END-OF-ROWS ***' getsql -p -D choir | message`

The following shows how I use a form to update a table in postgreSQL.

    form="Add Entry"
    done=`cosend -n PGSQL "insert into choir values (nextval('id'), ";
	    if [ "X$F1" = "X" ]; 
	        then cosend -n PGSQL "NULL, ";
	        else cosend -n PGSQL "$F1, ";
	    fi;
	    cosend PGSQL "'$F3', '$F2', '$mvalue', '$F5');" | message`update
    Name="Folder No:"
    nrow=1
    ncol=1
    frow=1
    fcol=12
    flen=5
    rows=1
    columns=5
    valid=`[ "X$F1" = "X" ] ||
	    cosend PGSQL "select val1_id($F1);"`
    invalidmsg="Folder number $F1 already exists!"
    fieldmsg="Enter a unique number."

    Name="Last Name:"
    nrow=2
    ncol=1
    frow=2
    fcol=12
    flen=35
    rows=1
    columns=25
    scroll
    fieldmsg="Enter the last name of the new member."

    [ remaining text removed ... ]

In the preceeding example, $F1 is the contents of Field #1 and val1_id() is a 
SQL function that returns the string "TRUE" is $F1 already exists as an ID in 
the database or "FALSE" if it does not.

All in all, if you have a need to do character mode applications with 
postgreSQL and your system has FMLI, I would recommend using it.  Also, if 
there is interest, I will send 'getsql' to the contrib area on the postgreSQL 
site.

-- 
____       | Billy G. Allie    | Domain....: Bill.Allie@mug.org
|  /|      | 7436 Hartwell     | Compuserve: 76337,2061
|-/-|----- | Dearborn, MI 48126| MSN.......: B_G_Allie@email.msn.com
|/  |LLIE  | (313) 582-1540    | 





view thread (5+ messages)  latest in thread

Message-ID: <199807110423.AAA05422@bgalli.mug.org>
Permalink:  ../199807110423.AAA05422@bgalli.mug.org/
Also on:    postgresql.org/message-id/199807110423.AAA05422@bgalli.mug.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: Bill.Allie@mug.org, chris@lightwood.demon.co.uk, pgsql-interfaces@hub.org
  Subject: Re: [INTERFACES] Character mode forms designer
  In-Reply-To: <199807110423.AAA05422@bgalli.mug.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox