home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / database / sybase / 322 < prev    next >
Encoding:
Text File  |  1992-11-15  |  2.9 KB  |  62 lines

  1. Newsgroups: comp.databases.sybase
  2. Path: sparky!uunet!news.centerline.com!noc.near.net!news.bbn.com!usc!sdd.hp.com!zaphod.mps.ohio-state.edu!wupost!darwin.sura.net!paladin.american.edu!news.univie.ac.at!hp4at!mcsun!sunic!seunet!enea!sommar
  3. From: sommar@enea.se (Erland Sommarskog)
  4. Subject: Re: How to connect APT-Form to different database?
  5. Message-ID: <1992Nov15.204137.20582@enea.se>
  6. Organization: Enea Data AB
  7. References: <EEDKSC.92Nov11123557@teamos50.ericom>
  8. Date: Sun, 15 Nov 1992 20:41:37 GMT
  9. Lines: 51
  10.  
  11. Klaus Schniedergers (eedksc@teamos50.ericom) writes:
  12. >I have the following problem with the behated APT-Forms:
  13. > I want my form to be able to connect to different databases, i.e. defining
  14. >a database name in an environment variable then starting the form
  15. >without any recompiling or interactive input.
  16.  
  17. Well, what exactly do you want to do? Do you want to run your
  18. application against different instances of the same database
  19. definition, or do you want to something more advanced? I am
  20. assuming that you want to do the former, since we have had this
  21. problem.
  22.  
  23. >When creating the form, the database name is encoded in several places:
  24. >- the form-preprocessing-procedure (as ' sqlbegin use <db-name> sqlend ')
  25. >- the sql column connected to fields (<db-name>.dbo.table)
  26.  
  27. First thing to do, is to remove all those 'use <db-name>' suckers and
  28. rely strictly on the default database. If you are running the application
  29. from your own startup program, the best idea is to look on the environ-
  30. ment variable and set the default DB before anyting else. If you are
  31. using aptexec, set the default DB in a surrounding script. Yes, this
  32. means that the same user cannot run two different databases at the
  33. same time, but that is what you get with such a corny concept as a
  34. default database.
  35.  
  36. In our application, we use a slightly different approach. There is
  37. no environment variable, and the users cannot change the database
  38. on their own, but only the appointed super user can from a special
  39. menu. (They are not super users in the wide Unix sense, they are
  40. just as unexperienced of computers as the ordinary users, so neither
  41. they have shell access.)
  42.  
  43. >A dirty solution would be running the <name>.frm file through an sed-script,
  44. >changing the database-name to the new one. But I would like a more
  45. >elegant solution.........
  46.  
  47. Well, you don't need the shell script, Sybase has aptmig for you to
  48. do the task. But beware about the interface, which is very un-Unix.
  49. If you say "aptmig -n new_db *" you will cause a mess; you have to
  50. use find(1).
  51.  
  52. However, as long as the databases are sufficiently identicial and
  53. accessible to everyone there is no need for migration. The only
  54. thing you have to make sure is that everyone is a user in the
  55. database to which the forms refer. If this is a security issue,
  56. make this an empty database.
  57.  
  58. Yes, if the database are different this is a mess with hard-coded
  59. database names in the forms, but when did APT make anyone happy?
  60. -- 
  61. Erland Sommarskog - ENEA Data, Stockholm - sommar@enea.se
  62.