stored-functions

How to view a stored function - SQL Server

被刻印的时光 ゝ 提交于 2019-11-29 00:59:12
问题 Version: SQLServer 8 I would like to view the contents of a stored function in sqlserver, i.e. what exactly the function is doing. None of the options listed here work for me. There doesn't appear to be any database/table called sys.objects. I was able to query the information_table.routines table, but that does not contain the function that I am looking for. My function is located in: DBName.dbo.functionName How can I view the contents of this function? 回答1: You can use sp_helptext command

Why is it not recommended to use server-side stored functions in MongoDB?

早过忘川 提交于 2019-11-28 21:21:30
According to the MongoDB documentation , it isn't recommended to use server-side stored functions. What is the reason behind this warning? I am sure I have stated the list a couple of times despite the Google search result being filled only with people telling you how to do it: It is eval eval has natural abilities to be easily injected, it is like a non-PDO equilivant to SQL, if you don't buld a full scale escaping library around it it will mess you up. By using these functions you are effectively replacing the safer native language of MongoDB for something that is just as insecure as any old

MySQL said: #1415 - Not allowed to return a result set from a function

耗尽温柔 提交于 2019-11-28 14:12:08
问题 Please help me to solve this Error While creating stored function in MySQL's PHPMyAdmin MySQL said: #1415 - Not allowed to return a result set from a function BEGIN SET @pAvg = 0; SET @p1 = 0; SET @p2 = 0; SET @p3 = 0; SET @p4 = 0; IF river > 1 THEN SELECT @P1 := Precipitation FROM abd_2013 where id = 1; SELECT @P2 := Precipitation FROM abd_2014 where id = 1; SELECT @P3 := Precipitation FROM abd_2015 where id = 1; SELECT @P5 := Precipitation FROM abd_2016 where id = 1; SELECT @pAvg := (@p1 +

C# call oracle stored function

▼魔方 西西 提交于 2019-11-28 11:34:18
create or replace function ar_knyga_egzistuoja( id number ) return number is kiekis number; begin select count(*) into kiekis from knygos where kn_id = id; return kiekis; end; C# code: conn.Open(); OracleCommand cmd = new OracleCommand(); cmd.Connection = conn; cmd.CommandText = "ar_knyga_egzistuoja"; cmd.CommandType = CommandType.StoredProcedure; OdbcParameter param = new OdbcParameter(); cmd.Parameters.Add("id", OracleType.Number).Value = id; cmd.ExecuteNonQuery(); var kiekis = Convert.ToString(cmd.Parameters["kiekis"].Value); MessageBox.Show(kiekis); cmd.Parameters.RemoveAt(0); conn.Close()

Is there a PL/SQL pragma similar to DETERMINISTIC, but for the scope of one single SQL SELECT?

时光总嘲笑我的痴心妄想 提交于 2019-11-28 11:11:00
In a SQL SELECT statement, I'd like to execute a function that is deterministic for the scope of that SELECT statement (or transaction would be ok, too): select t.x, t.y, my_function(t.x) from t Many values of t.x are the same so Oracle could omit calling the same function again and again, to speed things up. But if I label the function as DETERMINISTIC , the results may be cached between several executions of this query. The reason why I can't use DETERMINISTIC is because my_function uses a configuration parameter that is changed from time to time. Is there any other keyword I could use? Are

Recursive stored functions in MySQL

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 09:23:53
I'm trying to make a function that recursively builds a path for a specific category CREATE FUNCTION getPath(inId INT) RETURNS TEXT DETERMINISTIC BEGIN DECLARE return_path TEXT; DECLARE return_parent_id INT; SELECT CONCAT('/', name) INTO return_path FROM article_categories WHERE id = inId; SELECT parent_id INTO return_parent_id FROM article_categories WHERE id = inId; IF return_parent_id > 0 THEN SELECT CONCAT(getPath(return_parent_id), return_path) INTO return_path; END IF; RETURN return_path; END When I try to run this function with a category that has no parents (parent_id = 0) it works

How to throw an error in MySql procedure?

☆樱花仙子☆ 提交于 2019-11-28 07:13:06
问题 What is the mechanism to force the MySQL to throw an error within the stored procedure? I have a procedure which call s another function: PREPARE my_cmd FROM @jobcommand; EXECUTE my_cmd; DEALLOCATE PREPARE my_cmd; the job command is: jobq.exec("Select 1;wfdlk# to simulatte an error"); then: CREATE PROCEDURE jobq.`exec`(jobID VARCHAR(128),cmd TEXT) BEGIN DECLARE result INT DEFAULT 0; SELECT sys_exec( CONCAT('echo ',cmd,' | base64 -d > ', '/tmp/jobq.',jobID,'.sh ; bash /tmp/jobq.',jobID,'.sh &>

Why does this MySQL stored function give different results than to doing the calculation in the query?

我们两清 提交于 2019-11-28 00:30:18
This is a question about calculating the distance between two points of latitude and longitude on the earth using a haversine formula, for use in projects where you need to have a 'find my nearest' function. The haversine formula is well discussed and solved in MySQL in this post . I then asked this question about turning it into a stored function so that its available for future projects without having to lookup, remember or re-type the formula in its long form. Its all good. Except my function differs in results (slightly) to just typing the formula directly into the query, all other things

How to use Table output from stored MYSQL Procedure

此生再无相见时 提交于 2019-11-27 22:05:42
I've been looking for the last hour or so and haven't found a conclusive answer to this seemingly simple problem: How do you call a stored MYSQL function/procedure and use its output in further SELECT queries? Although this obviously doesn't work, this is the kind of thing I'd like to have: SELECT P.`id` FROM (CALL test_proc()) AS P Where test_proc() is defined by: DROP PROCEDURE IF EXISTS test_proc; DELIMITER ;; CREATE PROCEDURE test_proc() BEGIN SELECT * FROM `table`; END;; DELIMITER ; Just as an example. I'd be fine with using a stored function as well. This can't be done, directly, because

Functions vs procedures in Oracle

我只是一个虾纸丫 提交于 2019-11-27 18:28:44
can anybody explain what is the main difference between functions and procedures in Oracle? Why must I use procedures if I can do everything with functions? If I cannot call procedure in sql statement, ok, I'll write a function to do the same work. Procedures don't return values, ok, I'll return only sql%rowcount or 1(success), 0(exception) after any dml operation Both procedures and functions can pass variables to calling environment via OUT/IN OUT parameters I heard that the main difference is in performance, 'procedures are faster than functions'. But without any detail. Thanks in advance.