AW: create and insert

[prev] [thread] [next] [Date index for 2005/01/20]

From: Hartmaier Alexander
Subject: AW: create and insert
Date: 16:45 on 20 Jan 2005
You missed the point!
Look at my code snips. I have defined the names of the sequences.
But when I load my data with the ->search_from_scan method the objects do=
esn't get a primary key and is also not inserted into the db (what is ok =
cause I need it only temporary in memory).

-Alex


-----Urspr=FCngliche Nachricht-----
Von: Dana Hudes [mailto:dhudes@xxxxx.xxx]=20
Gesendet: Donnerstag, 20. Januar 2005 17:41
An: Hartmaier Alexander
Betreff: Re: create and insert

a relational database , while you can do it, its not really the thing
for this data. What you have is a time-series database.
RRDtool lives for this.

As for your existing relational database question you have to
have a prinary key defined in your table class. without keys,
you haven't relation. You must put the sequence() in your class.
See this snippet from the documentation which you apparently neglected
to read carefully:
   sequence / auto_increment

           __PACKAGE__->sequence($sequence_name);

           $sequence_name =3D Class->sequence;
           $sequence_name =3D $obj->sequence;

   If you are using a database which supports sequences and
   you want to use a sequence to automatically supply values
   for the primary key of a table, then you should declare
   this using the sequence() method:

   Class::DBI will use the sequence to generate a primary key
   value when objects are created without one.

   *NOTE* This method does not work for Oracle. However,
   Class::DBI::Oracle (which can be downloaded separately
   from CPAN) provides a suitable replacement sequence()
   method.

so..go forth and read carefully the Class::DBI::Oracle documentation.

On Thu, 20 Jan 2005, Hartmaier Alexander wrote:

> I scan for new interfaces on my devices via snmp automatically and inse=
rt them in a 'scaninterface' table.
> When somebody selects a new interface on the webgui it gets loaded from=
 the 'scaninterface' table with a this call:
> ($obj_new_interface) =3D NAC::Interface->search_from_scan($newport);
>=20
> This is the definition im my NAC::Interface class:
> __PACKAGE__->set_sql('from_scan', 'SELECT fk_device, port, name, snmpid=
, snmpid_rtt, type, speed, mtu, ipaddr, ipnetmask, description FROM nacad=
m.scaninterface WHERE port =3D ?');
>=20
> I have also defined the sequence of my oracle db:
> __PACKAGE__->sequence('seq_interface');
> I is not needed that Class::DBI gets a value from the sequence, because=
 an oracle trigger is defined for every table to do this.
>=20
> -Alex
>=20
>=20
> -----Urspr=FCngliche Nachricht-----
> Von: Dana Hudes [mailto:dhudes@xxxxxx.xxxx]=20
> Gesendet: Donnerstag, 20. Januar 2005 17:06
> An: Hartmaier Alexander
> Cc: Class:DBI maillist
> Betreff: Re: create and insert
>=20
>=20
>=20
> On Thu, 20 Jan 2005, Hartmaier Alexander wrote:
> >=20
> > -          How can I create an object in memory without a primary key=

> > and insert it if needed (or not)? (partially answered by my second
> > question...)
>=20
> Unless your primary key is a SERIAL, this makes no sense.
> How can you have a record with no key, unless its a SERIAL therefore=20=

> auto-created?
>=20
> *"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*=
"*"*"*
> Hinweis: Dieses E-mail kann vertrauliche und gesch=FCtzte Informationen=
 enthalten.
> Sollten Sie nicht der beabsichtigte Empf=E4nger sein, verst=E4ndigen Si=
e bitte den Absender und l=F6schen Sie dieses E-mail dann sofort.
>=20
> Notice: This e-mail contains information that is confidential and may b=
e privileged.
> If you are not the intended recipient, please notify the sender and the=
n delete this e-mail immediately.
> *"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*=
"*"*"*
>=20

*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*=
"*"*
Hinweis: Dieses E-mail kann vertrauliche und gesch=FCtzte Informationen e=
nthalten.
Sollten Sie nicht der beabsichtigte Empf=E4nger sein, verst=E4ndigen Sie =
bitte den Absender und l=F6schen Sie dieses E-mail dann sofort.

Notice: This e-mail contains information that is confidential and may be =
privileged.
If you are not the intended recipient, please notify the sender and then =
delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*=
"*"*

(message missing)

AW: create and insert
Hartmaier Alexander 16:45 on 20 Jan 2005

AW: create and insert
Hartmaier Alexander 15:57 on 21 Jan 2005

Re: AW: create and insert
Jay Strauss 16:45 on 21 Jan 2005

Generated at 17:42 on 27 Jan 2005 by mariachi v0.52