Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2006
    Posts
    13

    Question Unanswered: Does Sybase support array or VARRAY just like Oracle?

    HI, Everybody
    I'm writing some stored procedure. I need to execute many query onec. Does Sybase support array or VARRAY just like Oracle? If not, can I use some alternative method?
    Thanks very much!

  2. #2
    Join Date
    Jan 2003
    Location
    Geneva, Switzerland
    Posts
    353
    No, Sybase doesn't support variable arrays.

    What you do instead is store the data in a temporary table, like this:

    Code:
    select ... into #tmp
    from ...
    where ...
    The temporary table will be automatically dropped when the stored proc terminates, and will be private to this execution of the stored proc.

    Michael

  3. #3
    Join Date
    Aug 2006
    Posts
    13
    How to do if I want to input multiple value parameter?

  4. #4
    Join Date
    Jan 2003
    Location
    Geneva, Switzerland
    Posts
    353
    Could you post an example of what you are trying to do?

    Michael

  5. #5
    Join Date
    Aug 2006
    Posts
    13
    For example: I want to write a stored procedure which accecpt some values as input parameter. The procedure will select some records from database according the input values one by one. In Oracle ,I can define a parameter type as table or array to input many parameter values once to get results. Thus I needn't run a sql repeatly. Is there any same methods in Sybase? Does Sybase support table or array type parameter in stored procedure?

  6. #6
    Join Date
    Jan 2003
    Location
    Geneva, Switzerland
    Posts
    353
    No.

    You can pass multiple parameters (@p1, @p2, etc) and use that, or you create a temp table and populate it before calling the stored proc, and use the info in the temp table to perform the request inside the proc.

    Michael

  7. #7
    Join Date
    Jul 2006
    Posts
    115
    every parameters can be varchar(255),
    u can "concat" an single dimention array into a parameter and breakdown in ur sp ...
    eg an array of 10 entries and every element is char(3) -> char(30)

  8. #8
    Join Date
    Feb 2002
    Location
    Willy is on vacation
    Posts
    1,208
    This can be achived in a bit crooked way in SYbase. Basically a stored proc is referred to as a table using CIS proxy.

    You query the pseudo-table with all your conditions in a WHERE clause or if the conditions you want are frmo a nother table, you can sinmply join another real table with this pseudo-table.

    Check out the CIS manual for examples.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •