home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / database / 7945 < prev    next >
Encoding:
Text File  |  1992-11-18  |  2.8 KB  |  74 lines

  1. Newsgroups: comp.databases
  2. Path: sparky!uunet!sun-barr!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!rsoft!mindlink!a269
  3. From: Mischa_Sandberg@mindlink.bc.ca (Mischa Sandberg)
  4. Subject: Re: help needed on sybase stored procedure
  5. Organization: MIND LINK! - British Columbia, Canada
  6. Date: Thu, 19 Nov 1992 04:22:37 GMT
  7. Message-ID: <17581@mindlink.bc.ca>
  8. Sender: news@deep.rsoft.bc.ca (Usenet)
  9. Lines: 63
  10.  
  11. > In article <1992Nov14.000317.58320@ssf-corp.dhl.com>,
  12. > julies@ssf-corp.dhl.com (Julie Stephens) writes:
  13. > |> I'm attempting to create a generic Sybase stored procedure which will
  14. > |> accept up to 254 input parameters.  Within the stored procedure
  15. > |> I would like to determine how many parameters were passed to the
  16. > |> stored procedure & process them.
  17. >
  18. > |> Here is an example of what I'm trying to do.  The problem here is
  19. > |> clear (see WHILE clause).  The program will evaluate the temporary
  20. > |> variable @argName--not the input parameter @arg1.
  21. > |>
  22. > |>      CREATE PROC processArguments
  23. > |>              @arg1   varchar(255),
  24. > |>              @arg2   varchar(255),
  25. > |>              @arg3   varchar(255),
  26. > |>              ...
  27. > |>              @arg254 varchar(255)
  28. > |>      AS
  29. >
  30. > Anyone reported this to Sybase as a feature enhancement request?
  31. >
  32. > Mark
  33. >
  34.  
  35.  
  36. 254 arguments !? No, I'm sorry, I guess you *are* being serious.
  37.  
  38. While there is a time and place for everything, might I suggest that
  39. if using as many as 254 arguments might occur some time, then a list
  40. of arguments is not the place for them. More likely, you might want
  41. to create something like:
  42.  
  43.         create table #arg(num int, val varchar(255) null)
  44.         create procedure ProcessArgs as
  45.         declare @nargs int
  46.         select  @args = count from #arg
  47.         ... operations on #arg en masse where possible and
  48.                 en loope where not ...
  49.         go
  50.         drop table #arg   /* ... to be born again */
  51.  
  52.         create table #arg(num int, val varchar(255) null)
  53.         insert #arg(1, "This is the first argument")
  54.         ...
  55.         insert #arg(254, "This need not be the last argument!")
  56.         exec ProcessArgs
  57.         drop table #arg
  58.  
  59. Small tables are a pretty efficient way of dealing with lists of values
  60. in Sybase, and allow you the efficiency of vector operations instead of
  61. tedious loops, within your procedure ...
  62.         (e.g. "update #args set val=rtrim(val) where num between 3 and 10")
  63.  
  64. Then again, perhaps I'm off base, and that the actual purpose is to
  65. see how much Transact can be used without having to resort to any SQL :-).
  66.  
  67. --
  68. Mischa Sandberg ... Mischa_Sandberg@mindlink.bc.ca
  69.                  or uunet!van-bc!rsoft!mindlink!Mischa_Sandberg
  70. *-*-*-*-*-*-*-*-*-*-*
  71. Engineers think equations are an approximation of reality.
  72. Physicists think reality is an approximation of the equations.
  73. Mathematicians never make the connection.
  74.