Baanboard.com

Go Back   Baanboard.com > Forum > Baan Quick Support: Functional & Technical > Tools Development

User login

Frontpage Sponsor

Main

Poll
How big is your Baan-DB (just Data AND Indexes)
0 - 200 GB
18%
200 - 500 GB
29%
500 - 800 GB
3%
800 - 1200 GB
7%
1200 - 1500 GB
8%
1500 - 2000 GB
12%
> 2000 GB
23%
Total votes: 73

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 12th September 2019, 09:23
RavCOder's Avatar
RavCOder RavCOder is offline
Member
 
Join Date: Jul 2019
Posts: 48
RavCOder is on a distinguished road
Baan: 10.3 - DB: SQL Server - OS: Windows
Doubts about insert record in a DAL
Baan: Other/Unknown
C/S: None/Unknown

Hi,

I have a doubt about insert a record in table with DAL: I see in the programmer's guide that there is a method call db.insert(), but it's not correct for DAL.
What is the right procedure to insert a record in a table in a DAL?

Regards,

RavCoder
Reply With Quote
  #2  
Old 12th September 2019, 11:28
bdittmar's Avatar
bdittmar bdittmar is offline
Guru
 
Join Date: Apr 2002
Location: Germany, 50.584097,8.544078
Posts: 1,800
bdittmar will become famous soon enough
Baan: 2.2/3.1/4c4/LN6.1 FP6/FP9/HiDox Tools 10.7 - DB: tbase, ms-sql7, oracle10gV1, 11g - OS: HP-UX, W2K3, SLES
DAL save ....

Code:
dal.save.object()
Syntax:

function long dal.save.object  (string tbl.name [, long error.flag])

Description

Saves a record of the given table. In case a dal.new.object() or a dal.copy.object() was done, the record is inserted in the database. In case a dal.change.object() was done, the record is updated in the database.

In case DAL2 Field dependencies have been defined in the DAL, this function takes care that dependent fields will be triggered in the right order so that they can update themselves.

Note that this is done based on the values of the fields that have been set by calling dal.set.field()

Before the record is saved all (changed) fields will be validated.

The sequence of the actions is as follows:

Table level permission is checked.
For all fields set, the fieldname.make.valid() is executed, e.g. to perform rounding of data.
All dependent fields are triggered to update themselves.
Record level permission is checked.
The actual save (insert or update) is done.

Arguments

string tbl.name the table name of the DAL.
 
[long error.flag ]  
 
Return values

0 Record is saved 
DALHOOKERROR One of the hooks blocked the save action 
DALDBERROR A domain or reference error occurred (only in Integration context (e.g. via a BOL)) 
DALNOSETPERM No table level permission 
DALNOOBJPERM No record level permission 
>0 The error code of the db.insert() or db.update() function 
 
Context

This function can be used in all script types.

Hooks called

before.open.object.set() if this is the first call to the DAL
after.new.object() in case of a new record
after.change.object() in case of an existing record
for all fields set, the fieldname.make.valid() hook is executed
for each dependent field:

field.update()
method.is.allowed()
for each (DAL_NEW) / each changed (DAL_UPDATE) field:

one or more field hooks
before.save.object()
after.save.object()
Error Handling

In case a database error occurs (a return value greater than 0), then this function will set an error message. E.g. in case a record is modified by another user then an error message is set.

Note 
When working with DAL2 DALs, it is advised to use dal.save.object() instead of dal.new() or dal.update(). Only then field dependencies are taken into account.

In case the DAL does not have field dependencies defined, or if you don't want to set defaults based on field dependencies, you can also use dal.new() or dal.update(). These functions are faster than dal.save.object().
Regards
__________________
//Bernd
Reply With Quote
  #3  
Old 12th September 2019, 11:52
RavCOder's Avatar
RavCOder RavCOder is offline
Member
 
Join Date: Jul 2019
Posts: 48
RavCOder is on a distinguished road
Baan: 10.3 - DB: SQL Server - OS: Windows
Hi,
Thanks for your help.
I created a DAL but in the DAL script I have two functions : before.open.object.set() and before.save.object (long type). I don't understand what I have to put into.

Regards,
RavCoder
Reply With Quote
Sponsored Links
  #4  
Old 12th September 2019, 12:36
RavCOder's Avatar
RavCOder RavCOder is offline
Member
 
Join Date: Jul 2019
Posts: 48
RavCOder is on a distinguished road
Baan: 10.3 - DB: SQL Server - OS: Windows
Update

I understand I set fields in the function before.open.object.set().
Now I have to call this DAL in a print session that I have created (tdsls4900m000).
How can I do?
Reply With Quote
  #5  
Old 12th September 2019, 15:11
andreas.toepper andreas.toepper is offline
Senior Member
 
Join Date: Jun 2004
Posts: 168
andreas.toepper is on a distinguished road
Baan: Baan4, LN6.1 - DB: MSSQL - OS: Linux&Windows
You don't need to "call" a DAL. (It’s like a library, but the functions declared are executed automatically.)
The functions you see when creating a new DAL script are called “hooks”. Hooks are not called manually in a function. They are called automatically (“in the background”) when you update or create a dataset of a given table.
So, if you want to update a dataset in a print session (like mark a set as printed), you need to modify the dataset. To invoke DAL hooks, you need to use the correct standard functions:
Code:
|An example:
db.retry.point()
dal.change.object("tiipd001")
dal.set.field("tiipd001.oltm", new.value)
dal.save.object("tiipd001")
commit.transaction()
This will call the defined hooks of the table on runtime.
Reply With Quote
  #6  
Old 12th September 2019, 15:46
RavCOder's Avatar
RavCOder RavCOder is offline
Member
 
Join Date: Jul 2019
Posts: 48
RavCOder is on a distinguished road
Baan: 10.3 - DB: SQL Server - OS: Windows
Ok I have already entered those things and I put in the session script program the DAL but if I try to start the session it doesn't start anything (this doesn't show it to me).
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ue.before.after.destroy.object pralash Tools Development 8 6th August 2018 13:37
Unable to Insert Record in MS Sql Database from ION vik.patil ION 2 24th May 2018 15:58
AFS - insert record in whinh5120m100 eric.dizon AFS/DDC/OLE: Function servers 13 31st October 2016 15:14
Inserting an Inverse Record from the same table using DAL eric.dizon Tools Development 1 23rd January 2014 03:32
how to insert record in type3 form via AFS??? alibaba AFS/DDC/OLE: Function servers 5 17th September 2004 04:19


All times are GMT +2. The time now is 14:05.


©2001-2018 - Baanboard.com - Baanforums.com