Niños en crecimiento
Me lo contaron en Japon
ernesto el vampiro
Las Fábulas del Capitán Oso Azul
Nopo y Gonta
La casa voladora
jimbo y el jet set
La Familia Ness
CREATE OR REPLACE FUNCTION check_phone_number(text)
RETURNS boolean AS
'
BEGIN
IF NOT $1 ~ e''^\\+\\d{3}\\ \\d{3} \\d{3} \\d{3}$'' THEN
RAISE EXCEPTION ''Malformed string "%". Expected format is +999 999'';
END IF;
RETURN true;
END;
' LANGUAGE plpgsql STRICT IMMUTABLE;
$$
to make it unique - you might want to use $-quotes inside the function body, too. I do that a lot, actually.CREATE OR REPLACE FUNCTION check_phone_number(text)
RETURNS boolean LANGUAGE plpgsql STRICT IMMUTABLE AS
$func$
BEGIN
...
END;
$func$;
***********
The SQL needed to create a new function is CREATE FUNCTION, which has the following basicsyntax:CREATE FUNCTION name ( [ ftype [, ...] ] )RETURNS rtype
AS definition
LANGUAGE 'langname'
The parts of the function definition do not need to be in this order, and a popular choice isto state the language being used before the definition, like this:
CREATE FUNCTION name ( [ ftype [, ...] ] )
RETURNS rtype
LANGUAGE 'langname'
AS definition
int[, ,] array1 = new int[4, 2, 3];
http://stackoverflow.com/questions/12567329/multidimensional-array-vs
www.functionx.com/csharp2/arrays/Lesson02b.htm
look at this link, it gives a clear explanation for Kadane's algorithm.
Basically you have to look for all positive contiguous segments of the array and also keep track of the maximum sum contiguous segment until the end. Whenever you find a new positive contiguous segment, it checks if the current sum is greater than the
max_sum so far and updates that accordingly.
The following code handles the case when all the numbers are negative.
|
2
In MySQL, a function cannot return a table. You would have to use a stored procedure for that. – Dmytro Shevchenko Nov 6 '12 at 13:11
4
What do you mean with "In SQL it's working fine?". You are using SQL.... – a_horse_with_no_name Nov 6 '12 at 13:28
************************
CREATE FUNCTION myFunction(id INT) RETURNS TABLE
BEGIN
RETURN SELECT * FROM board;
END
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TABLE
*********************************
{STRING|INTEGER|REAL|DECIMAL}
CREATE [AGGREGATE] FUNCTION function_name RETURNS {STRING|INTEGER|REAL|DECIMAL}
SONAME shared_library_name
select
resultset you have to define a procedure
but not function
.DELIMITER //
DROP PROCEDURE IF EXISTS myProcedure //
CREATE PROCEDURE
myProcedure( id INT )
BEGIN
SELECT * FROM board
-- add where condition if required
WHERE Col_name = id
;
END
//
DELIMITER ;
call myProcedure( 6 )
|