dbTalk Databases Forums  

SQL Anywhere table function returns table?

sybase.public.sqlanywhere.general sybase.public.sqlanywhere.general


Discuss SQL Anywhere table function returns table? in the sybase.public.sqlanywhere.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
marcos_p78@hotmail.com
 
Posts: n/a

Default SQL Anywhere table function returns table? - 10-13-2011 , 05:43 PM






/ *
Hello this is my question
in SQL Anywhere can create functions that return tables?
There are table type variables in SQL Anywhere?
or something
in MSQL Server I had a function that returns me a table

Then I had a procedure that called the function
and kept the data in a table variable
now how to do it in SQL Anywhere
the query is slightly longer but I have summarized
* /

CREATE FUNCTION fun_1
(@finicio datetime,
@ffinal datetime)
RETURNS @tab1 TABLE (CIndice int IDENTITY(1, 1) NOT NULL,
CodOperacion numeric(18,0),
CodCliente varchar(10))
AS
BEGIN
DECLARE @masvariables numeric(18,0)

Insert into @tab1 (CodOperacion, CodCliente)
Select CodOP, Cliente from Tabla1
--where .......


return
End

go

Create procedure SP_1
As
declare @finicio datetime
declare @ffinal datetime


declare @vartabla_1 table (
CIndice int NOT NULL, CodOperacion numeric(18,0), CodCliente
varchar(10) )

insert into @vartabla_1
Select CIndice, CodOperacion ,CodCliente from [fun_1]
(@finicio, @ffinal)

/*
more code....
*/

thanks greetings

Reply With Quote
  #2  
Old   
tduemesnil
 
Posts: n/a

Default Re: SQL Anywhere table function returns table? - 11-09-2011 , 09:39 AM






Normaly only Procedures return Result sets ( aka Tables ).
CREATE PROCEDURE proc_1 (@finicio datetime, @ffinal datetime)
RESULT (CIndice int IDENTITY(1, 1) NOT NULL, CodOperacion
numeric(18,0), CodCliente varchar(10))
AS
BEGIN

Select CodOP, Cliente from Tabla1
--where .......

End

On 13 Okt., 23:43, marcos_... (AT) hotmail (DOT) com wrote:
Quote:
/ *
Hello this is my question
in SQL Anywhere can create functions that return tables?
There are table type variables in SQL Anywhere?
or something
in MSQL Server I had a function that returns me a table

Then I had a procedure that called the function
and kept the data in a table variable
now how to do it in SQL Anywhere
the query is slightly longer but I have summarized
* /

CREATE FUNCTION fun_1
* * * * * * * * * * (@finicio datetime,
* * * * * * * * * * *@ffinal datetime)
* * * * *RETURNS @tab1 TABLE (CIndice int IDENTITY(1, 1) NOT NULL,
* * * * * * * * * * * * * * *CodOperacion numeric(18,0),
* * * * * * * * * * * * * * *CodCliente varchar(10))
AS
* *BEGIN
* * * DECLARE @masvariables *numeric(18,0)

* * * Insert into @tab1 (CodOperacion, CodCliente)
* * * Select CodOP, Cliente from Tabla1
* * * * --where .......

* * * return
* *End

go

Create procedure SP_1
As
declare @finicio datetime
declare @ffinal datetime

declare @vartabla_1 table (
CIndice int NOT NULL, CodOperacion numeric(18,0), CodCliente
varchar(10) )

insert into @vartabla_1
*Select CIndice, CodOperacion ,CodCliente from *[fun_1]
(@finicio, @ffinal)

/*
more code....
*/

thanks greetings

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.