Baanboard.com

Go Back   Baanboard.com

User login

Frontpage Sponsor

Main

Baanboard at LinkedIn


Poll
What actions do you take to ensure compliance with the sanction/embargo lists published by the EU and the US?
don't know what you are talking about
55%
we are scanning customers, suppliers and employees using own programs on a regular basis
12%
each delivery/purchase adress is checked immediately with own programs
2%
we are using third party software for this purpose
10%
we simply don't bother
20%
Total votes: 49

Reference Content

 
Database operations overview
By patvdv at 26 Feb 2008 - 21:57


Database operations overview

Use these functions for handling database input and output.

New features in BaanERP

In BaanERP, the functions db.curr(), db.first(), db.last(), db.next(), db.prev(),db.gt(), db.ge(), db.lt() and db.le() are implemented internally as SELECT statements. They are supported for backward compatibility only. In new applications, use queries instead.

In BaanERP, certain 4GL functions have Data Access Layer (DAL) equivalents. The following table lists these functions and their DAL equivalents.

 

4GL function DAL function

on.main.table()

with.object.set.do()

on.old.occ()

with.old.object.values.do()

set.input.error()

dal.set.error.message()
return(DALHOOKERROR)

skip.io()

dal.set.error.message()
return(DALHOOKERROR)

abort.io()

dal.set.error.message()
return(DALHOOKERROR)

db.update()

dal.update()

db.delete()

dal.destroy()

db.insert()

dal.new()

 

If a DAL exists for a particular table, it is preferable to use the DAL functions. The older functions access the database directly. When you make changes to the database with these functions, logic integrity checks programmed in the DAL are not executed. When you make changes to the database with the DAL functions, the relevant DAL hooks are executed automatically. This ensures the logic integrity of the database.

For further information about database handling in general and about the Data Access Layer, see Database Handling and Data Access Layer.

Table names and declarations

The naming syntax for tables, record buffers, and fields is:

 table tppmmmxxx        | table declaration
rcd.tppmmmxxx | record buffer of table
ppmmmxxx.ffffffff | logical field of table

where t stands for table,

pp is the package code, mmm is the module code, 
xxx is the table number, and 
ffffffff is a field name. 

If a table is used in a script, it must be declared with the statement:

table tppmmmxxx

Declaration of a table implies declaration of all its fields and its record buffer. These do not need to be declared separately.

There are no functions for opening or closing a table. A table is automatically opened the first time it is accessed. It is automatically closed when the program ends.

Error handling

In BaanERP, there are two main categories of errors: operating system errors and database system errors. For an explanation of the error codes, consult your operating system or database system documentation, or see Error codes.

Normally, a program can detect only four of the database errors: EDUPL, EENDFILE, ENOREC, and EROWCHANGED. When other errors occur, an error message is displayed on screen. However, you can use the predefined variable error.bypass to suppress error messages and enable a program to detect some or all errors instead. This variable can have the following values:

 

0

This is the default value. The program can detect the following database errors: EDUPL, EENDFILE, ENOREC, and EROWCHANGED.

Some fatal errors cause a direct abort of the application. When this happens, the message 'Cannot continue' is displayed.

If you attempt to lock a record or table that is already locked by another process, the program returns to the retry point automatically a number of times (by default, 10 times) before stopping the session and displaying the error message.

1

The program can detect all errors. So no database error messages are displayed on screen.

 

A program can detect database errors in the following ways:

  • Test return values. For example:

    if db.insert( tpctst999
    ) = EENDFILE then ...
  • Use db.error(). For example:

    db.insert( tpctst999
    )
    if db.error( tpctst999 ) = EENDFILE then

    ...
  • Use the predefined variable e. For example:

    db.insert( tpctst999 )

    if e = EENDFILE then ...

  • The ENDSELECT and SELECTEMPTY statements automatically detect the EENDFILE and ENOREC errors respectively.

Related topics


0
No votes yet


All times are GMT +2. The time now is 02:36.


©2001-2008 - Baanboard.com - Baanforums.com