EzDevInfo.com

Result

Swift type modelling the success/failure of arbitrary operations.

Boost::Spirit result of phrase_parse

Hello everybody I am new to boost and boost::spirit, so I am sorry for noob question.

When I use qi::phrase_parsefunction, the function returns only bool variable which indicates whether parsing has been successful or not, but I don't know where I can find the result of parsing ...some sort of syntax tree etc.

If I use macro #define BOOST_SPIRIT_DEBUG XML representation of tree is printed on standard output, but these nodes has to be stored somewhere. Can you help me please?


Source: (StackOverflow)

Java: Getting an array of every string that matches a Regular expression

How would I parse a file like this:

Item costs $15 and is made up of --Metal--
Item costs $64 and is made up of --Plastic--

I can do

Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(input);
String result = m.group();

But how would I get EVERY result?


Source: (StackOverflow)

Advertisements

check if two "select"s are equivalent

Is there a way to check if two (non-trivial) select are equivalent?

-- edit --

Initially I was hoping for a formally equivalence between two selects, but the answers in proving-sql-query-equivalency stop me.

For my actual need I can just check if the (actual) results of two selects are the same.


Source: (StackOverflow)

Joining 2 SQL SELECT result sets into one

I've got 2 select statements, returning data like this:

Select 1 col_a col_b

Select 2 col_a col_c

If I do union, I get something like col_a col_b

And rows joined. What i need is getting it like this: col_a col_b col_c

Joined on data in col_a.


Source: (StackOverflow)

Can I pass the result of an assignment to a function in c++?

My question is: "Can I pass the result of an assignment to a function in c++?"

The reason I want to do this is that a variable has a specific type, e.g. "int" so I assign the value to the variable and pass the whole thing to the overloaded function that takes "int" as an argument.

The main reason for doing this is to make the code a bit smaller and easier to read, so instead of:

val = 2
function(val);

I get:

function(val = 2);

Is that ok? If so, is there a convention that says this is poor coding practice for some reason?

Thanks, fodder


Source: (StackOverflow)

Will RESULT_CACHE keyword return updated data from function in Oracle?

I am calling function inside select query of view. View is reading records from table which contains around 1 million records. When I am writing RESULT_CACHE key word in function, I am getting output in fraction of seconds. I have doubt that when value of any column is changed which is used inside view, will function consider that new value?


Source: (StackOverflow)

Check If Activity Has Been Called for Result

I would like to know if its possible to know if some activity has been called for result or only started using "startActivity".

I need to control this, if its called for result the behaviour will be different.

Thanks in advance!


Source: (StackOverflow)

Asp.Net Mvc: ContentResult vs. string

I recently was asked why to use ContentResult instead of returning string. Unfortunatly I could not give a better answer than: "It is best practice."

Does anyone have a better answer?


Update: To better understand the question. What's the difference?

public ActionResult Foo(){
    return Content("Some string");
}

public string Bar(){
    return "Some string";
}

Source: (StackOverflow)

Get other columns that correspond with MAX value of one column?

Ok, this is my query:

$sql="SELECT video_category, video_url, video_date, video_title, short_description, MAX(video_id) FROM videos GROUP BY video_category";

When it pulls the data, I get the correct row for the video_id, but it pulls the first row for each category for the others. So when I get the max result for the video_id of category 1, I get the max ID, but the first row in the table for the url, date, title, and description.

How can I have it pull the other columns that correspond with the max ID result?

Edit: Fixed.

$sql="SELECT * FROM videos WHERE video_id IN (SELECT DISTINCT MAX(video_id) FROM videos GROUP BY video_category) ORDER BY video_category ASC";

Source: (StackOverflow)

How to get SQL result saved into a C# variable?

I have troubles finding out how to save a SQL result into a String or whatever type the result returns.

my SQL query is

SELECT SUM(Length) FROM tbl_test WHERE TITLE LIKE 't%'

here I need a function that sums up the length of all datarows where title beginns with the letter "T", when executing the query in MS-SQL it returns "188.99" (the sql type is decimal)

my question is, how do I get to save that value into a C# variable? the query always returns ONE row with the particular value, which I want to save into a variable. I have a C# function to execute the query, I just need the value from that row, 188.99, to be saved into a variable. any suggestions are cool,no matter if I the result is saved into a decimal variable or string.


Source: (StackOverflow)

Android onActivityResult is always 0

This has been killing me for two days now. I have a main Activity A which calls a second Activity B. Activity B simply presents the user with a listview. When I press an item on the list view I want a couple of strings to be passed back to the main Activity A and Activiy B will finish.

The problem is I always get a resultcode of 0 and the data bundle is null. I really don't understand why this is happening.

Here is my code.

Start Activity B for result;

Test.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(recipeActivity.this, BrowseLoadRecipes.class);
            startActivityForResult(i, RECIPE_CHOOSER);
    }  
    });

This starts the second Activity fine. Activity B populates a listview and when I click an item I'm trying to send some data back to the calling Activity A.

Any text at the moment, so I used the following in Activity B;

     lv.setOnItemClickListener(new OnItemClickListener() {
     @Override
     public void onItemClick(AdapterView<?> a, View v, int position, long id) {
        Bundle bundle = new Bundle();
        bundle.putString("TEXT", "Please work... pleeeeaasee");
        Intent mIntent = new Intent();
        mIntent.putExtras(bundle);
        setResult(RESULT_OK, mIntent);
        finish();
     }
     });

In the calling activity I have the following listening for the return as follows;

protected void onActivityResult(int requestCode, int resultCode, 
        Intent data) { 
            switch(requestCode) { 
            //TODO
            case RECIPE_CHOOSER:
                Toast.makeText(getApplicationContext(), "In recipe return", Toast.LENGTH_SHORT).show();
                Toast.makeText(getApplicationContext(), "resultCode is " + String.valueOf(resultCode), Toast.LENGTH_SHORT).show();
                if (resultCode == RESULT_OK) {
                Bundle b = getIntent().getExtras();

                Toast.makeText(getApplicationContext(), "Returned " + b.getString("TEXT"), Toast.LENGTH_LONG).show();
                }
                if (resultCode == RESULT_CANCELED) {

                    }
                break;

                } 
            } 
        }

I can see that the request code is correctly returned, but the resultcode is always a 0 and the data is always a null.

I've ran through the debug and the setResult is doing its job and the bundle does indeed have the data I'm passing, but it's lost at some point along the way.

Is there something in the manifest I'm missing or something. It's killed my progress on this project so far.

Any help would truly be appreciated.

Thanks, Dean


Source: (StackOverflow)

How to export solr result into a text file?

I needs to export doc_id, all fields, socr, rank of one search result to evaluate the results. How can I do this in solr?


Source: (StackOverflow)

Getting object as a result from func/proc in Delphi

What is the best practice for returning simple objects from functions / procedures in delphi?

eg. 2 kinds of code:

pass created object as reference, populate object in Proc, destroy it afterwards

procedure Proc(var Obj: TMyObject);
begin
  // populate Obj
end;

O := TMyObject.Create;
try
  Proc(O);
  // manipulate populated object
finally
  O.Free;
end;

or get created object as result from function, destroy after manipulation

function Func: TMyObj;
begin
  Result := TMyObj.Create;
end;

O := Func;
if O <> nil then
begin
  try
    // manipulate
  finally
    O.Free;
  end;
end;

Source: (StackOverflow)

Result consisted of more than one row Error 1172 mysql

Hello im having a hard time with this stored procedure. im getting the error: Result consisted of more than one row.

here is my stored procedure:

DELIMITER $$

DROP PROCEDURE IF EXISTS `dss`.`COSTRET` $$
CREATE DEFINER=`dwadmin`@`192.168.%.%` PROCEDURE `COSTRET`( TDATE DATE)
BEGIN
    DECLARE done INT DEFAULT 0;
    DECLARE ls_id VARCHAR(8);
    DECLARE ld_cost DECIMAL(10,4);
      DECLARE ld_retail DECIMAL(10,4);
    DECLARE cur1 CURSOR FOR SELECT DISTINCT `id` FROM `prod_performance` WHERE `psc_week` = TDATE;
    DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;

  -- Get the Cost
  CREATE TEMPORARY TABLE IF NOT EXISTS `prod_itemcost`
    SELECT DISTINCTROW `itemcode` ID, `mlist` COST
    FROM (SELECT `itemcode`, `pceffdate`, `mlist`
        FROM `purchcost` a
        where `pceffdate` = (SELECT MAX(z.`pceffdate`) FROM `purchcost` z WHERE z.`itemcode` = a.`itemcode`
        AND z.`pceffdate` <= TDATE)) tb
    ORDER BY `itemcode`;

    OPEN cur1;
    REPEAT
      FETCH cur1 INTO ls_id;
      IF NOT done THEN
            SELECT DISTINCTROW `cost` INTO ld_cost FROM `prod_itemcost` WHERE id = ls_id;

        UPDATE LOW_PRIORITY `prod_performance` SET `current_cost` = ld_cost WHERE `psc_week` = TDATE and `id` = ls_id;
      END IF;
    UNTIL done END REPEAT;
    CLOSE cur1;

   -- Destroy Temporary Tables
   DROP TEMPORARY TABLES IF EXISTS `prod_itemcost`;
END $$

DELIMITER ;

Any solutions and recommendations are much appreciated!


Source: (StackOverflow)

Android activity lifecycle

Quick question - what is called first when activity is restored? onRestoreInstanceState or onActivityResult?


Source: (StackOverflow)