home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / IMPEXP.ZIP / TBLIMPO.CMD < prev   
OS/2 REXX Batch file  |  1991-06-19  |  3KB  |  77 lines

  1. /* ********************************************************************** */
  2. /* TBLIMPO version 1.0 - Import TABLES        - 6/19/91                   */
  3. /* ********************************************************************** */
  4. /* ********************************************************************** */
  5. Trace 'o'
  6. rcx = Rxfuncquery('SQLDBS')
  7. If rcx <> 0 then
  8.    rcy = Rxfuncadd('SQLDBS','SQLAR','SQLDBS')
  9. rcx = Rxfuncquery('SQLEXEC')
  10. If rcx <> 0 then
  11.    rcy = Rxfuncadd('SQLEXEC','SQLAR','SQLEXEC')
  12. Say "TBLIMPO.CMD - version 1.0 - 6/19/91"
  13.  
  14. sample_rc = 0
  15. call SQLDBS 'START DATABASE MANAGER'
  16. if result<>0 then signal ERROR
  17. if (SQLCA.SQLCODE <> -1026 & SQLCA.SQLCODE <> 0)
  18.   then signal ERROR
  19. FLTMOD = "FORCEIN"
  20. Do forever
  21.   Say ""
  22.   Say "Please enter the database name to receive the tables or"
  23.   Say "Press Enter to exit."
  24.   Pull db1
  25.   if db1="" then leave
  26.   else do forever
  27.     Say "Enter name of IXF file that contains the exported table or"
  28.     Say "Press Enter to select another database."
  29.     Pull ixfname
  30.     If ixfname = '' then leave
  31.     Say "Enter table name or"
  32.     Say "Press Enter to select another database."
  33.     Pull tblname
  34.     If tblname = '' then leave
  35.     Else do
  36.       say "Importing from" ixfname " to table " tblname "....."
  37.       crea=1
  38.       call SQLDBS 'IMPORT TO' db1 'FROM' ixfname 'OF IXF MODIFIED BY :FLTMOD CREATE INTO ' tblname ' MESSAGES TBLIMPO.LOG'
  39.       if SQLCA.SQLCODE=-3305 Then Do
  40.         call SQLDBS 'IMPORT TO' db1 'FROM' ixfname 'OF IXF MODIFIED BY :FLTMOD INSERT INTO ' TBLNAME ' MESSAGES TBLIMPO.LOG'
  41.         crea=0
  42.       end
  43.       if SQLCA.SQLCODE=3107 Then Do
  44.         say "Import errors are logged in 'TBLIMPO.LOG'"
  45.         say "Do you want to see them now? Y or N"
  46.         Pull ans
  47.         If ans='Y' then 'TYPE TBLIMPO.LOG'
  48.       end
  49.       else if SQLCA.SQLCODE <> 0 then signal ERROR
  50.       if crea=1 then do
  51.         say "**************************************"
  52.         say "TABLE " TBLNAME " has been created."
  53.         say "**************************************"
  54.         say ""
  55.       end
  56.     end
  57.   end
  58. end
  59.  
  60. result=0
  61. signal FINISH
  62.  
  63. ERROR: result = SQLCA.SQLCODE
  64.        say "return code:" result
  65.        say SQLMSG
  66.        exit result
  67.  
  68. FINISH: say 'TBLIMPO finished and result =' result
  69.         exit result
  70.  
  71. rcy = Rxfuncdrop('SQLDBS')
  72.    If rcy <> 0 Then
  73.      Say "RXfuncdrop SQLDBS rc =" rcy
  74. rcy = Rxfuncdrop('SQLEXEC')
  75.    If rcy <> 0 Then
  76.      Say "RXfuncdrop SQLEXEC rc =" rcy
  77.