home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.databases:7877 comp.databases.sybase:324
- Path: sparky!uunet!think.com!ames!sun-barr!cs.utexas.edu!bcm!mparsons
- From: mparsons@fleming.csc.bcm.tmc.edu (Mark Parsons)
- Newsgroups: comp.databases,comp.databases.sybase
- Subject: Re: help needed on sybase stored procedure
- Date: 16 Nov 1992 15:35:25 GMT
- Organization: Baylor College of Medicine, Houston, Tx
- Lines: 53
- Distribution: world
- Message-ID: <1e8f3tINN1ii@gazette.bcm.tmc.edu>
- References: <1992Nov14.000317.58320@ssf-corp.dhl.com>
- Reply-To: mparsons@fleming.csc.bcm.tmc.edu (Mark Parsons)
- NNTP-Posting-Host: fleming.csc.bcm.tmc.edu
- Originator: mparsons@fleming.csc.bcm.tmc.edu
-
-
- In article <1992Nov14.000317.58320@ssf-corp.dhl.com>, julies@ssf-corp.dhl.com (Julie Stephens) writes:
- |> I'm attempting to create a generic Sybase stored procedure which will
- |> accept up to 254 input parameters. Within the stored procedure
- |> I would like to determine how many parameters were passed to the
- |> stored procedure & process them. To accomplish this, I'd like to
- |> have a loop which creates input parm names on the fly & retrieve
- |> the values stored in those input parameters. Can this be done?
- |>
- |> Here is an example of what I'm trying to do. The problem here is
- |> clear (see WHILE clause). The program will evaluate the temporary
- |> variable @argName--not the input parameter @arg1.
- |>
- |> CREATE PROC processArguments
- |> @arg1 varchar(255),
- |> @arg2 varchar(255),
- |> @arg3 varchar(255),
- |> ...
- |> @arg254 varchar(255)
- |> AS
- |> DECLARE @argName varchar(30)
- |> DECLARE @argInt int
- |>
- |> ProcessArguments:
- |> SELECT @argInt = 1
- |> SELECT @argName = '@arg1'
- |>
- |> WHILE @argName IS NOT NULL
- |> BEGIN
- |> (blah, blah, blah)
- |> SELECT @argInt = @argInt + 1
- |> SELECT @argName = '@arg' + (SELECT CONVERT(char(3), @argInt))
- |> END
- |>
-
- From what I've seen(and played with) you cannot do indirect addressing
- or dynamic creation of code within a stored procedure . . at least not
- in Sybase(can you in other DB servers?).
-
- Each time through the loop @argName will be set to a string that looks
- like 'arg??'. In addition to that, the system will run indefinitely
- since @argName will never be set to NULL, i.e., this is an endless
- loop . . . unless you put in a test that says "If @argInt > 254 select
- @argNmae = NULL".
-
- If you use a different language, or move this to the front-end,
- say . . . APT . . . you could do something like this . . but not in
- the server . . .
-
- Anyone reported this to Sybase as a feature enhancement request?
-
- Mark
-
-