Re: create and insert

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

From: Hartmaier Alexander
Subject: Re: create and insert
Date: 16:38 on 24 Jan 2005
No I can't cause I copy data from a NAC::ScanInterface class object to a =
NAC::Interface class object!
I also can't use ->move cause it's depreciated...

My solution is this:

my $newport =3D 'dnsname.of.scanned.interface';
my $monitor =3D '2'; #2 means monitor yes

my $obj_scanint =3D NAC::ScanInterface->retrieve($newport);

my @columns =3D ("snmpid", "name", "ipnetmask", "fk_device", "fk_line", "=
port", "description", "speed", "snmpid_rtt", "type", "mtu", "ipaddr");

my %data;
@data{@columns} =3D $obj_scanint->get(@columns);
$data{'fk_monitor'} =3D $monitor;

my $obj_int =3D NAC::Interface->create(\%data);

print $obj_int->id . "\n";

Doesn't really look nice but it works. I will create a method called 'gen=
_interface' for the NAC::ScanInterface object which returns me the new cr=
eated NAC::Interface object (or should I do it the other way round???).

-Alex


-----Urspr=FCngliche Nachricht-----
Von: Peter Speltz [mailto:peterspeltz@xxxxx.xxx]=20
Gesendet: Montag, 24. Januar 2005 17:29
An: class dbi list
Betreff: Re: create and insert


--- Hartmaier Alexander <Alexander.Hartmaier@xxxxxxxxx.xx> wrote:


> Now I'll look in the process of creating NAC::Interface objects out of
> NAC::ScanInterface objects. As Perrin already wrote the NAC::ScanInterf=
ace
> objects don't have the same primary key as the NAC::Interface objects s=
o I
> won't be able to use ->copy.

You can use copy. The primary key is removed anyway before it is copied. =
You
set the primary key if you want via parameter(s) or class dbi figures it =
out.
For multi col keys you have to set them.  Here's excerpt from docs:

Copy
This creates a copy of the given $obj, removes the primary key, sets any
supplied column values and calls create() to insert a new record in the
database.

For tables with a single column primary key, copy() can be called with no=

parameters and the new object will be assigned a key automatically. Or a =
single
parameter can be supplied and will be used as the new key.

For tables with a multi-olumn primary key, copy() must be called with
parameters which supply new values for all primary key columns, unless a
before_create trigger will supply them. The create() method will fail if =
any
primary key columns are not defined.

=3D=3D=3D=3D=3D
pjs


	=09
__________________________________=20
Do you Yahoo!?=20
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250

*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*=
"*"*
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)

create and insert
Hartmaier Alexander 16:00 on 20 Jan 2005

Re: create and insert
Dana Hudes 16:06 on 20 Jan 2005

Re: create and insert
Hartmaier Alexander 16:24 on 20 Jan 2005

Re: create and insert
Jay Strauss 17:45 on 20 Jan 2005

Re: create and insert
Perrin Harkins 18:46 on 20 Jan 2005

Re: create and insert
Jay Strauss 19:33 on 20 Jan 2005

Re: create and insert
Perrin Harkins 19:51 on 20 Jan 2005

Re: create and insert
Jay Strauss 17:39 on 20 Jan 2005

Re: create and insert
Peter Speltz 17:53 on 20 Jan 2005

Re: create and insert
Peter Speltz 18:06 on 20 Jan 2005

Re: create and insert
Hartmaier Alexander 09:40 on 21 Jan 2005

Re: create and insert
Jay Strauss 15:41 on 21 Jan 2005

Re: create and insert
Perrin Harkins 19:35 on 21 Jan 2005

Re: create and insert
Peter Speltz 05:50 on 22 Jan 2005

Re: create and insert
Perrin Harkins 17:19 on 22 Jan 2005

Re: create and insert
Peter Speltz 17:43 on 22 Jan 2005

Re: create and insert
Perrin Harkins 19:09 on 22 Jan 2005

Re: create and insert
Peter Speltz 22:22 on 22 Jan 2005

Re: create and insert
Perrin Harkins 00:18 on 23 Jan 2005

Re: create and insert
Hartmaier Alexander 14:07 on 24 Jan 2005

Re: create and insert
William McKee 16:15 on 24 Jan 2005

Re: create and insert
Peter Speltz 16:28 on 24 Jan 2005

Re: create and insert
Hartmaier Alexander 16:38 on 24 Jan 2005

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