OpenVMS Source-Code Demos
mysql_import_helper_basic_template_107_part2
!
! start of template 2/3
!22222222222222222222222222222222222222222222222222222222222222222222222
!=======================================================================
! file : mysql_import_helper_basic_template_107_part2.bas
! author : Neil Rieck
! history:
! 100 NSR 140708 1. original effort
! 106 NSR 170314 1. adding true unicode support
! NSR 170316 2. more work
! 107 NSR 200106 1. modified code to do better unicode data conversion to ISO (picking up new modules)
! 2. changed the default datatype from UTF-8 to CP1252
! NSR 200107 3. modified code to do better unicode data conversion to CP1252 (picking up new modules)
! 200108 4. disabled "set character-set='latin1';" (now do something similar in "load data")
! 200109 5. a few more changes after a good night's sleep (I'm now dreaming in code again) bf_107.5
!=======================================================================
!
! rms info (populated by FSP$)
!
map(ri) string ri_whole = 16 , ! &
string ri_align = 0 ! enforce layout check
map(ri) byte ri_org , ! 1= 1 &
byte ri_rat , !+1= 2 &
word ri_mrs , !+2= 4 &
long ri_alq , !+4= 8 &
word ri_bks_bls , !+2= 10 &
word ri_num_keys , !+2= 12 &
long ri_mrn , !+4= 16 &
string ri_align = 0 ! must align with previous decl
!=======================================================================
! main
!=======================================================================
main:
when error in !
!
! make sure INPUT is different from OUTPUT
!
if edit$(fs_i$,32+2) = edit$(fs_o$,32+2) then !
print "-e-oops, someone has made a typo (sanity test-1)"!
cause error 50 !
end if !
!
! make sure we are outputing to a file with a CSV extension
!
if pos( edit$(fs_o$,32+2), ".CSV",1)=0 then !
print "-e-oops, someone has made a typo (sanity test-2)"!
cause error 50 !
end if !
!
print "-i-opening: "+ fs_i$ !
open fs_i$ for input as #100 &
,access read, allow modify &
,recordtype any, organization undefined !
ri_whole = fsp$(100) ! snoop
close #100 !
!
map(xfer) string xfer$ = 4096 !
if ri_mrs > 4096 then !
print "-e-oops, map(xfer) is too small. Aborting" !
cause error 50 !
end if !
!
open fs_i$ for input as #100 &
,access read &
,allow modify &
,recordtype any &
,organization undefined &
,map xfer &
,recordsize ri_mrs !
!
open fs_o$ for output as #99 &
,organization sequential &
,recordsize 32767 !
!
print "-i-start : "; date4$(0) +" "+ time$(0) !
limit_i% = 25000 ! see "more efficient" ~ 8 lines below
while 1 !
get #100, regardless !
count_i% = count_i% + 1 !
%let %patch20200109=1 !
%if %patch20200109=0 %then ! OLD
print "-i-read :"; count_i% if mod(count_i%,25000)=0 ! do we really want to do a millions of these each night?
%else ! NEW
if count_i% = limit_i% then ! this is much more efficient than MOD(,)
print "-i-read :"; count_i% !
limit_i% = limit_i% + 25000 !
end if !
%end %if
! print left$(xfer$,ri_mrs) x debug maximum rec siz
!22222222222222222222222222222222222222222222222222222222222222222222222
! end of template 2/3
!