Questions tagged [create-function]

114 questions
17
votes
6 answers

Incompatible object type when create and alter a table value function in SQL

I'm getting the below error for the given function. Msg 2010, Level 16, State 1, Procedure GetTableFromDelimitedValues, Line 2 Cannot perform alter on 'dbo.GetTableFromDelimitedValues' because it is an incompatible object type. IF NOT EXISTS(SELECT…
ary
  • 597
  • 3
  • 8
  • 20
15
votes
1 answer

How to replace postgresql function body?

In the DOC only described how to change function definition. But I have only function body changed (text between $$ sql $$). How to replace only this function body? Should I use CREATE OR REPLACE syntax to accomplish this?
Eugen Konkov
  • 22,193
  • 17
  • 108
  • 158
8
votes
3 answers

MySQL stored function with nested IF... END IF, error in syntax, right syntax to use near ''

I have a function that I currently use in PHP which compiles a mailing address from separate fields but takes into account different formats used in different regions. I'm trying to replicate this as a MySQL stored function. I realise that it's…
batfastad
  • 1,943
  • 3
  • 27
  • 37
8
votes
1 answer

Execute mysql "create function" statement with PHP

I want to run the following mysql create function statement from PHP: DELIMITER $$ CREATE FUNCTION `myFunc`(`instring` varchar(4000)) RETURNS int(11) NO SQL DETERMINISTIC SQL SECURITY INVOKER BEGIN DECLARE position int; ....here…
Borut Tomazin
  • 8,041
  • 11
  • 78
  • 91
6
votes
1 answer

How to rewrite an example without the use of create_function?

When looking at PHP's create_function it says: If you are using PHP 5.3.0 or newer a native anonymous function should be used instead. I want to recreate same functionality of create_function but using an anonymous function. I do not see how, or…
Dennis
  • 7,907
  • 11
  • 65
  • 115
6
votes
2 answers

Creating MySQL function requires SUPER privileges

I have a simple MySQL function for comparing versions: CREATE FUNCTION `compareVersions` ( versionA VARCHAR(50), versionB VARCHAR(50)) RETURNS INT DETERMINISTIC NO SQL BEGIN DECLARE a1 INT; DECLARE b1 INT; DECLARE c1 INT; DECLARE d1…
comodoro
  • 1,489
  • 1
  • 19
  • 30
6
votes
2 answers

Shouldn't this PostgreSQL function return zero rows?

Given the schema CREATE TABLE users ( id bigserial PRIMARY KEY, email varchar(254) NOT NULL ); CREATE UNIQUE INDEX on users (lower(email)); CREATE FUNCTION all_users() RETURNS users AS $$ SELECT * FROM users; $$ LANGUAGE SQL STABLE; ,…
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
5
votes
1 answer

Extend existing PostgreSQL type

Is it possible to extend an existing datatype in PostgreSQL? Essentially, I want the equivalent of this TypeScript but in SQL: interface Meeting { id: number; start: Date; end: Date; description: string; } interface ServiceHour extends…
Nicholas Chiang
  • 317
  • 2
  • 11
5
votes
1 answer

Php - understanding create_function() - passing simple variable

First time I am trying to use the dynamic create_function, and up to now, not much success :-) My function is this : function o99_brsa_custom_widgets() { global $wp_meta_boxes; global $o99_brsa_options; for($i=0; $i>…
Obmerk Kronen
  • 15,619
  • 16
  • 66
  • 105
4
votes
1 answer

How to read the function body of a Postgres standard-SQL function?

In Postgres 14 a new kind of syntax was added to CREATE FUNCTION where the body of the function can be specified directly in SQL rather than being contained in a string. The string bodies of functions are easily accessible in pg_proc.prosrc, while…
nyctef
  • 474
  • 6
  • 12
4
votes
2 answers

PHP 7.2 error Function create_function() is deprecated

After upgrade my VPS to PHP 7.2, my website have this error: PHP Deprecated: Function create_function() is deprecated in /home/nickname/public_html/framework/web/CHttpRequest.php on line 968 and the code at this file…
user2406612
  • 51
  • 1
  • 5
4
votes
1 answer

Deprecated: Function create_function() is deprecated PHP 7.2

add_filter( 'option_page_capability_' . ot_options_id(), create_function( '$caps', "return '$caps';" ), 999 ); How to write this correctly so that there is no error: Deprecated: Function create_function() is deprecated
4
votes
5 answers

PHP's create_function() versus just using eval()

In PHP you have the create_function() function which creates a unique named lambda function like this: $myFunction = create_function('$foo', 'return $foo;'); $myFunction('bar'); //Returns bar Is this actually any better (apart from being more…
Pim Jager
  • 31,965
  • 17
  • 72
  • 98
4
votes
2 answers

Memory leak?! Is Garbage Collector doing right when using 'create_function' within 'array_map'?

I found following solution here on StackOverflow to get an array of a specific object property from array of objects: PHP - Extracting a property from an array of objects The proposed solution is to use array_map and within create a function with…
algorhythm
  • 8,530
  • 3
  • 35
  • 47
4
votes
4 answers

PostgreSQL: CASE: SELECT FROM two different tables

Is it possible to do something like the following with SQL, not PL/pgSQL (note if it's only possible with PL/pgSQL, then how)? IF password = 'swordfish' THEN SELECT a, b, c FROM users; ELSE SELECT -1; -- unauthorized error code END…
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
1
2 3 4 5 6 7 8