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

  1. /* ********************************************************************** */
  2. /* QMIMPO version 1.0 - Import Query Manager objects - 2/19/90            */
  3. /* ********************************************************************** */
  4. /* If the QM object table doesn't exist yet, it will be created and you   */
  5. /* will be prompted to enter a new CREATOR id for the imported objects.   */
  6. /* If the QM object table already exists, this renaming is skipped.       */
  7. /* The following can be done to rename the imported objects anyway:       */
  8. /* 1. Export the existing QM objects to a second IXF file.                */
  9. /* 2. Drop the QRWSYS.QRWSYS_OBJECT table                                 */
  10. /* 3. Import the new QM objects using QMIMPO.CMD                          */
  11. /*    (QMIMPO will prompt for a new CREATOR)                              */
  12. /* 4. Import the old QM objects using QMIMPO.CMD                          */
  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 "QMIMPO.CMD - version 1.0 - 2/18/90"
  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. FLTMOD = 'FORCEIN'
  29.  
  30. Do forever
  31.   Say ""
  32.   Say "Please enter the database name to receive the QM objects or"
  33.   Say "Press Enter to exit."
  34.   Pull db1
  35.   if db1="" then leave
  36.   else do forever
  37.     Say "Enter name of IXF file that contains the exported QM objects or"
  38.     Say "Press Enter to select another database."
  39.     Pull ixfname
  40.     If ixfname = '' then leave
  41.     Else do
  42.       say "Importing from" ixfname "...."
  43.       crea=1
  44.       call SQLDBS 'IMPORT TO' db1 'FROM' ixfname 'OF IXF MODIFIED BY :FLTMOD CREATE INTO QRWSYS.QRWSYS_OBJECT MESSAGES QMIMPO.LOG'
  45.       if SQLCA.SQLCODE=-3305 Then Do
  46.         call SQLDBS 'IMPORT TO' db1 'FROM' ixfname 'OF IXF MODIFIED BY :FLTMOD INSERT INTO QRWSYS.QRWSYS_OBJECT MESSAGES QMIMPO.LOG'
  47.         crea=0
  48.       end
  49.       if SQLCA.SQLCODE=3107 Then Do
  50.         say "Import errors are logged in 'QMIMPO.LOG'"
  51.         say "Do you want to see them now? Y or N"
  52.         Pull ans
  53.         If ans='Y' then 'TYPE QMIMPO.LOG'
  54.       end
  55.       else if SQLCA.SQLCODE <> 0 then signal ERROR
  56.       if crea=1 then do
  57.         say "**************************************"
  58.         say "QRWSYS.QRWSYS_OBJECT has been created."
  59.         say "**************************************"
  60.         say ""
  61.       end
  62.       if crea=1 then do
  63.         say "If you want to rename the CREATOR id of the QM objects"
  64.         say "just imported, enter the new id below. (max 8 characters)"
  65.         say "Press Enter without any data to skip the renaming."
  66.         do forever
  67.           pull newid
  68.           if newid='' then signal FINISH
  69.           if length(newid) > 8 then do
  70.             say "CREATOR must be 8 characters or less."
  71.             iterate
  72.           end
  73.           if words(newid) > 1 then do
  74.             say "Spaces are not allowed."
  75.             iterate
  76.           end
  77.           call SQLDBS 'START USING DATABASE' db1
  78.           t='QRWSYS.QRWSYS_OBJECT'
  79.           stmt1 = "UPDATE" t "SET CREATOR='"newid"'"
  80.           call SQLEXEC 'EXECUTE IMMEDIATE :stmt1'
  81.           if sqlca.sqlcode <> 0 then signal ERROR
  82.           stmt2 = "UPDATE" t "SET QRW_CREATOR='"newid"'"
  83.           call SQLEXEC 'EXECUTE IMMEDIATE :stmt2'
  84.           if sqlca.sqlcode <> 0 then signal ERROR
  85.           call SQLDBS 'STOP USING DATABASE'
  86.           leave
  87.         end
  88.       end
  89.     end
  90.   end
  91. end
  92.  
  93. result=0
  94. signal FINISH
  95.  
  96. ERROR: result = SQLCA.SQLCODE
  97.        say "return code:" result
  98.        say SQLMSG
  99.        exit result
  100.  
  101. FINISH: say 'QMIMPO finished and result =' result
  102.         exit result
  103.  
  104. rcy = Rxfuncdrop('SQLDBS')
  105.    If rcy <> 0 Then
  106.      Say "RXfuncdrop SQLDBS rc =" rcy
  107. rcy = Rxfuncdrop('SQLEXEC')
  108.    If rcy <> 0 Then
  109.      Say "RXfuncdrop SQLEXEC rc =" rcy
  110.