94
questions
2
votes
0
answers
551
views
CDS View Table functions Abap Class consume with parameters
I want to select data through a class method implemented in ABAP class. This method takes parameters from the defined table function to filter on POnumber and POitem.
Goal is to call this table ...
0
votes
0
answers
39
views
SQL Conditional Logic for BigQuery
I am creating a TVF on my BigQuery which will allow me to take in two date arguments. Based on the date logic, I want to run and return different SQLs. Pseudo code is below-
CREATE OR REPLACE TABLE ...
0
votes
3
answers
148
views
pass values from a table into oracle table funcion in SQL
I have
create or replace TYPE t_process_teilenummer_tab AS TABLE OF VARCHAR2(4000);
create or replace FUNCTION process_teilenummer (
Teilenummer IN CLOB
)
RETURN t_process_teilenummer_tab
...some ...
0
votes
1
answer
49
views
Use a Select Statement for Variable Values
In SQL, I have a table function created which, in its definition, includes a variable called @customerid. Therefore, select statements need to include (@customerid).
When performing a select statement ...
-4
votes
1
answer
291
views
Function that receive table name as input variable to be used in CROSS APPLY
I need to create a Db function that returns a list of GUID, but from different tables.
So I'm trying to create a db function, that get as input the name of the table, and return a list (table with ...
1
vote
1
answer
98
views
I am trying to create a UDTF in Snowflake but I get an error on RETURNS TABLE even though it matches the syntax
CREATE OR REPLACE FUNCTION DQ_IS_NULL ("SCHEMA_NAME" VARCHAR(500), "TABLE_NAME" VARCHAR(500), "COLUMN_NAME" VARCHAR(500))
RETURNS TABLE (TABLE_NME VARCHAR(500), ...
1
vote
1
answer
2k
views
bigquery sql table function with string interpolation
I am trying to write a BigQuery SQL function / stored procedure / table function that accepts as input:
a INT64 filter for the WHERE clause,
a table name (STRING type) as fully qualified name e.g. ...
0
votes
1
answer
749
views
Use table function to perform actions on every row of data
I have a query that returns multiple records based on the Number ID (parameter) passed into it. I would like to create a table function which takes in "num_id" (number datatype) as a ...
0
votes
0
answers
2k
views
Create Dynamic Query in SAP using Table Function
I am trying to create Dynamic SQL query using Table Function, so that it can be consumed in ABAP CDS views. For same I have developed an ABAP Class & defined a method "Get_data".
CLASS-...
0
votes
0
answers
63
views
How to insert data from the function into another table using procedure in oracle
I would like to insert the return type of a function into a table using a procedure. Function is returning a collection as its output. We are calling that function from a select statement inside the ...
1
vote
1
answer
68
views
Unexpected behaviour using table functions over multivalued columns with same length
Using table functions I thought that you get new rows associated with the current row, each new row may have more than one column, and each column contains a single value of the values contained in ...
0
votes
1
answer
68
views
Oracle 12c table function to select subset of rows with FOR UPDATE SKIP LOCKED
I have a requirement to return a subset of rows from a table using FOR UPDATE SKIP LOCKED. Based on application parameters this subset may or may not be ordered by a column. I can't use ROWNUM since ...
0
votes
0
answers
79
views
How can I enable the "GROUP BY" aggregation dimension as the input for a function created in BigQuery
I need to create a table with the same aggregations at multiple different levels in BigQuery, for example:
SELECT
dimension_a,
dimension_b,
SUM(value) AS value
FROM mydataset.table
GROUP BY ...
1
vote
1
answer
238
views
snowflake UDTF update array at specific index
i'm very new to JS especially in snowflake and i am trying to achieve a very simple thing - i would like to update an array according to an index for each row.
this is my code:
CREATE TABLE T1(C1 INT);...
2
votes
1
answer
529
views
Snowflake table and generator functions does not give expected result
I tried to create a simple SQL to track query_history usage, but got into trouble when creating my timeslots using the table and generator functions (the CTE named x below).
I got no results at all ...
0
votes
1
answer
73
views
AnyLogic: Is it possibile to multiple/sum/subtract/...respectively link two TableFunctions in AnyLogic?
I have two TableFunctions f1: arguments1 -> values1 and f2: arguments2 -> values2 given via their arguments[] and values[] arrays. I want to link them to a new TableFunction g, so that:
The ...
0
votes
2
answers
158
views
How to return thousands of ids from a function accepting input to a select query
Create or replace function f(v_input nvarchar2)
Return t_table
Is
v_table t_table;
BEGIN
Select id bulk collect into v_table from table1 where "USER"=v_input ;
Return v_table;
End;
/
...
0
votes
1
answer
117
views
Crosstable on multiple rows in PostgreSQL
Hi I want to know how can do a pivot table with crosstable in a table like:
user_id
action
time
1
a
2022-01-01 12:30
1
b
2022-01-01 12:40
1
b
2022-01-01 12:50
1
c
2022-01-01 13:00
1
c
2022-01-01 ...
1
vote
1
answer
3k
views
Bigquery - parametrize tables and columns in a stored procedure
Consider an enterprise that captures sensor data for different production facilities. per facility, we create an aggregation query that averages the values to 5min timeslots. This query exists out of ...
0
votes
2
answers
112
views
How can I write a pivot that takes this form of data to the result desired?
I have a table that looks like this
CREATE TABLE foo (id, name, category)
AS VALUES
( 1, 'name1.1', 'cat1.1.1'),
( 1, 'name1.2', 'cat1.1.1'),
( 1, 'name1.3', 'cat1.2.1'),
( 2, 'name2.1', 'cat2....
-4
votes
1
answer
2k
views
Possible to create a function that returns more than one column?
Does SQL have the concept of a function that returns multiple columns, outside of a table function? Here would be an example:
SELECT
id,
SPLIT_NAME(name, ' ')
FROM
table
And I want the ...
0
votes
1
answer
197
views
How to use DDL statements inside java script UDTF in snowflake
I am trying to use DDL statement like select columns from tables inside java script UDTF..
I am able to achive inside plain UDTF as below
create function returntable()
returns table(COL1 varchar(...
1
vote
2
answers
4k
views
How do you install the PostgreSQL tablefunc extension?
I am not able to run the following command in my PostgreSQL server:
CREATE EXTENSION tablefunc;
When I run this command, I get the following error message:
ERROR: could not open extension control ...
0
votes
1
answer
136
views
SQL: Apply and union table function recursively
I'm using SQL Server Management Studio 18.
I have a function that takes a table name as a parameter and outputs a table with info about other tables that have the same columns in it. Each table has a ...
2
votes
2
answers
174
views
Oracle - Grouping Sets and Pipelined Table Functions (expected NUMBER got ROW)
I'm working on a report with summary logic using GROUPING SETS, but I'm getting this error:
SELECT c1, c2, c3, SUM(c4) AS MySum
FROM TABLE(get_data()) src
GROUP BY GROUPING SETS ((c1, c2, c3), (c1, c2)...
1
vote
1
answer
1k
views
Oracle - Table function that returns dynamic column names
I'm building a report that should generate a dynamic list of columns based on the requested years, i.e. 2000 to 2002. The user should be able to run the report via a SELECT statement like so:
SELECT *...
0
votes
2
answers
1k
views
Oracle - Return a result set via a SELECTable function without explicit object / table types
I'm trying to find a simple and easy-to-maintain way to return a result set via a function that can be referenced in a SELECT statement like this:
SELECT u.UserId, u.UserName, up.ProfileName
FROM ...
2
votes
1
answer
1k
views
Insert into table collection type in table function without using explicit cursor in PL/SQL
I write the following code in PL/SQL and it works:
declare
type deliveryStat_o IS record (
warehouseName varchar2(20), shipMode char(30), thirty_days number, sixty_days number,
...
0
votes
1
answer
357
views
how to calculate the lift value of table in R?`
library(readr)
data1<-read_csv(".../file1")
data2<-read_csv(".../file2")
table2<-table(data1$`_SEGMENT_`,data2$`_SEGMENT_`,data1$Subscribed)
This is the frequency table2 ...
-1
votes
1
answer
204
views
Create function that returns table in SQL
I wanted to create view with some logic like using (for loop , if .. else) but since that's not supported in SQL
I thought of creating table function that takes no parameter and returns a table.
I ...
0
votes
1
answer
966
views
How to edit records in SQL-Server stored procedure
I would like to know the secret of how SQL statements in SQL-Server go from being read-only to editable. Right click on any table, and the interface gives the option of "Selecting" or &...
1
vote
1
answer
5k
views
Table Function to get first row of MSEG in CDS view
I'm trying to build a CDS view that uses various fields from invoices in VBRK and VBRP. Another requirement is to display the price listed in the original purchase order (for example, I'm selling ...
0
votes
1
answer
770
views
How to overcome grouping() function not supported by HANA Table UDF?
I have written some custom logic in HANA anonymous block. I used grouping function somewhere in the middle as a core. It worked well and the result was satisfying.
Once I tried to industrialize it ...
1
vote
1
answer
1k
views
Get the last entered rows of each distinct value of a column
Let the a table be:
Product ID | Date of Sale | Time of Sale | Buyer ID | ...
------------------------------------------------------------------
1 | 2019-01-09 | ...
1
vote
1
answer
54
views
How to retrieve multiple result rows in a Postgres functions?
Actually I just want to return more than one result rows by using the code below. But I have received only one row of the result set while calling the function (Date is not an issue because I have ...
0
votes
1
answer
906
views
Consuming Oracle Table Function from Stored Procedure
I'm working with an ERP database that stores a lot of data in multi-year tables. (Each new year a new table is created to hold the data for that year) We have a requirement to be able to query and ...
0
votes
1
answer
47
views
Is there any way to call PostgreSQL tablefunc module in R?
I have some PostgreSQL/PostGIS tablefunc queries that I want to call in R environnement. Is there any way to perform this?
Ex :
dbGetQuery(con, "SELECT * FROM CROSSTAB(
'SELECT factor1, factor2, ...
2
votes
2
answers
942
views
Dynamic Oracle Table Function for use in Tableau
We have a large amount of data in an Oracle 11g server. Most of the engineers use Tableau for visualizing data, but there is currently not a great solution for visualizing straight from the Oracle ...
-1
votes
2
answers
8k
views
DB2 - how to call a stored procedure that returns a result set in another user defined table function
I have a db2 stored procedure that takes in some parameters, gets some data from somewhere and then returns a result set through a cursor.
Now I want to write a table function in db2, that will call ...
4
votes
2
answers
1k
views
Why is the performance of table value function better than select direct statement?
I use AdventureWorks2012 and do a test.
and my question: Why is SELECT statement directly performance lower than table values function. I only put SELECT statemnt into table value function and ...
1
vote
0
answers
66
views
Modifying Parameter in Table Value Function - Datetime - Local to UTC
I am working in a type 2 data vault and currently working on a function to try and simulate a data cube for certain users to do fast data pulls from specific snapshots.
At the moment i can modify ...
0
votes
0
answers
49
views
SQL Server 2012: Procedure is taking very long time to execute when I call a function within it with parameters but it doesn't if a pass raw values
I am asking wondering if any of you can help me with ideas. You see, I am tuning a store procedure, call it proc1, and it calls internally a table function. The procedure have a table input parameter (...
0
votes
1
answer
26
views
Check existence of given text in a table
I have a course code name COMP2221.
I also have a function finder(int) that can find all codes matching a certain pattern.
Like:
select * from finder(20004)
will give:
comp2211
comp2311
comp2411
...
0
votes
1
answer
83
views
How to get dynamic number of columns in Postgresql crosstab
I'm new to the postgresql crosstab function and have tried out a few solutions here on SO but still stuck. So basically I have a query that result in an output like the one below:
|student_name|...
0
votes
2
answers
601
views
Configure Entity Framework to call a SQL Server table function instead of a table on a specific entity
I have a table of entities (let's say documents), where each document may have a different entity connected to it (let's say permission). A permission has a foreign key to the document table.
Example:...
0
votes
0
answers
52
views
two different operation in different cases sql table function
I want to program a function that sees how much time the client spent of time without paying the seller. My problem is that I'm kind of confused because this is the function that already programmed:
...
2
votes
2
answers
3k
views
In PL/SQL how do you return the results of a query from a User-Defined Function?
I'm coming to Oracle 11g from SQL Server, and I'm trying to use SQL Developer to create a simple function (getIDs) that will return the results of a query (SELECT id FROM employee). Nothing that I've ...
0
votes
0
answers
669
views
connectby of PostgreSQL gives invalid return type error
I'm trying to recreate the following connect by sql of Oracle's HR Schema in PostgreSQL.
select employee_id, manager_id, lpad(' ',level*2,' ')||first_name name, level from employees
start with ...
0
votes
0
answers
339
views
DRG-10849 - Only when calling from higher level function
I have several tiers of table functions which are used to perform a search. I have a CTXCAT index on the relevant tables.
When calling one particular function directly I recieve no errors and get the ...
0
votes
1
answer
68
views
How can I do this faster than cursor?
I have 2 tables:
first is : dept
second is : payment
I want to compare these tables and make one result table .
Tables include :
table debt:
customerid order amount
1 1 30
...