FAQ Database Discussion Community


How can I extract a specific Letter(s) and numbers from a text string via VBA Or excel Formula

excel,vba,excel-vba,user-defined-functions,data-extraction
I would like to extract a combination of text and numbers from a larger string located within a column within excel. The constants I have to work with is that each Text string will either start with a A, C or S, and will always be 7 Characters long the...

Running SQL Server 2012 Express Scalar Function in View

sql,function,view,user-defined-functions,sql-server-2012-express
My SQL guru is in Costa Rica for the week and have a problem I don't know how to solve. I have four simple tables and one function. For simplicity sake I'll remove any fields not required to understand what I need. Table1: PRIMARY_ITEM_ID, INVENTORY_ITEM_ID Table2: Table2ID, INVENTORY_ITEM_ID, Table3ID Table3:...

Select from Table Valued Function nhibernate

c#,sql-server,nhibernate,hql,user-defined-functions
I need a little help on this. I'm trying to use a table-valued function in a select, but I got the error that this is not mapped. dbo.FnListEvnt is not mapped [from dbo.FnListEvnt(:dt, :id, :code) ] Function CREATE FUNCTION [dbo].[FnListEvnt] (@DT DATETIME, @ID INT, @CODE VARCHAR (4)) RETURNS @RESULTADO TABLE...

How to properly pass array pointers to function in C

c,pointers,computer-science,user-defined-functions
A different question may have been asked about this program, however in this C code I have three functions: one to print records, one to add a record and one to delete a record. What I don't understand is why the (add) and (delete) do not make changes in the...

User defined fucntion for String?

java,string,user-defined-functions
I have following code in Java: public class StringSearch { public static void main(String[] args) { String s = new String("I love my school. I love to play basketball. It is lovely weather. Love is life."); System.out.println(s); int i = -1; int count = 0; System.out.print("Counting love:"); do{ i =...

calling functions without objects or passing values

java,oop,user-defined-functions
I want to call a user defined function inside a function without creating an object or passing any value to the called function. Is there any possible way to do that? consider the following code import java.io.*; public class sorting { int number[]=new int[5]; void input()throws IOException { BufferedReader in=new...

Write a user defined fillna function in pandas dataframe to fill np.nan different values with conditions

python,pandas,dataframes,user-defined-functions,nan
Considering the following pandas dataframe: import pandas as pd change = [0.475, 0.625, 0.1, 0.2, -0.1, -0.75, 0.1, -0.1, 0.2, -0.2] position = [1.0, 1.0, nan, nan, nan, -1.0, nan, nan, nan, nan] date = ['20150101', '20150102', '20150103', '20150104', '20150105', '20150106', '20150107', '20150108', '20150109', '20150110'] pd.DataFrame({'date': date, 'position': position, 'change':...

Pass a table and return a table to a stored procedure or function?

sql,sql-server,stored-procedures,user-defined-functions
I would like to pass a table to either a UDF or stored procedure and then have it process the data and return the sensitivity, specificity and 95% Upper/Lower Confidence Intervals (for each) from the table I pass to it. Basically, from a table I need to calculate and return...

Get Numbers Range from Table in MSSQL

sql-server,sql-server-2008,sql-server-2008-r2,user-defined-functions
I have a table in MSSQL 2008R2: ID | PinAddress ------------------------------------- 1 | 1 1 | 2 1 | 3 1 | 4 1 | 5 1 | 6 1 | 16 1 | 31 2 | 55 2 | 56 2 | 57 2 | 81 2 | 82...

Slight adaptation of a User Defined Function

regex,excel-vba,user-defined-functions,udf
I would like to extract a combination of text and numbers from a larger string located within a column within excel. The constants I have to work with is that each Text string will •either start with a A, C or S, and •will always be 7 Characters long •the...

Python — nondimensionalize

python,user-defined-functions
I'm writing a python module to allow me to make unit-based calculations, and I'm trying to implement unit-sensitive integration of functions. My idea is basically to write a wrapper for scipy.integrate -- take the function and arguments given, including the limits of integration, nondimensionalize them all, pass to scipy.integrate.quad or...

Using result of Stored Procedure with dynamic query in another Stored Procedure with dynamic query

sql-server,tsql,stored-procedures,user-defined-functions
I runned into a problem while creating a stored procedure that uses user-defined types and builds a dynamic query that is to be executed on the end of the stored procedure. I have done this before, but this time it is different. I am building a dynamic aggregated SELECT statement...

R Code: using UDF with multiple arguments for apply function

r,user-defined-functions,apply,udf,multiple-arguments
My UDF: testfn = function(x1, x2, x3){ if(x1 > 0){y = x1 + x2 + x3} if(x1 < 0){y = x1 - x2 - x3} return(y) } My Sample Test set: test = cbind(rep(1,3),c(2,4,6),c(1,2,3)) Running of apply: apply(test, 1, testfn, x1 = test[1], x2 = test[2], x3 = test[3]) This...

Program control passed to function, but the statements in the function block doesn't get executed

c,function,pointers,multidimensional-array,user-defined-functions
#include<stdio.h> int findMax(int **,int m,int n); int main() { int n; int a[20][20]; int i, j, max; printf("\nEnter the number of rows in the array"); scanf("%d", &m); printf("\nEnter the number of columns in the array"); scanf("%d", &n); printf("\nEnter the elements of the matrix"); for(i=0; i<m; i++) { for(j=0; j<n; j++)...

SELECT table value function into @temp_table

sql-server,tsql,user-defined-functions
Is there a way of selecting the results of a table value function into a table variable using MSSQL Server 2008? Lets say I have a table value function that returns the following: id | data --------- 1 | A 2 | B 3 | C And I declare a...

Use a UDF as the default value in a table column in SQL Server

sql-server,user-defined-functions,default-value,dml,udf
I created a scaler UDF (called sCurrentAppUser()) in SQL Server 2012 Express and I would like to use this UDF as a default value when defining a table. But every time I try, I get an error of "'sCurrentAppUser' is not a recognized built-in function name." Since I can't post...

Constraint with multiple tables. UDF?

sql-server,sql-server-2008-r2,constraints,user-defined-functions
I have two tables: table A and table B. These two tables are linked with a primary key in A and a foreign key in B. Table A: CREATE TABLE [BIO].[table_A]( [table_A_id] [int] IDENTITY(1,1) NOT NULL, [type_id] [nvarchar](2) NOT NULL CONSTRAINT [PK_table_A] PRIMARY KEY CLUSTERED ( [table_A_id] ASC )) Table...

how to find user defined functions in python script

function,python-2.7,user-defined-functions,built-in
A python program has builtin functions and user defined functions in it. I wish to list out all the user defined functions in that program. Could any one suggest me the way to how to do it? example: class sample(): def __init__(self): .....some code.... def func1(): ....some operation... def func2():...

Extract text which begin with the same two characters and end in a numeric character

regex,vba,excel-vba,user-defined-functions,udf
I would like to extract a code from a larger extract of text, the constants I have is the Code will either start with WP or MD and end in a Numeric value and example of the patterns the code can be in are below; WP0053 WP053 WP_053 WP_0053 WP...

Excel VBA User-Defined Function: Get Cell in Sheet Function was Called In

excel,vba,excel-vba,user-defined-functions
I have a user-defined function in Excel that I run in multiple sheets. I am trying to use Cells(i, j) to pull the value of cells by their row and column in the sheet in which my function is called. Instead, Cells(i, j) pulls the value of cell [i,j] in...

Getting NullPointerException when using Spark-submit [duplicate]

scala,apache-spark,user-defined-functions,apache-spark-sql
This question already has an answer here: What is a NullPointerException? [duplicate] 4 answers I have some code that reads a data file into a Spark dataframe, is supposed to filter out any rows with nulls in a certain field, and writes out the result. When I run it...

Replace column text from a list of reserved words

sql-server,tsql,replace,user-defined-functions,table-variable
I have a table variable which contains a list of words that I want to replace from query results. I want to search for any of these 600 words in the table variable. I did 3 just for this example. Then, I want to replace the word if it's found....

Get work time in minutes based on shift schedule

sql,sql-server,sql-server-2008,ms-access,user-defined-functions
In production we have 3 shifts. Each Shift timing is described in table tbl_ShiftSched: WT - work time, PT - break time. ShiftTmID - schedule for 2 and for 3 shifts. I am looking for easy way to get work time in minutes having start and end time. For example,...