w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
function/procedure to update (ALTER) another function/procedure
While you can retrieve function source from pg_proc, trying to retrieve it, edit it and update the function is a recipe for pain and suffering. Instead, write a PL/PgSQL procedure that generates the function text in its entirety. Use a query against the information_schema or pg_catalog.pg_class to get the required table list, constraints, inheritance, etc. Loop over the query results, generating the body of the function, then join it all into a single block of text and pass it to EXECUTE. Here's a toy example of one function generating another: CREATE OR REPLACE FUNCTION very_meta(func_name text, message text) RETURNS void AS $$ DECLARE func_lines text; BEGIN -- In reality you'd build this iteratively, or preferably use `string_agg` over -- a query, but I'm just going to su

Categories : Function

LINQ FUNCTION TO RETURN LIST BUT COMPILER SAYS function doesn't return a value on all code path
All code paths don't return a value. If searchtype = "withdatetime" Then Dim locs As New crimemsapslocationDataContext Dim giveloc = From locations In locs.crimelocations _ Where locations.INCIDENTTYPE = crime And (locations.DATE_COMTD >= Convert.ToDateTime(startdate) And locations.DATE_COMTD <= Convert.ToDateTime(enddate)) _ And (locations.gettimecom >= starttime And locations.gettimecom <= endtime) _ Select locations Return giveloc.ToList ElseIf searchtype = "withdate" Then Dim locs As New crimemsapslocationDataContext Dim giveloc = From locations In locs.crimelocations _ Where locations.INCIDENTTYPE = crime And (locations.DATE_COMTD >= Conv

Categories : Asp Net

Replace function set as Store Procedure or Function in MySQL?
You just have to make a little change, you have to add the percent sign in the like expression DELIMITER // CREATE PROCEDURE updateURL(OUT url1, OUT url2) BEGIN UPDATE content SET url = REPLACE (url, url1, url2) WHERE URL LIKE CONCAT('%', url1, '%'); END // DELIMITER ;

Categories : Mysql

In what Javascript engines does Function.prototype.toString not return the source code of that function?
What current Javascript engines don't behave this way? Your question isn't really well-defined, given that you haven't defined "popular". Is IE6 popular? IE5? IE4? Netscape Navigator? Lynx? The only way to properly answer your question is to enumerate which browsers you wish to support and check them. Unfortunately kangax's table http://kangax.github.io/es5-compat-table/# doesn't test Function.prototype.toString Chrome's console will even tell you (when you pass anything other than a function o Function.toString.call), that Function.prototype.toString is not generic mandated in the spec the spec refrains from making any commitment as to what the behaviour should be when applied to functions The required behavior is specified in ECMA-262 version 1 (from 1997, http://

Categories : Javascript

how can find return variable value outside anonymous function in node js mysql query function
Try this and define the scope of variable as global     DBDATA=""; var alldata = function(){ var http = require('http'), mysql = require('mysql'); var client = mysql.createConnection({ host: '127.0.0.1', user: 'root', password: '' }); client.connect(); client.query("use cakephp2"); client.query("SELECT id, title,body,created from posts", function(err, results, fields) { if (err) throw err; var output = '<h1>Latest Posts</h1><ul><table border=1><tr>'; for (var index in fields) { output += '<td>' + fields[index].name + '</td>'; } output += '</tr>'; for (var index in results) { output += '<tr><td>' +

Categories : Javascript

how to return a value from inner function that have a phonegap database SQLite query to the outer function
The problem is very clear, as you are using heavy process(i.e. database) inside a function so jquery runs this function in seperate thread parallel to your main thread now in this condition your value will always get undefined. you can make a global variable var hasSubAcc=-1; now after checking condition if(rs.rows.length == 0) { hasSubAcc=0; } else { hasSubAcc=1; } now give a small delay using setTimeout(function(){ alert(hasSubAcc); },500); or while(hasSubAcc==-1){ //do nothing } alert(hasSubAcc);

Categories : Javascript

calling function should return default value, if object (or any function result) is null
Not really, any code you would write this way would look horrible and/or use very slow reflection. Unless you use an actual Java preprocessor that can understand and change the code you've written. A better (but associated with quite a bit of refactoring) approach would be to make sure that the values in question cannot possibly be null. For example, you could modify the individual accessors (getSubObject(), getDesiredValue()) to never return null in the first place: make them return default values. The accessors on the default values return default values in turn.

Categories : Java

JavaScript - override a function with a function that contains async callbacks and still return original value
callNextMiddleware should return its recursive call's return value, not middlewareFunc's. if (middlewareFunc) { var result; middlewareFunc.call(this, function() { result = callNextMiddleware(middlewares, callback); }); return result; } Fiddle: http://jsfiddle.net/mWGXs

Categories : Javascript

Rspec to mock my call to external api from my function and return custom response back to the function
Checkout https://github.com/bblimke/webmock or http://fakeweb.rubyforge.org/ Then you do something like: stub_request( :post, "#{GITHUB_URL}1.json" ).to_return( body: { actor_attributes: {name: "Bill"} }.to_json ) I'm a bigger fan of Webmock than Fakeweb (it's got a few more features), but they'll both do for you, and it's pretty easy to switch between them.

Categories : Ruby On Rails

PHP Eval Math Function for Bot
As I stated in the comment there is no ** operator in php, the pow function should be used instead ... what you can do to emulate it though is to throw another preg_replace at the input. $input = rtrim($this->get_message()); // grabbing the user input $input = preg_replace('/([0-9.]+)**([0-9.]+)/', 'pow($1, $2)', $input); $sum = $this->do_math($input);

Categories : PHP

Does ember.js function.property() always succeed a function with a return statement?
You need to see a property as a attribute. Ember doesn't make a distinction between functions and attributes. If you have a property it must return a value, since it acts like an attribute. If you're looking not to return a value, but you want something to change based on another property, you'd use the observable pattern. Have a look in the guide for more information.

Categories : Ember Js

return variable name from outside of function, as string inside python function
You cannot pass a variable as a string*, and you should not do so. If you want to pass a value between functions, the normal way is to pass it in as a parameter, and out as a return value. If that is inconvenient, the usual solution is an object: define a class which carries both the shared variable, and methods which act on the variable. If you need to create command objects, it is much better to do so in a structured way. For example, if you want to pass a function, and parameters, you can literally just pass the function object and the parameters in a tuple: def foo(): return (functionONE,somearray,1,3) command = foo() command[0](*command[1:]) If you want to embed such commands within commands, you'll likely want to wrap that up with a class, so you can recursively evaluate

Categories : Python

How to execute the function return the value to called function across node js files
Unable to send the variable resourceIdentifiers from subscriptionRestService to mysqlRestService.js Well, you didn't send it. It currently is a parameter of your callback function in the invocation, not an argument for the parameter of getPricingDetails. Use mysql.getPricingDetail(resourceIdentifiers, function callback(result){ // use result here }); Unable to return the pricingdetail from mysqlRestService.js to calling function in subscriptionRestService. I've got no idea what pricingDetail = pricingDetail; was supposed to do. You have to call (invoke) back the callback here! Use callback(pricingDetail);

Categories : Javascript

math function as binary operations
You can "pay" with memory for CPU cycles. If you have 256 bytes of ROM available to you, the cheapest way of computing such function would be building a lookup table. Make a program that prints a list of 256 8-bit numbers with the values of your non-linear function. It does not matter how fast the program is, because you are going to run it only once. Copy the numbers the program prints into your C program as an array initializer, and perform the lookup instead of calculating the function.

Categories : C

how do i exit a function which causes segfault and return to calling function
Here's a similar question with an answer (albeit the wrong language, C++): Catch Segfault or any other errors/exceptions/signals in C++ like catching exceptions in Java I believe that what you're looking for is an exception in place of your exit(0) statement, but a Segmentation Fault is not an exception, therefore making it difficult to deal with. This being said, it appears that C does not have built in exception handling. Regardless, here's a reference about receptions in c++: http://www.cplusplus.com/doc/tutorial/exceptions/ I don't know exactly how you're using the function you have here, but perhaps you can return a boolean instead of void, and return from the calling function if the boolean is true?

Categories : C

How to prevent default in a function if a function already return somethiing
You could add return false;: for(var i=0; i < 2; i++){ someNode.onclick = function(num){ return function(){ alert(num); return false; } }(i); } Or you could use e.preventDefault either: for(var i=0; i < 2; i++){ someNode.onclick = function(num){ return function(e){ e.preventDefault(); alert(num); } }(i); }

Categories : Javascript

In golang, how to return a slice of type int from a function to another function?
Change your chan make to this: make(chan []int) Or select an index of your []int to send on your chan int. Either way int and []int are distinct types, as chan int and chan []int are.

Categories : Go

How to return a cursor from database function to another function in activity
we should open and close database before and after use of database public void insert() { db.open(); Cursor cr = db.Settings();//db is object of database if (cr == null) otd.insert_setting(value + "", save_path, option); else { otd.delete_setting(); otd.insert_setting(value + "", save_path, option); } db.close }

Categories : Android

Have function return request data + a function to execute
How about Edit xmlhttp.onreadystatechange = (function(xmlhttp, url, somevar1, somevar2){ return function() { cfunc.call(this, xmlhttp, url, somevar1, somevar2); } })(xmlhttp, url, somevar1, somevar2);

Categories : Javascript

Hibernate @SqlInsert w/ PostgreSQL function -- What does my function need to return?
Assuming you have following entity class: @Entity public class MyString { private long id; private String name; // getters & setters.. } You can use Hibernate native SQL query: Session session = // obtain hibernate session somehow.. String sql = // sql to call your db function.. List<MyString> mystrings = session.createSQLquery(sql).addEntity(MyString.class).list(); Hibernate will map java properties based on the result set column name. you can use as keyword or decorate the java field with @Column annotation

Categories : Hibernate

C pass address of a function return value as function parameter
No you can't do that in C. Also note C doesn't have something called as reference as in C++. For that C has pointers to achieve the same behaviour.. To achieve the same goal in C use temporary variable like, int val; val = b(); a( &val ); // & is called as "address of" operator in C To answer why there is no reference in C, from my understanding pointer and reference are meant to achieve the same goal - minimizing or avoiding data copy. For this C's pointer is good enough, though technically both have some difference in C++ (taken for reference)

Categories : C

Why does ngRepeat use a compile function, when all it does is return a linking function?
Thats the way the Directive Definition Object is defined: You could also do: compile: function compile(tElement, tAttrs, transclude) { return { pre: function preLink(scope, iElement, iAttrs, controller) { ... }, post: function postLink(scope, iElement, iAttrs, controller) { ... } } Check Directives documentation at http://docs.angularjs.org/guide/directive A compile function can have a return value which can be either a function or an object. returning a (post-link) function - is equivalent to registering the linking function via the link property of the config object when the compile function is empty. returning an object with function(s) registered via pre and post properties - allows you to control when a linking function should be called during the li

Categories : Angularjs

What is the shorthand in d3 for the identity function ("function(d) { return d; }")?
I used to see Mike do .data(Object) which seems to work http://tributary.io/inlet/5842519 but I'm not sure why I don't see it around anymore var svg = d3.select("svg") var data = [[10,20],[30,40]]; svg.selectAll("g") .data(data) .enter() .append("g") .attr("transform", function(d,i) { return "translate(" + [i * 100, 0] + ")"}) .selectAll("circle") //.data(function(d) { console.log(d); return d }) .data(Object) .enter() .append("circle") .attr({ cx: function(d,i) { return 100 + i * 40 }, cy: 100, r: function(d,i) { return d } })

Categories : Javascript

access to function return value within another function python
Please read the Python tutorial in particular, the section about classes. You will find tons of great OO Python tutorials online, like here or here. Getting the return value of a function return_value = my_function(my_argument) For example, using the interpreter by running python on the command line: ➤ python Python 2.7.2+ (default, Jul 20 2012, 22:15:08) [GCC 4.6.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> def square(x): ... return x*x ... >>> four_squared = square(4) >>> four_squared 16 Cleaning up the code: Your code doesn't make sense. What is nmaidcount().finallist? Where do you define finallist in your program? Why do you have if True? This will always be the case! This is what I think you me

Categories : Python

jQuery: Math.floor function on hash load
I solved this problem by firing the math.Floor function on window load like so: $(window).load(function(){ var $this = $('.grid-break'); $this.css('height','auto'); var newHeight = $this.height(); newHeight = (Math.floor((newHeight+10)/230)+1)*230-10; $this.css('height',newHeight); });

Categories : Jquery

My function doesn't calculate a simple math operation
The problem is, you are casting the value of 5 / 9 to an int, which will give you 0 as a value. Just remove the cast, and it will be fine. And also you need to add parenthesis around the subtraction. Change your print statement to: print((int(Fvalue) - 32) * 5/9)

Categories : Python

How to handle "Error in function boost::math::cyl_bessel_k(d,d): numeric overflow"
Well the obvious answer seems to be to not pass 0, but if that is not feasible, and you are ok with the function failing, you can catch the exception and handle it in a way that seems right. The program wont crash then. This tutorial might help explain deeper what you should do.

Categories : C++

What function does Math.sqrt(n) serve in relation to Eratosthenes algorithm for finding N primes?
The square root of a number is the largest possible member of a pair of its prime factors. Any prime factor larger than the square root will need to be multiplied by a prime factor smaller than the square root to get the number.

Categories : Javascript

Return parent::function in a function
This will call the function changeVarA in the parent class. When a class extends another class, and both have the same function name, the parent:: call forces the parent version of the function to be called and used. The return part of it will simply return whatever the parent function returns after it completes: <?php class A { function example() { echo "Hello Again! "; } } class B extends A { function example() { echo "Hello World "; parent::example(); } } $b = new B; // This will call B::example(), which will in turn call A::example(). $b->example(); ?> output: Hello World Hello Again! The example is taken from the PHP documentation which you really should take a look at.

Categories : PHP

return a value from a function without exiting the function in C
There are many forms of Inter Process Communication (IPC) strategies in UNIX. One of my favorite is to spawn a child process and receive a notification upon its demise. A primer on IPC can be found here and an example of asynchronously waiting on a child processes death can be found here. If you don't want to spawn a separate process you can used named pipes to have information flow back and forth between the two processes.

Categories : C

Procedure or function !!! has too many arguments specified
You invoke the function with 2 parameters (@GenId and @Description): EXEC etl.etl_M_Update_Promo @GenID, @Description However you have declared the function to take 1 argument: ALTER PROCEDURE [etl].[etl_M_Update_Promo] @GenId bigint = 0 SQL Server is telling you that [etl_M_Update_Promo] only takes 1 parameter (@GenId) You can alter the procedure to take two parameters by specifying @Description. ALTER PROCEDURE [etl].[etl_M_Update_Promo] @GenId bigint = 0, @Description NVARCHAR(50) AS .... Rest of your code.

Categories : SQL

How to use function in store procedure
when calling functions in SQL Server they must be done as a SELECT SELECT [ColumnNameToSelectFromFunction] FROM [Function](Parameters for function all seperated by a ,)

Categories : Sql Server

Can changing a function which used to return a const ref to an std::string to return by value break calling code?
One way this could go wrong is if the calling code does something like: const char* s = ConvertToString(first).c_str(); And then stores s somewhere and accesses it later, thinking that the std::string object referenced by the return value of ConvertToString will never be destroyed. Of course, that calling code sucks anyway, in that case.

Categories : C++

How to handle "not all code paths return a value" when the logic of the function does ensure a return
C# code flow analysis is limited and as your sample points out there are cases where all paths do return but the compiler can't detect it. Throwing an exception is an acceptable remedy in those circumstances. I would not use a return of a default value to fix this error. You're operating under the assumption that the line is never hit against the advice of the compiler. Consider for a second that your analysis is wrong and execution can proceed to the end of the method. If you return a default value then you will have no indication of the problem. The method will just be returning bad data. Throwing an exception will make it very obvious that there is a problem. However in those cases my preference is to simply rewrite the code such that the compiler can see that all paths ter

Categories : C#

stored procedure and split function.....how to
You can split multiple values like this, #Table stores values which you required CREATE TABLE #Table (Value VARCHAR(MAX)) DECLARE @Values VARCHAR(MAX) = (select StringStoredValue from TableName) SET @Values = 'INSERT INTO #Table SELECT ' + REPLACE(@Values, ',',' UNION SELECT ') EXEC(@Values) --Here you can do join with #Table and find those values which required SELECT * FROM #Table DROP TABLE #Table

Categories : Sql Server

how to set a parameter error in procedure or function in asp.net
The error message is telling you that you are missing a parameter for the stored procedure, to be specific@CreatedDate You need to add: cmd.Parameters.Add(new SqlParameter("CreatedDate", DateTime.Now)); Note: You will have to supply all of the other parameters that you are missing or you will encounter the same error.

Categories : C#

Procedure or function deleteprofile has too many arguments specified
instead of giving set firstname = @pfirstname, lastname=@plastname,adress = @padress, email = @pemail,telephone = @ptelephone,birthday = @pbirthday where id = @pid u have given set firstname = @pfirstname, @plastname = lastname,@padress = adress, @pemail = email, @ptelephone = telephone,birthday = @pbirthday where id = @pid

Categories : Vb.Net

Procedure or function has too many arguments specified C# DotNetNuke
If your Module is a compiled module, just making changes to the .CS file won't help, you will also need to recompile the module. How do you tell if it is compiled? Check out the website's BIN folder, see if there is a DLL in there that matches the name of the module.

Categories : C#

how to use SUBSTRING_INDEX function in mysql procedure
Your immediate problem is not with SUBSTRING_INDEX but rather with missing SET Change d = SUBSTRING_INDEX(b, ',', c); to SET d = SUBSTRING_INDEX(b, ',', c); ^^^ Now that will solve syntax error but you need to make quite a few changes to your code to make it work. To get n-th element from a list you need to apply SUBSTRING_INDEX() twice SUBSTRING_INDEX(SUBSTRING_INDEX(list, ',', n), ',', -1) That being said your SP might look like DELIMITER $$ CREATE PROCEDURE my_sp() BEGIN DECLARE done INT DEFAULT FALSE; DECLARE a, b, d VARCHAR(12); DECLARE c, m INT DEFAULT 0; DECLARE cur1 CURSOR FOR SELECT id, school_id FROM my_list; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; OPEN cur1; read_loop: LOOP FETCH cur1 INTO a, b; IF done THEN LEAVE read_loop

Categories : Mysql

Generic function to clear all handlers of a procedure?
Try something like this: For Each b As Button in MySub.Controls.OfType(Of Button) 'This should remove all the handlers for each button PSLib.cEventHelper.RemoveAllEventHandlers(b) 'Or like this to just remove just the Click handler for each button PSLib.cEventHelper.RemoveEventHandler(b, "Click") Next A suggestion use the original first. Get your front interfacing with it properly. Then do the translation. This way you have a base line and know how it's supposed to work. UPDATE: I think part of the confusion is in the misuse of terminology. In your update MyMethod is a handler, it doesn't contain handlers, but it can handle more than one event. Button1.Click is an event. Button1 is a Button. So, using the proper terminology, it appears you want to remove all

Categories : Dotnet



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.