I'm planning to do a mass-import of Research Notes from an excel file using SQL. It's more complicated than I had first imagined because it involves entries in both TX_CUST_NOTES and TX_CUST_NOTES_EXT. Has anyone developed a script or utility to do this?
(Cross-posting to the Fundraising forum.)
I haven't, but something like this... (You would of course have to have an outer loop to select the next record.)
***Please note*** I slapped this together in like 10 minutes. Just some logic to do it and not a completed bit of code. Purely academic so you can learn.
declare @debug char(1) = 'F',@customer_no int = 1021703,@next int,@note_type int = 5, -- note type@notes varchar (max) = 'lWith its folding 7.3-inch screen, Samsung''s Galaxy Fold was touted as the biggest Galaxy phone yet. Priced at nearly $2,000, the folding smartphone was due to go on sale this Friday. But Samsung announced on Monday that it''s delaying the release after reviewers found problems with the phone''s screen.In a statement, Samsung acknowledged the device "needs further improvements that could ensure the best possible user experience. To fully evaluate this feedback and run further internal tests, we have dec 11111111111111111111111111111111111111111111111111111111111111111111111'
if @debug = 'F' begin --get the next id exec @next = ap_get_nextid_function @type = 'CN', @increment = -1 --update the table INSERT INTO TX_CUST_NOTES ( customer_no, note_type, cust_notes_no ) VALUES (@customer_no,@note_type,@next ) end
if @debug = 'T' begin select @customer_no,@note_type end
declare @counter int = 1,@notes_len decimal = null,@max decimal (5,0)= null,@notes_snip varchar(255),@start int = 1,@end int = 255
set @notes_len = (select len(@notes))set @max =ceiling((select @notes_len/255))
if @debug = 'T' begin select @notes_len, @max end
if @max = 1 begin INSERT INTO TX_CUST_NOTES_EXT ( notes, cust_notes_no, serial_order ) VALUES ( @notes, @next, 1 ) end
if @max > 1 begin
while @max >= @counter begin set @notes_snip = (select substring(@notes,@start,@end)) if @debug = 'T' begin select @notes_snip select @start, @end end
if @debug = 'F' begin INSERT INTO TX_CUST_NOTES_EXT ( notes, cust_notes_no, serial_order ) VALUES ( @notes_snip, @next, @counter ) end
set @counter = @counter+ 1 set @start = @start + 255 set @end = @end + 255 end end