Hi all,
Last week I inserted 208 rows into TX_EVENT_EXTRACT and did the following to get around the evex_no (code below). However, being the SQL newbie I am…..didn’t realize that this would break the evex_no for any further invitations added in the normal way. As a temporary solution, I have updated my 208 inserts so that their evex_no are +1000 so duplicates won’t come up for a while.
Does anyone know how/where I can insert my evex_no’s so they are recognized and recorded correctly in the system?
Also, how do others get around doing Insert Select statements with a non-identity column as a PK? I searched and search online but couldn’t find anything. I hope I have made sense….
Thanks as always,
Tash
Declare
@maxid int
Set @maxid = (Select MAX(evex_no)+1 from TX_EVENT_EXTRACT)
While exists (Select * from #invitations)
Begin
If @maxid in (select evex_no from TX_EVENT_EXTRACT) continue;
Insert into TX_EVENT_EXTRACT
Select top 1
@maxid,
a.campaign_no,
a.customer_no,
a.source_no,
a.inv_status,
a.reserved_ind,
a.recd_amt,
a.num_attendees,
a.notes,
a.mir_lock
from #invitations a
Set @maxid = @maxid+1
delete from #invitations where customer_no in (Select MIN(customer_no)from #invitations)
End
You can use AP_GET_NEXTID_function @type='EV' for that table specifically. Probably right now what you really need to do is get the max evex_no you've currently got in tx_event_extract and update t_next_id so it's +1 that number where type='EV'. I think right now that table actually stores the current max, not in fact the "next" id, but I think in v11 it switches.
And just adding to Amanda's note - what people mostly do when they want to add a chunk of their own rows into one of those next_id-controlled tables is
Ken
Thanks so much Amanda and Ken. Table is back in working order!