Questions tagged [table-functions]

A function in a relational database system that does not return a single value or row, but an arbitrary number of them. In SQL, a call to a table function can usually be used instead of a table.

A function in a system that does not return a single value or , but an arbitrary number of them.

In , a call to a table function can usually be used instead of a table.

Table functions go by different names in different relational database systems, such as in .

94 questions
0
votes
2 answers

SQL Server : I need to pass a row value as a parameter to table function in a stored procedure

I want to create a stored procedure with a table-valued function as a column. I want to use one of the other column values as the parameter for the function. ALTER PROCEDURE [dbo].[AuditReportLeaseID] @leaseID int AS BEGIN SET NOCOUNT ON; …
0
votes
0 answers

Use Table function on a list of Twitter users

I'm working on a small function using TwitteR package. The function will look at the followers of several twitter account, and return a list of of the follower with the number of time they appeared. To do so I'm using a simple loop to create a list…
Fabian
  • 11
  • 3
0
votes
2 answers

SQL Select fields of table value function

I have a table valued function declared so that I can return several values in one go. The values are calculated using DECLARE and Maths and Date functions. The function is structured such that it only takes a 'logged date', and a priority for…
Mark Rabjohn
  • 1,643
  • 14
  • 30
0
votes
0 answers

User-defined table functions in DB2

I would like to know the DB2 platforms where it is possible to create User-defined table functions in SQL-PL. It seems that it is possible in DB2 for i, but I haven't seen anything for LUW, not z/OS. It does not appear in the "SQL Reference for…
AngocA
  • 7,655
  • 6
  • 39
  • 55
0
votes
1 answer

Table function for each record in a query

I have a function that has two outputs ... dbo.func1(@code) -> Table(out1, out2) This function is too costly and takes much time to calculate these two outputs. and I have a query like this : SELECT code, name, (SELECT out1 dbo.func1(code)),…
Atzi
  • 457
  • 1
  • 6
  • 16
0
votes
0 answers

How to create Table Function that returns row for each line of a string, and returns empty table if string is null or empty

Although I found answers for the individual parts of this question, I am posting this because I did not find an answer that consolidated these into one solution. Thought I would post my solution in case anyone else had the same question. This is my…
edurhamx
  • 1
  • 1
0
votes
0 answers

How can we access an object type(not table of objects) in Oracle TABLE function?

How can we access an object type(not table of objects) in TABLE function ? The table function works on a collection of objects, but I have a need to access a single row using TABLE function. I get the error "ORA-22905: cannot access rows from a…
0
votes
1 answer

TABLE function with Dynamic SQL?

Is it possible to use TABLE function in Dynamic SQL? I get Invalid identifier error when I use table function with Table of Records as Input in EXECUTE IMMEDIATE. I can't get the following SQLs to work. EXECUTE IMMEDIATE 'SELECT COUNT(1) from…
0
votes
2 answers

T-SQL Table Function using declare statements

I have the following SQL statement that I have been building up, which returns a range of values based on the order of values within a table for 'product data' For example a product, TV, has a screen size and we want to query on TVs that have a…
VorTechS
  • 473
  • 5
  • 12
0
votes
1 answer

Send string into function and use string as "table"

Is there a way to send in a string into a T-SQL function and use that string as a "table" For instance CREATE FUNCTION [dbo].[TEST] ( @id int, **@table_name** nvarchar(50)) RETURNS @mytables TABLE ( id int, values nvarchar(50) …
Joe
  • 2,675
  • 3
  • 21
  • 26
0
votes
0 answers

How to use TOP() in Conjunction with Table Function

I am trying to do some thing like this: Select top 10 * from dbo.Fn_getUsers( ) where some condidtion The problem is taht it is giving an error message: incorrect synatax near from How to make this work. Please help.
Sai Avinash
  • 4,683
  • 17
  • 58
  • 96
0
votes
1 answer

Getting part of query defined by a parameterized function

Hello all :) I'm try to do something like this in Oracle 10g: SELECT CAR_ID, CAR_DATE, get_some_other_info(CAR_TYPE) FROM CARS Where get_some_other_info(CAR_ID) would return several columns: | CAR_ID | CAR_DATE | CAR_COLOR | CAR_CO2 | 001 …
BenoitParis
  • 3,166
  • 4
  • 29
  • 56
0
votes
1 answer

Functions returns empty set

I have successfully created a function in SQL 2008: ALTER FUNCTION [dbo].Func_raw_data_xref (@ColName AS NVARCHAR(255)) RETURNS @VVSrcCDs TABLE ( VV_SRC_CD NVARCHAR(255) NULL, VV_CD NVARCHAR(255) NULL, VV_SRC_CD_DESC…
Baub
  • 723
  • 4
  • 21
  • 36
0
votes
1 answer

Using a sql function inside a subquery with parameters

I have the following query that works: SELECT STUFF ( ( SELECT ', ' + RTRIM(LTRIM(ulastname)) FROM ROOM r LEFT JOIN person p ON p.hmy = r.hmyperson WHERE 1=1 AND r.hmytenant = t.hmyperson …
Matt Holmen
  • 47
  • 1
  • 6
0
votes
1 answer

Read Excel from DB2

I have to import some Excel data on a regular basis. Checking the DB2 documentation one can directly access OLE DB datasources via an external function. However I'm unable to set it up properly. I got the Microsoft Access Database Enginge 2010 plus…
Udo Held
  • 12,314
  • 11
  • 67
  • 93