How it works

Input and output

dbServ uses the HTTP protocol to get the parameters for the sql statements.

For the interpretation of the parameter dbServ uses a template which must be defined in its special way (for the new tags see the documentation). A template always holds a sql statement and a data output defination in the body tag. There are two methods:

The OUT method

When you have this statement
     select id_, name_ from adr
     order by 2
you have to put these fields here to fill them:
     <LI>id_ = ##1## name_ = ##2##
An other way of filling the field is to use the field name:
     <LI>id = ##id_## name = ##name_##
When you are using a form window for searching some datas you will get it from the client:
The server interprets this for the template 'suchlist.shtml' and changes the sql statement to:
     select id_, name_ from adr
     where name_ like 'Fischer'
     order by 2
So you will see only this rows.

The IN method

With INSERT, UPDATE, DELETE and sometimes also with SELECT statements it is useful to define the incoming parameters directly into the statement:

Dazu ein Beispiel:

     update adr
     set name_ = ##name##
     where id_ = ##id##
To seperate these two methods you have to call it as an 'in' file:
In SELECT calls this works with the UNION statements in an excellent way.

Some specials in sql statements

As you have seen in the first example the statement will only find rows with exact the names e.g. 'Fischer' but no entries like 'Fischer GmbH'.

To solute this problem you have to define your input tag in the form window in a special way:

     <INPUT TYPE="text" NAME="name_[%]"  size=30>
This will generate the statement
     select id_, name_ from adr
     where name_ like 'Fischer%'
     order by 2
If you use two '%' characters
     <INPUT TYPE="text" NAME="name_[%%]"  size=30>
you will get this statement back
     select id_, name_ from adr
     where name_ like '%Fischer%'
     order by 2
and will also see entries like 'Axel Fischer GmbH'.

Getting values

Some databases have problems by getting large values. Therefore you can specify the incoming values in your statement. Define a large text area as ASCII stream or a numeric value as character to get the values right into your database.


 update adr 
	set long_ = ##text_,a##, 
	    plz_ = ##plz_,c##
 where id_ = ##id_##
No blanks please in this definition.

Stored procedures

The sql statements must be defined in the way of your specific database like sysdate, now(),data() brings back the date in different databases. Interactions with stored procedures are working in a different way. To keep it simple and working with all databases in this case the Java method of prodedure call is used. An example:

call myschema.my_proc( ##test##, ##4,o##, ##12,o##)
calls a procedure 'my_proc', gives the values of 'test' with it and gets back a numeric and a string value (this definition follows the Java typ definition). The numeric return value must be '0' if the procedure works well. The string value contains the error message. The procedure could be like this:
procedure my_proc (
	test    in  varchar,
	errorn  out number,
	errort  out varchar
) begin

errorn = 0;
errort = 'Ok';

update adr
    set text = 'test';
   errorn = -1;
   errort = 'error';

When the return value is not zero the error message is shown otherwise the text inside the <dbdata> tags. If there is an error outside the procedure the alternate text (<dbdata txt="...">) is shown.

Function calls inside a sql statement are handled like before.


To handle calls from a specified host you can use the transaction numbers dbtan. You have to initialize it at the beginning and move it to every following scripts. The life time of a dbtan is set in the ini file.

The counter

In dbServ you find a simple counter. To use it you have to design a database named 'count' before (see description in the directory db). To get an entry in this table you have two ways:

  • a call via an image:
        <IMG SRC="http://localhost:4444/count?index" WIDTH="1" HEIGHT="1">
    Behind 'count?' you may define every text you want to write into the table. You get back a transparent image.

  • a call via a link:
        <A HREF="http://localhost:4444/count?target=http://newhost/index.html"
        target="_new">new Location</A>
    Here you have to define a target for the redirection. The link is stored to the database.

    To use the counter you have some parameters in dbServ.ini.

    The cache

    To get the best performance you can use the cache mechanism. It only works with the 'OUT' method. After the first call a page is in the cache memory. Please set the life time for the cache in the ini file. If you don't want it for special pages you have to define the 'nocache' tag in the document header.

  • Axel Fischer, afischer@dbServ.de