user-defined-functions

user-defined scalar function to generate computed column

雨燕双飞 提交于 2020-03-04 21:33:53
问题 I have databse having 2 tables i.e (Installment and InstallmentPlan). In the installment table there are number of columns. I want to add one new computed column name SurchargeCalculated (SC). The calculation for SC is this SC = (Installment.Amount * Installment.days * (InstallmentPlan.InstPercentage /365 /100)) I have created user-defined function SurchargeCal having 3 parameters which are Amount, days and InstPercentage. The problem is that when i add computed column in installment table

running async JS functions on BigQuery with #standardSQL

ぐ巨炮叔叔 提交于 2020-03-01 18:35:16
问题 Now that BigQuery supports async on #standardSQL, how can I convert this #legacySQL function to run on #standardSQL? #legacySQL SELECT SUM(s) FROM js(( SELECT FLOOR(RAND()*100000) group, NEST(requests) as x FROM ( SELECT requests, content_size FROM [fh-bigquery:wikipedia.pagecounts_201205] ) GROUP BY group) , group, x , "[{name:'s', type: 'float'}]", "function (row, emit) { const memory = new WebAssembly.Memory({ initial: 256, maximum: 256 }); const env = { 'abortStackOverflow': _ => { throw

Redshift UDF AES ENCRYPT - No module named Crypto.Cipher._mode_ecb

╄→гoц情女王★ 提交于 2020-02-26 02:42:12
问题 LIBRARY create library pycryptodome language plpythonu from 's3://aws_python/library/pycryptodome/pycryptodome.zip' credentials 'aws_iam_role' region as 'aws-region'; FUNCTION CREATE OR REPLACE FUNCTION test.aes_encrypt(input varchar(max)) RETURNS varchar(max) STABLE AS ' if input is None: return None import pycryptodome encrypt=True secret_key = b''abcdefghijklmnop'' remainder = len(secret_key) % 16 modified_key = secret_key.ljust(len(secret_key) + (16 - remainder))[:32] remainder = len

How can I get ColdFusion methods to return numeric values as strings in JSON format?

别等时光非礼了梦想. 提交于 2020-02-05 08:19:33
问题 ColdFusion 8 This is as simple pseudo-code as there can be: <cffunction name="badJSON" access="remote" output="true" returntype="string" returnformat="JSON"> <cfreturn "06762" /> </cffunction> Results in: 6762.0 It should result in: 06762 Is there a way to get JSON to not convert my value to numeric? I know I can use WDDX, but that is out of the question. 回答1: Have you tried this? return javaCast("string", "06762") 回答2: Ok, so there is no real way to do this in CF8. The workaround is to add a

SQL CLR: Streaming table valued function results

流过昼夜 提交于 2020-01-31 18:16:27
问题 My issue is very similar to this issue. However, I'm using SQL Server 2005 Service Pack 2 (SP2) (v9.0.3042) and the solution posted there does not work for me. I tried using both connection strings. One is commented out in my code. I realize I can store all the results in a List or ArrayList in memory and return that. I've done that successfully, but that is not the goal here. The goal is to be able to stream the results as they are available. Is this possible using my version of SQL Server?

Passing parameter into function to create variable name

寵の児 提交于 2020-01-25 06:53:39
问题 I want to be able to use some global variables in my Workbook and in the ThisWorkbook Code I have declared the following varaibles Public position_1 as string Public position_2 as string If I want to see the value of those variables I believe the need to be fully qualified so Debug.Print ThisWorkbook.position_1 Debug.Print ThisWorkbook.position_2 I have written a UDF which I will pass in an integer to represent which variable I am looking for. I will only be passing in a single number and not

Passing parameter into function to create variable name

送分小仙女□ 提交于 2020-01-25 06:53:05
问题 I want to be able to use some global variables in my Workbook and in the ThisWorkbook Code I have declared the following varaibles Public position_1 as string Public position_2 as string If I want to see the value of those variables I believe the need to be fully qualified so Debug.Print ThisWorkbook.position_1 Debug.Print ThisWorkbook.position_2 I have written a UDF which I will pass in an integer to represent which variable I am looking for. I will only be passing in a single number and not

Unexpected @@rowcount behavior inside an UDF in MS SQL 2019

时光总嘲笑我的痴心妄想 提交于 2020-01-23 01:39:06
问题 here's my sample code drop function rowcount_test go CREATE FUNCTION dbo.rowcount_test () RETURNS INT AS BEGIN DECLARE @v INT SELECT @v = 1 return @@ROWCOUNT END GO grant exec on dbo.rowcount_test to public go SELECT dbo.rowcount_test() It gives 1 when executed by mssql 2017 (and earlier) It gives 0 when executed by mssql 2019 It gives 1 when executed by mssql 2019 (Standard edition) with a db put to the 2017 compatibility mode It's never been a problem before... Is it a kind of setting

Profiling statements inside a User-Defined Function

淺唱寂寞╮ 提交于 2020-01-21 15:56:06
问题 I'm trying to use SQL Server Profiler (2005) to track down some application performance problems. One of the calls being made is to a table-valued user-defined function. This function wraps a select that joins several tables together. In SQL Server Profiler, the call to the UDF is logged. However, the select that underlies the UDF isn't being logged at all. Because of this, I'm not getting useful data on which tables & indexes are being hit. I'd like to feed this info into the Database Tuning

Where are user defined functions stored in MS SQL Server 2008?

偶尔善良 提交于 2020-01-21 11:21:06
问题 I want to be able to see the code associated with the User Defined Function. I can see the name etc by doing the following, select * from information_schema.routines where routine_type='function' Which is all fine and dandy but I can actually see the code. Do I need to do this in SQL Server Management Studio, and if so how? Thanks for all the help, I'm a noob when it comes to IIS/MS SQL stuff. 回答1: In SQL Server Management Studio (SSMS) look under the Programmability\Functions branch. Since