Questions tagged [sql-function]

A function defined in a relational database system. Most RDBS's include numerous built-in functions and also allow for the creation of additional custom functions.

908 questions
4
votes
3 answers

Call dynamic function name in SQL

Is it possible to call a function with a dynamic name in SQL? For example: SELECT functionid, (SELECT results FROM dbo.Function_*functionid*) AS results FROM List_of_Functions This would call a different function for every row in the table…
William
  • 386
  • 5
  • 16
3
votes
1 answer

How to manipulate ntext type data in stored procedure of SQL Server 2008

I was wondering how to manipulate ntext datatype in stored procedure of SQL Server 2008. We have a column of type ntext in a table. We have to fetch data from that column, parse the data, change and then store it back. For all of the above task we…
Rahatur
  • 3,147
  • 3
  • 33
  • 49
3
votes
2 answers

Postgresql - error returned more than one row from function

My first post in Stackoverflow. I am trying to learn Postgresql (12) "on the job" and seem to be stuck on a rather simple issue. I have a simple database with 12 rows. In one column (int) there is a 4-digit number [representing a year]. I am…
3
votes
1 answer

How to add trailing spaces when concatenating two columns?

I am trying to find a way to preserve a space within SQL concatenation. For context: A table I am selecting from a table with a single concatenated key column. Concatenated keys respect spaces. Example: BUKRS(4) = 'XYZ ', WERKS(4) = 'ABCD' is…
Zero
  • 1,562
  • 1
  • 13
  • 29
3
votes
3 answers

PostgreSQL - why can't I ORDER BY a function of a column?

I'm trying to get something I thought should be relatively simple (it works in Oracle and MySQL). The PostgreSQL fiddle for the code below is available here - just change the server to check out the others. Very simple test case: CREATE TABLE x ( …
Vérace
  • 854
  • 10
  • 41
3
votes
0 answers

How to add multiple Standard SQL functions within JPQL

Is it possible to add multiple SQL functions within JPQL ? (Spring Boot application) By using MetadataBuilderContributor I succeded to add only one. Is there any way to add more ? Current code: public class SqlFunctionsMetadataBuilderContributor…
Michael Bat
  • 101
  • 9
3
votes
0 answers

Is there a way to keep postgres functions synced with a git repository?

Using postgresql functions is convenient, but keeping them updated is rather difficult. Ideally one would want to keep this separate from database migrations (possibly up to some version constraint mechanism in the migrations), and be able to work…
saolof
  • 1,097
  • 1
  • 15
  • 12
3
votes
1 answer

why postgres functions returns result in one column?

I have a simple PostgreSQL function which I aspect should return values into separate columns -115 and 101000005458E6258... but it returns one column where two values are separated by a comma -115,101000005458E6258.... What is wrong with my…
3
votes
1 answer

PostgreSQL function : relation does not exist error

I am getting below error while calling Postgresql function with argument containing dot (.) operator. SQL Error [42P01]: ERROR: relation "es.article_data" does not exist Where: PL/pgSQL function es.getrowcount(text) line 6 at EXECUTE.... Query:…
srp
  • 619
  • 7
  • 18
3
votes
2 answers

Use Record As Function Argument in RETURNING Statement

I have a plpgsql function that takes a record as an argument. I would like to call this function in the RETURNING statement of an insert, but am unsure what to put as the argument (* does not work) i.e., -- Postgres 12 INSERT INTO some_table (a, b,…
Avocado
  • 871
  • 6
  • 23
3
votes
3 answers

What is the simplest way to get the least value and second least value from multiple columns (MIN function does not work this)?

Below table is from Teradata database SELECT sku.Item_id, sku.Item_length, sku.Item_width, sku.Item_heigth, FROM Category_item sku Item_id | Item_length | Item_width |Item_heigth ------------------------------------------- 104174 8 …
WeldaSudha
  • 39
  • 5
3
votes
1 answer

Postgresql corrupt data in input function of custom base data type

I've created a custom type, gp to model the DND 5e currency system. I have defined custom input and output functions in gp.c: #include "postgres.h" #include #include "fmgr.h" #include #ifdef…
ocket8888
  • 1,060
  • 12
  • 31
3
votes
1 answer

How can you create a table (or other object) that always returns the value passed to its WHERE-clause, like a mirror

There is a legacy application that uses a table to translate job names to filenames. This legacy application queries it as follows: SELECT filename FROM aJobTable WHERE jobname = 'myJobName' But in reality those jobnames always match the filenames…
bvdb
  • 22,839
  • 10
  • 110
  • 123
3
votes
1 answer

PostgresSql - Split aggregated, comma separated values into separate columns iniside query - with Amazon Aws & PostgreSql 9.6

I have the following situation where I need to solve the question of displaying data inside a column, for each data-part of a concatenated string. I'm relatively new to this and the sad thing is I was not able to transfer other already read…
3
votes
1 answer

Workaround to query array column as rows in Impala

In Hive, I can use explode function but how to do that in Impala? I read this but still have no clue: Is there a function equivalent to Hive's 'explode' function in Apache Impala? This is how I created the table in Hive: create table tb (arr_col…
HP.
  • 19,226
  • 53
  • 154
  • 253