Questions tagged [functions]
A function performs some specified work, usually taking parameters as input. In terms of databases these may be specific to SQL or to the database vendor.
763 questions
1 vote
1 answer
87 views
UDF vs other solutions for checking valid data
I have many 'title' and 'name' columns in different tables that have the same set of restrictions about what characters can be inserted and what not. For example, names should only allow alphabet plus ...
-2 votes
2 answers
119 views
Dayofweek vs weekday [closed]
Why does MariaDb use these terms differently? #drop table dbstructA; create table dbstructA(datum date); insert into dbstructA values('2025-01-01'); insert into dbstructA values('2025-...
2 votes
1 answer
102 views
How do I get the value of PI in Db2?
Some DBMSs have a pi() function to give the value of π. I can’t find the equivalent for Db2. I can use radians(180), I suppose, but is there something more direct?
0 votes
1 answer
82 views
DB2 LUW SQLCODE=-740, SQLSTATE=51034 on UPDATE with function modifies sql data
I have a user-defined function that modifies sql data. It inserts into one table and returns the ID of the returned row. Trying to use it like this UPDATE table_X SET REV = REVISION(:timestamp, :user) ...
3 votes
1 answer
120 views
Permission denied for index idx_my_index on using pg_prewarm
I work on a project that uses PostgreSQL. Some analytic queries take a lot of time, and we would like to prewarm two indexes and one table. Here are the prewarming queries: SELECT pg_prewarm('...
0 votes
1 answer
101 views
Custom Function Filters
I have a function that currently uses 3 parameters: CREATE FUNCTION dbo.RatesReport (@StartTapeDate DATE, @StartFcbVersionId int, @StartSvbVersionId int) SELECT * FROM dbo.DataTapes t WHERE t.TapeDate ...
2 votes
1 answer
273 views
Using a function as argument to GRANT fails with syntax error
I can't get GRANT to take current_database() as argument. These all fail with the same error: GRANT ALL PRIVILEGES ON DATABASE current_database() to justintestin; GRANT ALL PRIVILEGES ON DATABASE (...
-1 votes
2 answers
347 views
LEFT JOIN LATERAL with a function result, how to prevent unnecessary function calls?
I have a costly function and it only provides relevant data when certain conditions are met. That data is inserted into the result through a LEFT JOIN LATERAL as shown below. As it works now, the ...