home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / IMPEXP.ZIP / TBLEXPO.CMD < prev    next >
OS/2 REXX Batch file  |  1991-08-20  |  3KB  |  88 lines

  1. /* ********************************************************************** */
  2. /* TBLEXPO version 1.0 - EXPORT TABLES        - 8/20/91                   */
  3. /*                                                                        */
  4. /*                                                                        */
  5. /* WHEN SPECIFYING A TABLE NAME YOU MUST ENTER THE FULLY QUALIFIED        */
  6. /* TABLE NAME.  EG.  USERID.MYTABLE                                      */
  7. /*                                                                        */
  8. /*                                                                        */
  9. /* WHEN SPECIFYING AN EXPORT FILE NAME YOU MUST INCLUDE THE EXTENSION     */
  10. /* 'IXF'.  EG.  MYTABLE.IXF                                               */
  11. /*                                                                        */
  12. /* ********************************************************************** */
  13. /* ********************************************************************** */
  14. Trace 'o'
  15. rcx = Rxfuncquery('SQLDBS')
  16. If rcx <> 0 then
  17.    rcy = Rxfuncadd('SQLDBS','SQLAR','SQLDBS')
  18. rcx = Rxfuncquery('SQLEXEC')
  19. If rcx <> 0 then
  20.    rcy = Rxfuncadd('SQLEXEC','SQLAR','SQLEXEC')
  21. Say "TBLEXPO.CMD - version 1.0 - 8/20/91"
  22.  
  23. sample_rc = 0
  24. call SQLDBS 'START DATABASE MANAGER'
  25. if result<>0 then signal ERROR
  26. if (SQLCA.SQLCODE <> -1026 & SQLCA.SQLCODE <> 0)
  27.   then signal ERROR
  28.  
  29. Do forever
  30.   Say ""
  31.   Say "Please enter the database name containing the tables or"
  32.   Say "Press Enter to exit."
  33.   Pull db1
  34.   if db1="" then leave
  35.   else do forever
  36.  
  37.     Say "Enter table name or"
  38.     Say "Press Enter to select another database."
  39.     Pull tblname
  40.     If tblname = '' then leave
  41.  
  42.     Say "Enter fully qualified name of IXF file to export data to "
  43.     Say "Press Enter to select another database."
  44.     Pull ixfname
  45.     If ixfname = '' then leave
  46.  
  47.     Else do
  48.       say "Exporting from" tblname " to " ixfname "....."
  49.       crea=1
  50.       stmt = 'SELECT * FROM ' TBLNAME
  51.  
  52.       call SQLDBS 'EXPORT :STMT FROM ' DB1 ' TO ' IXFNAME ' OF IXF MESSAGES TBLEXPO.LOG'
  53.  
  54.       if SQLCA.SQLCODE=3107 Then Do
  55.         say "Import errors are logged in 'TBLEXPO.LOG'"
  56.         say "Do you want to see them now? Y or N"
  57.         Pull ans
  58.         If ans='Y' then 'TYPE TBLEXPO.LOG'
  59.       end
  60.       else if SQLCA.SQLCODE <> 0 then signal ERROR
  61.       if crea=1 then do
  62.         say "**************************************"
  63.         say "TABLE " TBLNAME " has been exported"
  64.         say "**************************************"
  65.         say ""
  66.       end
  67.     end
  68.   end
  69. end
  70.  
  71. result=0
  72. signal FINISH
  73.  
  74. ERROR: result = SQLCA.SQLCODE
  75.        say "return code:" result
  76.        say SQLMSG
  77.        exit result
  78.  
  79. FINISH: say 'TBLEXPO finished and result =' result
  80.         exit result
  81.  
  82. rcy = Rxfuncdrop('SQLDBS')
  83.    If rcy <> 0 Then
  84.      Say "RXfuncdrop SQLDBS rc =" rcy
  85. rcy = Rxfuncdrop('SQLEXEC')
  86.    If rcy <> 0 Then
  87.      Say "RXfuncdrop SQLEXEC rc =" rcy
  88.