Questions tagged [user-defined-functions]

A function provided by the user of a program or an environment most often for spreadsheet type applications or database applications. Use [custom-functions-excel] for Excel and [custom-function] for Google sheets. Specify a programming language tag as well: [google-apps-script], [javascript], [sql], [tsql], etc. as well as a tag for the application: [excel], [google-spreadsheet], [sql-server] etc.

In the context of a programming language or an environment, a User Defined Function (UDF) is a function that is created by a user to perform a specific task (as opposed to a function that is intrinsic to the environment, built into the programming language or environment).

Spreadsheet applications like Excel and Google Sheets calls these "custom functions".

Microsoft also uses the term User Defined Functions with . The tag may also be applicable. See What is the need for user-defined functions in SQL Server?

Use:

4875 questions
2
votes
3 answers

SQLite order of operations in a query

I have a query of the form: SELECT akey, avalue, expensiveop(akey) FROM atable WHERE avalue < SOME_CONSTANT; It appears that expensiveop()--which is a user-defined function that takes a fair amount of time to execute--gets called for all rows in…
laslowh
  • 8,482
  • 5
  • 34
  • 45
2
votes
1 answer

T-SQL User Defined Function or similar to calculate Max Value (Date) from a list of values

Suppose I have a source that I have to query like this: Select Fields from TableA A join TableB B on A.SomeField = B.SomeField join TableC C on B.SomeField = C.SomeField Join TableD D on C.SomeField = D.SomeField Where CustomMaxDateFunction…
2
votes
1 answer

pig load udf for loading files from several sub directories

I want to write a custom load udf in pig for loading files from a directory structure. The directory structure is like an email directory.It has a root directory called maildir.Inside this we have the sub-directory of individual mail holders.Inside…
Shrey Shivam
  • 1,107
  • 1
  • 7
  • 16
2
votes
2 answers

Array formula result concatenated into single cell

Is it possible to take the return values from an array formula and concatenate them into a single cell? For example, I have a simple spreadsheet with rows for project tasks which looks like this: Task # Description Blocked on …
bshacklett
  • 1,802
  • 5
  • 23
  • 45
2
votes
1 answer

Keep assigned objects in workspace through a function

I am trying to keep an assigned object from a function (building a ts function to begin to model a univariate process, simple I know!). I am having trouble finding a method to keep objects in my workspace. It works fine just using a for loop but I…
Murray
  • 23
  • 3
2
votes
2 answers

PIG UDF handle multi-lined tuple split into different mapper

I have file where each tuple span multiple lines, for example: START name: Jim phone: 2128789283 address: 56 2nd street, New York, USA END START name: Tom phone: 6308789283 address: 56 5th street, Chicago, 13611, USA END . . . So above are 2 tuples…
2
votes
1 answer

Issue while rounding decimal fileds in C++ using setprecision

Possible Duplicate: Does setprecision in c++ round? If so why am I seeing this? Here is the function I'm using char* round(double value, int decimal_places) { decimal_places = decimal_places+1; std::stringstream s2; s2 <<…
2
votes
1 answer

matlab user defined function, how to create and call them

I have written a code in matlab script. I need to finish it up by creating a Function for center. Here is the sample code i written while(1) % infinite loop trigger(obj); im=getdata(obj,1); %get the image trigger(obj);…
user1827647
2
votes
1 answer

When xlCoerce returns a value, does it evaluate the formula in a cell again?

I had an issue when I was making a simple UDF in C# with ExcelDna The function uses this: var reference = XlCall.Excel(XlCall.xlfCaller); string oldValue = ((ExcelReference)reference).GetValue().ToString(); It would cause circular reference…
colinfang
  • 20,909
  • 19
  • 90
  • 173
2
votes
5 answers

TSQL function to compare two strings

Can anyone give me some sample TSQL code to compare two email addresses to check they are equal or not? CLR functions are not an option. I tried that but our DBA for some reason is totally against using CLR functions in SSMS. I know how to get the…
dotnetdev_2009
  • 722
  • 1
  • 11
  • 28
2
votes
1 answer

SQL function "RETURNS TABLE" syntax error in PostgreSQL 8.1

In a user defined function how do you return a table formed from the projection of joining other tables? Here is a simple example CREATE FUNCTION something123(character varying(100)) RETURNS TABLE (a integer, b character varying(300)) AS $$ SELECT…
Celeritas
  • 14,489
  • 36
  • 113
  • 194
2
votes
2 answers

creating a user defined function that doesn't return anything

I am trying to make a user defined function that returns nothing. I have the body: select form from bookings where id=$1 where $1 is the first and only argument the function takes. I've tried create function findBookgins(character varying(100))…
Celeritas
  • 14,489
  • 36
  • 113
  • 194
2
votes
5 answers

String matching in Oracle 10g where either side can have wildcards

Test case schema and data follow as: create table tmp ( vals varchar(8), mask varchar(8) ); insert into tmp values ('12345678',' '); insert into tmp values ('12_45678',' _ '); insert into tmp values ('12345678',' _ '); insert…
2
votes
1 answer

A CLR function equivalent to string.Format in C#

I was looking for a CLR function that will do the same thing as String.Format in C#. As an example, I would like to do the following through a CLR function: String.Format("My name is {0}, and I live in {1}",myName, cityName) I would like to be able…
Sunil
  • 20,653
  • 28
  • 112
  • 197
2
votes
0 answers

Where does mysql save the path for gearman mysql udf files?

I have been trying to use gearman mysql udf. I have downloaded tarball from http://gearman.org/index.php?id=download and installed it with the instructions given on http://gearman.org/index.php?id=mysql_udf_readme I am trying to create the gman_do…
Hussain
  • 5,057
  • 6
  • 45
  • 71