Creating row on ODBC Database

Forums for specific tips, techniques and example code
User avatar
haydn.chapman
Posts: 2
Joined: Mon Sep 28, 2009 11:18 am
Location: Glen Waverley. Aust.

Creating row on ODBC Database

Postby haydn.chapman » Mon Sep 28, 2009 12:09 pm

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

User avatar
BeeJay
Posts: 312
Joined: Tue Jun 30, 2009 2:42 pm
Location: Christchurch, NZ

Re: Creating row on ODBC Database

Postby BeeJay » Mon Sep 28, 2009 12:16 pm

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.

User avatar
haydn.chapman
Posts: 2
Joined: Mon Sep 28, 2009 11:18 am
Location: Glen Waverley. Aust.

Re: Creating row on ODBC Database

Postby haydn.chapman » Mon Sep 28, 2009 1:03 pm

Thanks BeeJay, That works a treat, H


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 7 guests

cron