w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
   » Home » Return amp
trying to return the result of sp_executesql and getting "A RETURN statement with a return value cannot be used in this context"
Looks like this isn't going to work as your function returns an inline table-valued function. For this syntax the function definition is followed by AS RETURN ( SELECT ... ) rather than AS BEGIN... RETURN ... END

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++

Ajax through javascript route, controller should return json and return html page
In your routes file, you have to routes matching the same URL : # Library GET /library/:id controllers.UserController.library(id: Long) GET /library/:id controllers.GameController.loadGame(id: Long) When your browser request the /library/123 url, Play will try the routes in the order of declaration and will match the first one, calling the controllers.UserController.library() Action. This is probably why you get a full HMTL page. Try to define a different URL for the second route (the one returning JSON) and Play will be able to match the correct Action. Ex : GET /library/:id controllers.UserController.library(id: Long) GET /gameData/:id controllers.GameController.loadGame(id: Long)

Categories : Javascript

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#

Conditional querying to return timestamp if NOT todays date , else return time
Which database? The dates are always stored with the date portion so this seems like a formatting question. I have a solution below but the actual format may be a little off. The question seemed to be about the logic and you can easily research formatting strings to get what you want. Here is an Oracle solution: (Notice I create an inline view with a UNION from DUAL to simulate your data. Just add your table there.) select dt, when, case when trunc(sysdate) = trunc(dt) then to_char(dt, 'hh24:mi:ss') else to_char(dt, 'yyyy-dd-mm hh24:mi:ss') end yourResult from ( select sysdate dt, 'today' when from dual union select sysdate-1 dt, 'yesterday' when from dual ); Here is a SQL Server solution: (Again, there is an inline view to simulate your data) select dt, whn, case

Categories : SQL

Query to return rows in date range but return only max value of column
Using the row_number() function to rank the rows select product, price, version from ( select *, row_number() over (partition by product order by version desc) rn from yourtable where @dategiven between startdate and enddate ) v where rn = 1

Categories : SQL

Return statement not satisfying generic return type despite the constraint?
Execute is supposed to return a TOutput but instead it's returning a List of TOutputType. A TOutput is constrained to be a List<TOutputType> but a List<TOutputType> isn't constrained to be a TOutput. Try instantiating result as: var result = new TOutput(); and see how that goes.

Categories : C#

JSF-2.2 Faces Flows Return value / cluster / flow return
Not entirely clear on your requirements for (1) but FacesFlow does provide the flowScope with which You can store pretty much anything you want it's contents are available within the scope of the current flow. Take for example, you've navigated from flow A into flow B. You now want to navigate from flow B back into flow A and also pass parameters back into flow A. What you need to do in your flow definition file for flow A (the parameter destination flow), define the parameter you want to pass as inbound: <inbound-parameter> <name>returnParameterFromB</name> <value>#{flowScope.returnParameter}</value> </inbound-parameter> Define the desired parameter as outbound in the flow config file of the parameter source flow (flow B) <outbound-p

Categories : JSF

TSQL Error: A RETURN statement with a return value cannot be used in this context
You need to describe the returned table, populate it, then RETURN: CREATE FUNCTION [dbo].[Sample] (@SampleValue int) RETURNS @RESULTS TABLE ( ID int, <other fields> ) AS BEGIN INSERT @T <select ...> RETURN END

Categories : SQL

Fluent interface - return most specific return type
As @chrylis noted in the comments, you can genericize BaseClass: public abstract class BaseClass<T extends BaseClass> { private Alpha a; private Beta b; public Alpha getAlpha() { return a; } public Beta getBeta() { return b; } @SuppressWarnings("unchecked") public T setAlpha(Alpha a) { this.a = a; return (T) this; } @SuppressWarnings("unchecked") public T setBeta(Beta b) { this.b = b; return (T) this; } } and extend as follows: Foo: public class Foo extends BaseClass<Foo> { private Gamma g; @Override public Foo setBeta(Beta b) { super.setBeta(b); doSomethingElse(); return this; } private void doSomethingElse() { } public Gam

Categories : Java

Getting json return type and html return in the same action
I'll straight away consider to write a sample : <action name="xclient" class="myCompany.ClientAction" method="jsonMethod"> <result type="json"></result> </action> <action name="yclient" class="myCompany.ClientAction" method="htmlMethod"> <result type="dispatcher">/pages/y.jsp</result> </action> now simply create both methods jsonMethod() & htmlMethod() in your ClientAction, one handling json and another html response. [EDIT] I read it again and seems like you require only one-action, well then simply consider using a field (request parameter) to decide the return type. public String execute(){ //..Other code if(returntype.equals("json")){ return "jsonresult"; } else{ return "htmlresult";

Categories : Json

Java Idiom or Library for Return Value and Return Value Validity?
As I see it, you have two options: The easiest is just to throw an exception for the exceptional case. I would imagine the case where the value isn't present would suit? Create a new generic class that you return from each method. It can have an isInvalid() method, which indicates whether the value was marked as "INVALID". If the user still calls getValue() despite being told it was invalid, throw an exception.

Categories : Java

Return a reference by a class function and return a whole object in c++?
First, the usual convention in C++ is to pass class type arguments as references to const. There are clearly exceptions (predicate objects or iterators in the standard library), but in application level code, passing a class type by reference to const is ubiquitous enough to justify a comment: Vector Vector::operator+( Vector const& rhs ) const { // ... } Or more likely: Vector operator+( Vector const& lhs, Vector const& rhs ) { Vector results( lhs ); results += rhs; return results; } Another widespread convention is to make such binary operators free functions, so that both the left and right arguments ar treated in the same fashion. And to implement them in terms of =, so as to ensure that = and have the desired relation. For operators which modify

Categories : C++

return statement doesnt return anything in python recursion
Here: find_and_remove_functions( string[ function_end + 1: ], found_functions ) should be return find_and_remove_functions( string[ function_end + 1: ], found_functions )

Categories : Python

"Method must have a return type" and "return must not be followed by an object expression"
You would need to change the declaration to return an Exception: public static Exception LogMessage(Exception ex) { Trace.WriteLine(ex.ToString()); return ex; } Note that, depending on usage, it might make sense to allow this to be a generic method: public static T LogMessage<T>(T ex) where T : Exception { Trace.WriteLine(ex.ToString()); return ex; } This would allow you to use the resulting exception in a strongly typed manner. Alternatively, you could just not return the exception, since Logging shouldn't need to return an exception in any case: public static void LogMessage(Exception ex) { Trace.WriteLine(ex.ToString()); }

Categories : C#

When does Facebook return JSON and when does it return plain text
I don't think there's any general logic behind this. Something that can help you tough is the Content-Type from the header in the response. Example: ... Access-Control-Allow-Origin: * Cache-Control: no-store Content-Length: 154 Content-Type: application/json; charset=UTF-8 ... This way you can tell your software how to react for each Content-Type. Either it's text/plain or application/json. Hope it helps -Laurent

Categories : Facebook

Return multiple results from class with return instead echo?
Just load everything into an array and return the array. Keep the output formatting out of this class and leave that up to the whatever is calling this class. $return_array = array(); while ($row = $r->fetch_assoc()) { $return_array[]['title'] = $row['title']; } return $return_array;

Categories : PHP

Methods that return meaningful return values
You could create and return an enum with expected LoginResults. public enum LoginResult { Success, AccountSuspended, WrongUsername, WrongPassword, } Then return using the enum type in your method: public LoginResult LoginToTwitter(String username, String password) { // Some code to log the user in }

Categories : C#

Return results from a call to Yield Return
A function that returns an IEnumberable<T> is indeed returning an object, which is not the full list but knows how to iterate it when its Enumerator's MoveNext method is called. The same is true for your GetNumbersWrapped method above. It doesn't wait for the full collection. It returns an object which has an Enumerator inside. Whenever the foreach loop (or other loop operations) call this enumerator's MoveNext method it starts reading the values. So GetNumbersWrapped and GetNumbersWrappedYield are the same, except that GetNumbersWrappedYield has one redundant looping layer.

Categories : C#

What's difference between pthread_mutex_trylock's return and pthread_mutex_lock's return
In this context mutex is acquired means that there was no thread holding the lock at the time. If the mutex is recursive, the call to pthread_mutex_trylock() will succeed unless it has been recursively locked too many times. You can think of pthread_mutex_trylock() as a non-blocking call, where if it would have blocked, it returns with an error instead. If it returns success, it means you have the lock as if pthred_mutex_lock() returned successfully. If it fails with EBUSY it means some other is holding the lock. If it fails with EOWNERDEAD, the lock was held by another thread, but that thread had died (getting the lock actually succeeded, but the current data state may not be consistent). If it fails with EAGAIN it was locked recursively too many times. There are other failure reasons, b

Categories : C

How to let the return Json(datetime) return millisecondes according to the UTC?
Json formate is created based on UTC datetime. After getting the datetime from ajax call, you have to convert this UTC datetime in to local datetime zone. Ex: var date = new Date('6/29/2011 4:52:48 PM UTC'); date.toString() // "Wed Jun 29 2011 09:52:48 GMT-0700 (PDT)"

Categories : Javascript

Can you return a string from a while loop without using the return command?
The return statement returns a value from the entire method you're in. But you're in main, which can't return a value (it's void). If you want to end the while loop when you have a good value, then use the break statement to break out of the while loop. Control then passes to the next statement following the end of the loop.

Categories : Java

Is 'yield return' slower than "old school" return?
For one, it's a convenience feature. Two, it lets you do lazy return, which means that it's only evaluated when the value's fetched. That can be invaluable in stuff like a DB query, or just a collection you don't want to completely iterate over. Three, it can be faster in some scenarios. Four, what was the difference? Probably tiny, so micro optimization.

Categories : C#

Matlab function switching return/no return
One common trick in matlab is to use the empty matrix [] to indicate nothing. You could write your function something like (untested code): function result = analyze(image, special_point) % your code here if pixels_are_ok result.a = 1; result.b = 2; else result = []; end If you call this function from your other code, you can use isempty to see if you got a result or not: result = analyze(image, special_point) if isempty(result) display('did not find anything') else display('found some interesting results') display(result) end

Categories : Matlab

How to enable carriage return with shift+return only
I would suggest writing a custom directive for this. Then you could reuse it for any elements you'd like. Here is an example of using it to move to the next input element. Just put enter-next in whatever element you want to have this ability. .directive('enterNext', function() { return { restrict: 'A', link: function($scope,elem,attrs) { elem.bind('keydown', function(e) { var code = e.keyCode || e.which; if ((code === 13) && (e.shiftKey)) { e.preventDefault(); elem.nextAll('input').first().focus(); } }); } } });

Categories : Angularjs

Return the last non-zero return code in a shell script
Maybe this is what you are looking for: If you don't want to soldier on after the first command failed, you can set -e at the top of the script to make it exit as soon as the first command (not part of a control structure like if cmd) exits nonzero. Your shell manual has all the details. My Bourne Shell says: -e errexit Exit immediately if any untested command fails in non-interactive mode. The exit status of a command is considered to be explic- itly tested if the command is part of the list used to control an if, elif, while, or until; if the command is the left hand oper- and of an ``&&'' or ``||'' operator; or if the command is a pipe- line preceded by the ! operator. If a shell function is executed and its ex

Categories : Shell

Return statement error, return null instead
Just do a return statement of return -1 right after the do while. You will not ever reach that code, but it will make the compiler happy who is not able to understand the logic of your code and just sees that there are possible execution paths that don't return anything. public int CheckAnswers () { boolean incorrectAnswer = true; do { playerAnswer = CheckAnswers(); if (playerAnswer < 1 || playerAnswer > 4) { System.out.println("You have entered an incorrect number."); System.out.println("Please enter a number between 1 and 4"); } else { return (playerAnswer); } } while (incorrectAnswer); return -1; //unreachable statement }

Categories : Java

In emacs23 how to bound C- to C- instead of C-J
That's not a valid sequence for most terminals, I'm afraid, so they simply can't send it to Emacs. If you run GUI Emacs instead, the key bindings will work. Thomas Dickey's xterm is the only terminal software I know of which can (I think) support all the normal Emacs bindings. If you're okay with compiling that, then you could try it with the following .Xdefaults-(hostname) (or .Xresources if you re-merge after editing) to get basic support working: XTerm*metaSendsEscape: true XTerm*modifier: meta XTerm*modifyOtherKeys: 1 You actually need XTerm*modifyOtherKeys: 2 to fully extend the sequences (otherwise you still can't type the likes of C-M-%), but by default that setting will break most key sequences, and right now I couldn't tell you how to configure things correctly for that setti

Categories : Emacs

Ajax return value with return not work
Use dataType option in $.ajax() dataType: "json" In post.php try this, <?php $name = $_POST['name']; echo json_encode(array('name'=>$name));// echo your json return;// then return ?>

Categories : PHP

set return URL to return to app when transaction is done with paypal
Be careful, the App Store Review Guidelines mentions that : 11.13 Apps that link to external mechanisms for purchases or subscriptions to be used in the App, such as a "buy" button that goes to a web site to purchase a digital book, will be rejected

Categories : IOS

how *return implicitly return a reference
Add member doesnt have Sub function. Compiler give an error. But, if you return *this, you are returning your own object (not reference). Now you have one cCalc object that can use Sub(3). Sub(3) return your object and can use Mult(4).

Categories : C++

What should the return type be when the function might not have a value to return?
What would be the most elegant modern C++ way? There's, as always, not just one solution to this problem. If you decide to go for any solution that references the original resonse instance, you're on a slippery road when it comes to aliasing and memory management, especially in a multi threaded environment. By copying the response to the caller, no such issues arises. Today, I would do this: std::unique_ptr<std::string> find_response(const std::string& id) const; That way, you can check for nullptr as "in the olden days" and it's 100% clear who's responsibility it is to clear up the returned instance: the caller. The only downside I see of this, is the additional copy of the response string, but don't dismiss that as a downside until measured and proven so. Another wa

Categories : C++

GetEnumerator: return or yield return
The reason that compiles is because you are being unclear what the enumerable is. If you make it generic it becomes more obvious: public IEnumerator<Foo> GetEnumerator() { return Database[id].GetEnumerator(); } vs public IEnumerator<IEnumerator<Foo>> GetEnumerator() { yield return Database[id].GetEnumerator(); } Your yield return version is not yielding the result: it is yielding the iterator - it is an iterator-of-iterators, an enumerator-of-enumerators. And not in a good way. Basically, "don't do that".

Categories : C#

Not all code paths return a value while I return something
In the exception handling bit, nothing's returned. Here's a fix. public string GetEigenaarBlog(int gebruikerid) { try { connection.Open(); string sql = "SELECT NICKNAME FROM GEBRUIKER WHERE GEBRUIKERID = :GEBRUIKERID"; command = new OracleCommand(sql, connection); command.Parameters.Add(new OracleParameter(":GEBRUIKERID", gebruikerid)); string nickname = Convert.ToString(command.ExecuteReader()); return nickname; } catch (Exception ex) { MessageBox.Show(ex.Message); return null; //if you want to let the code know too put "throw;" here instead. } finally { connection.Close(); } }

Categories : C#

Return from "for" in Scala is not the same as return from "for" in Java
It in fact will stop myMethod execution because behind the scenes it actually throws a (no-stack-trace) exception which is caught by myMethod before actually returning. So you just def myMethod(str1: String) { for (item <- items) { if (/*some cond*/) { if (/*other cond*/) { return item.myMethod123 } } } super.myMethod(str1) } "just like" in Java. The code works fine; it just doesn't work as fast since there is an exception involved. (Stack traces are what take most of the time, so you're probably okay here unless it's a heavily-used loop.) Alternatively, you can val target = items.find{ item => if (/* some cond */) { /*other cond*/ } else false } target.map(_.myMethod123()).getOrElse(super.myMethod(str1)) which will first pick o

Categories : Java

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

PHP objects inside arrays (HOW TO: If array key is 0, return 0. Else if array key is 2, return 2. BASIC LOGIC)
I think the problem is here: foreach($array as $single) { $array = $single->name . ','; } $array is only an array the first time the loop is executed as inside the loop your assigning it a new value. Try this instead: $names = array(); foreach ($array as $single) { $names[] = $single->name; } echo implode(', ', $names);

Categories : PHP

Sql IF exists, Update & return new column as true, Else return column as false
try begin and end like this: IF EXISTS(SELECT * FROM [User].Data WHERE username = @username AND password = @password) BEGIN --BEGIN IF BLOCK UPDATE [User].Data SET lastLogin = GETDATE() WHERE username = @username SELECT 'true' AS userValid END --END IF BLOCK ELSE SELECT 'false' AS userValid END As there are no braces or indentations in SQL, you have to demarcate blocks of IF with multiple statements using BEGIN and END.

Categories : SQL

return url post to PayPal will override the return url that has already set in the paypal merchant account
You should be able to get there in the Sandbox. The section may be called "Website payments preferences" and be found under the "Hosted payment settings" category. Here is a direct URL to the page, make sure you're signed into your Sandbox Seller account before you open this: https://www.sandbox.paypal.com/us/cgi-bin/webscr?cmd=_profile-website-payments

Categories : PHP

getFragmentByTag() return Fragment, but getFragmentByTag().getView() return null
I could not figure out why? onCreateView() has not been called on the fragment yet. IMHO, an activity should not be trying to mess with the widgets of its fragments. Delegate that work to the fragment, which can do that work at an appropriate time, when the widgets are ready.

Categories : Android



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