Page 1 of 1

Creating row on ODBC Database

Posted: Mon Sep 28, 2009 12:09 pm
by haydn.chapman
Hi guys, I have started playing with an external Database and can't work out how to create a new row.

I can modify a row using this code without a problem.
code : Tbl_PBSH_BLEcho_CodeTables;
dict : Tbl_PBSH_BLEcho_CodeTablesDict;
begin
create dict;
code := dict.getAtKey ('codeCode');
code.codeDescription := 'codeDescription';
code.codeShortName := 'codeShortName';
code.update;

But when trying to create a new row there is no create method
code : Tbl_PBSH_BLEcho_CodeTables;
dict : Tbl_PBSH_BLEcho_CodeTablesDict;
begin
create dict;
//create code transient; //"these don't work"
//create code;
code.code := 'codeCodeNew';
code.codeDescription := 'codeDescription';
code.codeShortName := 'codeShortName';
code.update;

Does anyone know how this should be coded?

Cheers, H

Re: Creating row on ODBC Database

Posted: Mon Sep 28, 2009 12:16 pm
by BeeJay
It's been a while since I last did this, but from memory you use the createObject method on the external dictionary to create a new row in the desired table.

For example, using your sample code the quasi-code would look something like the following. (Note: I don't have access to an external database to test this currently..)

Code: Select all

vars code : Tbl_PBSH_BLEcho_CodeTables; dict : Tbl_PBSH_BLEcho_CodeTablesDict; begin create dict transient; code := dict.createObject; code.code := 'codeCodeNew'; code.codeDescription := 'codeDescription'; code.codeShortName := 'codeShortName'; code.update;
Cheers,
BeeJay.

Re: Creating row on ODBC Database

Posted: Mon Sep 28, 2009 1:03 pm
by haydn.chapman
Thanks BeeJay, That works a treat, H