Saturday, February 25, 2012

Clone a record

Hello --
I want to create a new record in the "sales_quotes" table so the salesperson
can explore alternate quote(s) to present to a customer.
The new record will have these characteristics:
- identical values for all fields with the exception of the primary key
field
- the primary key value of the new record will have a user-entered value,
validated to assure it is unique
Can someone suggest how to do this ...
- updatable query
- create record in a temp table with identical structure, modify the primary
key field, then append to quotes table
- other
Thanks for any help.
Larry Mehl
L Mehl wrote:

>Hello --
>I want to create a new record in the "sales_quotes" table so the salesperso
n
>can explore alternate quote(s) to present to a customer.
>The new record will have these characteristics:
>- identical values for all fields with the exception of the primary key
>field
>
Identical for all fields of what row? I don't see the point of
inserting a new sales quote that is identical to an existing quote
except for the primary key (which appears to be entirely artificial).
But if you have some real need to do this, it would look something like
insert into sales_quotes
select
@.new_primary_key_value,
column_A,
column_B,
column_C,
.
from sales_quotes
where primary_key_column = @.old_primary_key_value
It makes more sense to me that you would want to add a new
row to a quotes table when there is a new, different quote, not
when there is no new quote.
Steve Kass
Drew University

>- the primary key value of the new record will have a user-entered value,
>validated to assure it is unique
>Can someone suggest how to do this ...
>- updatable query
>- create record in a temp table with identical structure, modify the primar
y
>key field, then append to quotes table
>- other
>Thanks for any help.
>Larry Mehl
>
>|||No reason to copy a row in your table. I guess what you mean is that you
want to present that data to the salesperson so that she can review it,
modify some data and then save a *modified* version of the row - not just
modify the key, which would serve no obvious purpose. Do this the same way
the enter any new row - the "cloned" values just become the defaults in the
user's entry form. This is client-side functionality.
David Portas
SQL Server MVP
--|||If [sales_quotes] is a table seperate from sales, then just do a select into
[sales_quotes] from [sales] and then let the salesperson can edit the new
record using a form. I don't see why the primary key should be user entered;
instead let them enter a descriptive text or key from cutomer and date
entered.
"L Mehl" <mehl_nospam@.cyvest.com> wrote in message
news:LGWMd.556$mG6.504@.newsread1.news.pas.earthlink.net...
> Hello --
> I want to create a new record in the "sales_quotes" table so the
> salesperson
> can explore alternate quote(s) to present to a customer.
> The new record will have these characteristics:
> - identical values for all fields with the exception of the primary key
> field
> - the primary key value of the new record will have a user-entered value,
> validated to assure it is unique
> Can someone suggest how to do this ...
> - updatable query
> - create record in a temp table with identical structure, modify the
> primary
> key field, then append to quotes table
> - other
> Thanks for any help.
> Larry Mehl
>|||Steve --
Thanks. Sorry for the brief description of the need for this process.
The reason for the cloned record is so that the sales person's manager can
perform sensitivity analysis on the quote, with the possible result that it
becomes the quote that is submitted to the customer, and the "original"
quote is discarded.
I was aware of the method you show. I was looking for a way to avoid having
to enter all the non-primary-key values.
Larry
"Steve Kass" <skass@.drew.edu> wrote in message
news:#cCT9q0CFHA.3728@.TK2MSFTNGP14.phx.gbl...
>
> L Mehl wrote:
>
salesperson
> Identical for all fields of what row? I don't see the point of
> inserting a new sales quote that is identical to an existing quote
> except for the primary key (which appears to be entirely artificial).
> But if you have some real need to do this, it would look something like
> insert into sales_quotes
> select
> @.new_primary_key_value,
> column_A,
> column_B,
> column_C,
> ..
> from sales_quotes
> where primary_key_column = @.old_primary_key_value
> It makes more sense to me that you would want to add a new
> row to a quotes table when there is a new, different quote, not
> when there is no new quote.
> Steve Kass
> Drew University
>
primary|||All --
Thank you for the suggestions.
Larry Mehl
"L Mehl" <mehl_nospam@.cyvest.com> wrote in message
news:LGWMd.556$mG6.504@.newsread1.news.pas.earthlink.net...
> Hello --
> I want to create a new record in the "sales_quotes" table so the
salesperson
> can explore alternate quote(s) to present to a customer.
> The new record will have these characteristics:
> - identical values for all fields with the exception of the primary key
> field
> - the primary key value of the new record will have a user-entered value,
> validated to assure it is unique
> Can someone suggest how to do this ...
> - updatable query
> - create record in a temp table with identical structure, modify the
primary
> key field, then append to quotes table
> - other
> Thanks for any help.
> Larry Mehl
>|||Steve --
I am a newbie concerning SQL queries in VB connected to a SQL Server
database.
In an ACCESS/VBA application I used SQL as in your example "insert into
sales_quotes ..." below, in a command
CurrentDb.Execute "insert into sales_quotes ...", dbFailOnError
Can you tell me how to do the same thing in VB connected to a SQL Server
database, or suggest some articles or other resoulced from which I can learn
how?
I can connect to the db and populate a datagrid using ADO. Is your example
"compatible" with ADO, or is it another technique entirely?
I will eventually convert my app to dotNET, so I would appreciate knowing if
your method will work well on that platform.
Thank you for any more help.
Larry
"Steve Kass" <skass@.drew.edu> wrote in message
news:#cCT9q0CFHA.3728@.TK2MSFTNGP14.phx.gbl...
>
> L Mehl wrote:
>
salesperson
> Identical for all fields of what row? I don't see the point of
> inserting a new sales quote that is identical to an existing quote
> except for the primary key (which appears to be entirely artificial).
> But if you have some real need to do this, it would look something like
> insert into sales_quotes
> select
> @.new_primary_key_value,
> column_A,
> column_B,
> column_C,
> ..
> from sales_quotes
> where primary_key_column = @.old_primary_key_value
> It makes more sense to me that you would want to add a new
> row to a quotes table when there is a new, different quote, not
> when there is no new quote.
> Steve Kass
> Drew University
>
primary|||The answer appears to be
connection.Execute
After I understand the third parameter 'Options' I think it will work.
Does anyone have examples or resources for using connection.Execute?
Larry Mehl
"L Mehl" <mehl_nospam@.cyvest.com> wrote in message
news:94CNd.2141$UX3.1163@.newsread3.news.pas.earthlink.net...
> Steve --
> I am a newbie concerning SQL queries in VB connected to a SQL Server
> database.
> In an ACCESS/VBA application I used SQL as in your example "insert into
> sales_quotes ..." below, in a command
> CurrentDb.Execute "insert into sales_quotes ...", dbFailOnError
> Can you tell me how to do the same thing in VB connected to a SQL Server
> database, or suggest some articles or other resoulced from which I can
learn
> how?
> I can connect to the db and populate a datagrid using ADO. Is your
example
> "compatible" with ADO, or is it another technique entirely?
> I will eventually convert my app to dotNET, so I would appreciate knowing
if
> your method will work well on that platform.
> Thank you for any more help.
> Larry
>
> "Steve Kass" <skass@.drew.edu> wrote in message
> news:#cCT9q0CFHA.3728@.TK2MSFTNGP14.phx.gbl...
> salesperson
value,
> primary
>

No comments:

Post a Comment