Mimer SQL Data Provider help
Basic insert
Mimer SQL Data Provider > Overview > Working with user defined types > Basic insert

When storing data in the database user defined types must be passed to the database server. This can be done with the  MimerUserDefinedType class. Consider the following SQL types and table:

create type streetno as integer;
create type address as (street varchar(30), streetnumber streetno);
create table person(personid int, home address);

And the following code:

MimerConnection conn = new MimerConnection(connectionString);
try {
MimerCommand comm1 = new MimerCommand("insert into person(personid, home) values(?, ?)", conn);
// We add parameters for the two columns 
MimerParameter par1 = new MimerParameter();
     MimerParameter par2 = new MimerParameter();
     par1.Value = -4;   // Personid
     par2.Value = new MimerUserDefinedType(new object[] { "Arlington road", 10 }); // street, streetnumber

In the example the data is inserted into the person table. Each question mark in the SQL statement represents one parameter passed from the application by using a MimerParameter. The value of the column home is populated by instantiating a MimerUserDefinedType with the two values. This can also be done as follows:

     MimerUserDefinedType home = new MimerUserDefinedType(2);
     home[0] =
"Arlington road";    // streetname
     home[1] = 10;                       // streetnumber

     par2.Value = home;

When instantiating the user defined type a constructor is used where the number of attributes of the user defined type is specified (in this case: two).

See Also

Basic select
Selecting user defined type into application class
Inserting user defined type from application class