Hi,
I have a table, and it is returning the data as -
Column1 Column2 Column3 Column4 Column5 Column6
-------------------------------------------------------------------
6 Joy Mycity NZ 123456 [email protected]
I need to disply it as -
SingleColumn
-----------------------
6
joy
mycity
NZ
123456
[email protected]
How do I do it?
I have a kind of strange thing that I really nead for my text formating. Don't ask me please why I did this strange thing! ;-)
So, my PHP script replaces all line foldings "\n" with one of the speacial symbol like "|". When I insert text data to database, the PHP script replaces all line foldings with the symbol "|" and when the script reads text data from the database, it replaces all special symbols "|" with line folding "\n".
I want to restrict text format in the way that it will cut line foldings if there are more than 2 line foldings used in each separating texts.
Here is the example of the text I want the script to format:
this is text... this is text... this is text...this is text...this is text... this is text... this is text... this is text... this is text... this is text...
this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text...
I want to restict format like:
this is text... this is text... this is text...this is text...this is text... this is text... this is text... this is text... this is text... this is text...
this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text...
So, at the first example there is only one line folding between 2 texts and on the second example there are 3 line foldings between 2 texts.
How it can be possible to replace more than 2 line foldings symbols "|" if they are detected on the text?
This is a kind of example I want the script to do:
$text = str_replace("|||", "||", $text);
$text = str_replace("||||", "||", $text);
$text = str_replace("|||||", "||", $text);
$text = str_replace("||||||", "||", $text);
$text = str_replace("|||||||", "||", $text);
...
$text = str_replace("||||||||||", "||", $text);
$text = str_replace("|", "<br>", $text);
HM, I HAVE PROBLEMS! THIS DOES NOT WORK WHEN TEXT DATA IS SENT IN POST METHOD. LOOK AT THIS:
//REPLACING ALL LINE FOLDINGS WITH SPECIAL SYMBOL
$_POST["text"] = str_replace("\n","|",$_POST["text"]);
// REMOVING ALL LINE FOLDINGS
$_POST["text"] = trim($_POST["text"]);
// IF THERE ARE MORE THAN 3 LINE HOLDINGS - FORMAT TO 1 LINE HOLDING
$_POST["text"] = preg_replace("/\|{3,}/", "||", $_POST["text"]);
echo $_POST["text"];
Are there any ASP.NET GridView's RowCreated, RowDataBound counterpart methods?
All I want is to break a string into lines before displaying. I've put Environment.NewLine to create a line break but have no success till now. So I think I need to RowCreated or RowDataBound, etc. events to make modifications.
I have hard times using maven to generate my client. So Please refer to http://stackoverflow.com/questions/2131001/creating-a-web-service-client-directly-from-the-source for the first part of my question.
To keep it simple and short, I want to go from here (a file in src/main/java) :
package com.example.maven.jaxws.helloservice;
import javax.jws.WebService;
@WebService
public class Hello {
public String sayHello(String param) {
; return "Hello " + param;
}
}
to there :
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.1.7-b01-
* Generated source version: 2.1
*
*/
@WebServiceClient(name = "HelloService", targetNamespace = "http://helloservice.jaxws.maven.example.com/", wsdlLocation = "http://localhost:8080/test/")
public class HelloService
extends Service
{
private final static URL HELLOSERVICE_WSDL_LOCATION;
private final static Logger logger = Logger.getLogger(com.example.wsimport.HelloService.class.getName());
...etc
using only 1 pom.xml file.
Please note the wsdlLocation set on the end.
The pom.xml file will probably use both maven-jaxws-plugin wsgen AND wsimport with some tricky configuration to achieve this.
Hi Good Guys,
I need your help. Please help me as I am a newbie using VB.NET.
I have been asked to transfer DATAREADER rows into Crystal Report DATASET1.XSD
Here are the coding
Private Sub BtnTransfer()
dim strsql as string = "Select OrderID, OrderDate from ORDERS"
dim DS as new dataset1 '<---crysal report dataset1.xsd
dim DR as SqlDataReader
dim RW as DataRow = DS.Tables(0).NewRow
sqlconn = new sqlconnection(ConnString)
sqlcmd = new sqlCommand(strSql, sqlconn)
sqlcmd.Connection.open()
DR = sqlcmd.ExecuteReader(CommandBehaviour.CloseConnection)
Do while DR.READ
RW("OrderID") = DR("OrderID")
RW("OrderDate") = DR(OrderDate")
DS.Tables(0).Rows.ADD(RW)
Loop
End sub
Suppose a tree structure is implemented in SQL like this:
CREATE TABLE nodes (
id INTEGER PRIMARY KEY,
parent INTEGER -- references nodes(id)
);
Although cycles can be created in this representation, let's assume we never let that happen. The table will only store a collection of roots (records where parent is null) and their descendants.
The goal is to, given an id of a node on the table, find all nodes that are descendants of it.
A is a descendant of B if either A's parent is B or A's parent is a descendant of B. Note the recursive definition.
Here is some sample data:
INSERT INTO nodes VALUES (1, NULL);
INSERT INTO nodes VALUES (2, 1);
INSERT INTO nodes VALUES (3, 2);
INSERT INTO nodes VALUES (4, 3);
INSERT INTO nodes VALUES (5, 3);
INSERT INTO nodes VALUES (6, 2);
which represents:
1
`-- 2
|-- 3
| |-- 4
| `-- 5
|
`-- 6
We can select the (immediate) children of 1 by doing this:
SELECT a.* FROM nodes AS a WHERE parent=1;
We can select the children and grandchildren of 1 by doing this:
SELECT a.* FROM nodes AS a WHERE parent=1
UNION ALL
SELECT b.* FROM nodes AS a, nodes AS b WHERE a.parent=1 AND b.parent=a.id;
We can select the children, grandchildren, and great grandchildren of 1 by doing this:
SELECT a.* FROM nodes AS a WHERE parent=1
UNION ALL
SELECT b.* FROM nodes AS a, nodes AS b WHERE a.parent=1 AND b.parent=a.id
UNION ALL
SELECT c.* FROM nodes AS a, nodes AS b, nodes AS c WHERE a.parent=1 AND b.parent=a.id AND c.parent=b.id;
How can a query be constructed that gets all descendants of node 1 rather than those at a finite depth? It seems like I would need to create a recursive query or something.
I'd like to know if such a query would be possible using SQLite. However, if this type of query requires features not available in SQLite, I'm curious to know if it can be done in other SQL databases.
When I use a RelativeLayout with either fill_parent or wrap_content as height and an element which specifies: android:layout_alignParentBottom="true" it is ignored and it is aligned at the top. Setting the height of the RelativeLayout to an explicit value makes it work. Any clues?
I have 2 tables with data thus:
Col1 Col2
------- --------
Admin001 A
Admin001 B
Admin002 C
Admin002 C
Admin003 A
Admin003 C
I need to find all instances of Col2 values with 'A' immediately followed by 'B'. 'A' followed by any other symbol does not count. Is there a way to use SQL to accomplish this?
Environment is DB2 LUW v9.5
Hey Guys,
This question seems ridiculously easy, but I seem to be stuck.
Lets say we have a table "Books"
Each Book, has a name, description, and a status.
Lets say I want to create link in the show view, that when clicked, solely changes the status (to "read") for example.
So far, I've tried adding a block in the controller, that says:
def read
@book = Book.find(params[:id])
@book.status = "Read"
@book.update_attributes(params[:book])
respond_to do |format|
format.html { redirect_to :back}
format.xml { render :xml => @book }
end
end
Then I've added a link to the view that is like:
<%= link_to "Read", read_book_path(@book), :method = :put %
This isn't working at all. I have added it to my routes, but it doesn't seem to matter.
Any help would be great! Thanks!
-Elliot
EDIT: Forgot to add I'm getting a NoMethodError: undefined method `read_book_path'
Hi there,
I'm not sure if this is possible what I'm trying to achieve. I want to get the avg of averaged columns.
SELECT avg(col1), avg(col2), avg(col3) FROM tbl
My Result should be the avg of all three avg columns, is this possible? Something like this
SELECT avg( col1, col2, col3) FROM tbl
doesn't work at MySQL 5.1
Given the following example data:
Users
+--------------------------------------------------+
| ID | First Name | Last Name | Network Identifier |
+--------------------------------------------------+
| 1 | Billy | O'Neal | bro4 |
+----+------------+-----------+--------------------+
| 2 | John | Skeet | jsk1 |
+----+------------+-----------+--------------------+
Hardware
+----+-------------------+---------------+
| ID | Hardware Name | Serial Number |
+----+-------------------+---------------+
| 1 | Latitude E6500 | 5555555 |
+----+-------------------+---------------+
| 2 | Latitude E6200 | 2222222 |
+----+-------------------+---------------+
HardwareAssignments
+---------+-------------+-------------+
| User ID | Hardware ID | Assigned On |
+---------+-------------+-------------+
| 1 | 1 | April 1 |
+---------+-------------+-------------+
| 1 | 2 | April 10 |
+---------+-------------+-------------+
| 2 | 2 | April 1 |
+---------+-------------+-------------+
| 2 | 1 | April 11 |
+---------+-------------+-------------+
I'd like to write a SQL query which would give the following result:
+--------------------+------------+-----------+----------------+---------------+-------------+
| Network Identifier | First Name | Last Name | Hardware Name | Serial Number | Assigned On |
+--------------------+------------+-----------+----------------+---------------+-------------+
| bro4 | Billy | O'Neal | Latitude E6200 | 2222222 | April 10 |
+--------------------+------------+-----------+----------------+---------------+-------------+
| jsk1 | John | Skeet | Latitude E6500 | 5555555 | April 11 |
+--------------------+------------+-----------+----------------+---------------+-------------+
My trouble is that the maximum "Assigned On" date for each user needs to be selected for each individual user and used for the actual join ...
Is there a clever way accomplish this in SQL?
I'm faced with a bit of a difficult problem. I store all the versions of all documents in a single table. Each document has a unique id, and the version is stored as an integer which is incremented everytime there is a new version.
I need a query that will only select the latest version of each document from the database. While using GROUP BY works, it appears that it will break if the versions are not inserted in the database in the order of version (ie. it takes the maximum ROWID which will not always be the latest version).
Note, that the latest version of each document will most likely be a different number (ie. document A is at version 3, and document B is at version 6).
I'm at my wits end, does anybody know how to do this (select all the documents, but only return a single record for each document_id, and that the record returned should have the highest version number)?
Hello!
This is driving me nuts.
I have a TableView with custom cells. My cell contains a editble textview. Is it possible to change rowheight on cell and textview dynamicly (when I editing the textView) ?
best regards
I have a large database and am putting together a report of the data. I have aggregated and summed the data from many tables to get two tables that look like the following.
id | code | value id | code | value
13 | AA | 0.5 13 | AC | 2.0
13 | AB | 1.0 14 | AB | 1.5
14 | AA | 2.0 13 | AA | 0.5
15 | AB | 0.5 15 | AB | 3.0
15 | AD | 1.5 15 | AA | 1.0
I need to get a list of id's, with the code (sumed from both tables) with the largest value.
13 | AC
14 | AA
15 | AB
There are 4-6 thousand records and it is not possible to change the original tables. I'm not too worried about performance as I only need to run it a few times a year.
edit:
Let me see if I can explain a bit more clearly, imagine the id is the customer id, the code is who they ordered from and the value is how much they spent there.
I need a list of the all the customer id's and the store that customer spent the most money at (and if they spent the same at two different stores, put a value such as 'ZZ' in for the store name).
I write custom jabber client in iphone.
I use xmppframework as engine.
And I have UITableViewController with NSMutableArray for repesent contact list.
When i receive(or somebody change it contents) roster (aka contact list) i wanna change UITableView items (add/remove/modify). So if User work with listView at time when list updates by
[items addObject:newItem];
[self.tableView reloadData];
user lost current selection item.
So, my question is howto save (if possible, i mean if given selected item not removed) current select item after reloadData?
Thx.
Hello, I have a table A where I put many image resources with a daily frequence.
Every record of table A references another table B in which there are only fixed records.
My doubt is the following, better to clean all records in A and then inserting new images or
updating only the binary column of all records.
What your advice?
What is the mysql I need to achieve the result below given these 2 tables:
table1:
+----+-------+
| id | name |
+----+-------+
| 1 | alan |
| 2 | bob |
| 3 | dave |
+----+-------+
table2:
+----+---------+
| id | state |
+----+---------+
| 2 | MI |
| 3 | WV |
| 4 | FL |
+----+---------+
I want to create a temporary view that looks like this
desired result:
+----+---------+---------+
| id | name | state |
+----+---------+---------+
| 1 | alan | |
| 2 | bob | MI |
| 3 | dave | WV |
| 4 | | FL |
+----+---------+---------+
I tried a mysql union but the following result is not what I want.
create view table3 as
(select id,name,"" as state from table1)
union
(select id,"" as name,state from table2)
table3 union result:
+----+---------+---------+
| id | name | state |
+----+---------+---------+
| 1 | alan | |
| 2 | bob | |
| 3 | dave | |
| 2 | | MI |
| 3 | | WV |
| 4 | | FL |
+----+---------+---------+
First suggestion results:
SELECT *
FROM table1
LEFT OUTER JOIN table2 USING (id)
UNION
SELECT *
FROM table1
RIGHT OUTER JOIN table2 USING (id)
+----+---------+---------+
| id | name | state |
+----+---------+---------+
| 1 | alan | |
| 2 | bob | MI |
| 3 | dave | WV |
| 2 | MI | bob |
| 3 | WV | dave |
| 4 | FL | |
+----+---------+---------+
HI,
I am having one check box and one table and table has 10 rows .If user selects the check box then all the 10 rows in the vaadin table should need to select but i don't know how to achieve this functionality.Can anyone tell me how to achieve this? If possible provide me some code snippet.
Dear All, please help me since I'm newbie in SQL Server. I have a select query that currently produces the following results:
DoctorName Team Visit date
dr. As A 5
dr. Sc A 4
dr. Gh B 6
dr. Nd C 31
dr As A 7
Using the following query:
SELECT d.DoctorName, t.TeamName, ca.VisitDate FROM cActivity AS ca
INNER JOIN doctor AS d ON ca.DoctorId = d.Id
INNER JOIN team AS t ON ca.TeamId = t.Id
WHERE ca.VisitDate BETWEEN '1/1/2010' AND '1/31/2010'
I want to produce the following:
DoctorName Team 1 2 3 4 5 6 7 ... 31 Visited
dr. As A x x ... 2 times
dr. Sc A x ... 1 times
dr. Gh B x ... 1 times
dr. Nd C ... X 1 times
This is my activity class i want to add one textview to TableRow but i cannot show the textview in TableLayout.
Activity
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.ViewGroup.LayoutParams;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import android.widget.LinearLayout;
public class TableRunTime extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TableLayout tl = (TableLayout) findViewById(R.id.arcitle_content_table);
TextView txt = new TextView(this);
TableRow tr = new TableRow(this);
txt.setText("Book Name");
txt.setTextColor(Color.WHITE);
txt.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
tr.addView(txt);
tl.addView(tr, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
}
}
This is manifest file
any one help how to show textview in TableLayout
I have a class called forest and a property called fixedPositions that stores 100 points (x,y) and they are stored 250x2 (rows x columns) in MatLab. When I select 'fixedPositions', I can click scatter and it will plot the points.
Now, I want to rotate the plotted points and I have a rotation matrix that will allow me to do that.
The below code should work:
theta = obj.heading * pi/180;
apparent = [cos(theta) -sin(theta) ; sin(theta) cos(theta)] * obj.fixedPositions;
But it wont. I get this error.
??? Error using == mtimes
Inner matrix dimensions must agree.
Error in == landmarkslandmarks.get.apparentPositions at 22
apparent = [cos(theta) -sin(theta) ; sin(theta) cos(theta)] * obj.fixedPositions;
When I alter forest.fixedPositions to store the variables 2x250 instead of 250x2, the above code will work, but it wont plot. I'm going to be plotting fixedPositions constantly in a simulation, so I'd prefer to leave it as it, and make the rotation work instead.
Any ideas?
Also, fixed positions, is the position of the xy points as if you were looking straight ahead. i.e. heading = 0. heading is set to 45, meaning I want to rotate points clockwise 45 degrees.
Here is my code:
classdef landmarks
properties
fixedPositions %# positions in a fixed coordinate system. [x, y]
heading = 45; %# direction in which the robot is facing
end
properties (Dependent)
apparentPositions
end
methods
function obj = landmarks(numberOfTrees)
%# randomly generates numberOfTrees amount of x,y coordinates and set
%the array or matrix (not sure which) to fixedPositions
obj.fixedPositions = 100 * rand([numberOfTrees,2]) .* sign(rand([numberOfTrees,2]) - 0.5);
end
function obj = set.apparentPositions(obj,~)
theta = obj.heading * pi/180;
[cos(theta) -sin(theta) ; sin(theta) cos(theta)] * obj.fixedPositions;
end
function apparent = get.apparentPositions(obj)
%# rotate obj.positions using obj.facing to generate the output
theta = obj.heading * pi/180;
apparent = [cos(theta) -sin(theta) ; sin(theta) cos(theta)] * obj.fixedPositions;
end
end
end
P.S. If you change one line to this: obj.fixedPositions = 100 * rand([2,numberOfTrees]) .* sign(rand([2,numberOfTrees]) - 0.5);
Everything will work fine... it just wont plot.
In the cakePHP project I'm building, I want to insert a defined number of identical records. These will serve as placeholders records that will have additional data added later. Each record will insert the IDs taken from two belongs_to relationships as well as two other string values.
What I want to do is be able to enter a value for the number of records I want created, which would equate to how many times the data is looped during save.
What I don't know is:
1) how to setup a loop to handle a set number of inserts
2) how to define a form field in cakePHP that only sets the number of records to create.
What I've tried is the following:
function massAdd() {
$inserts_required = 1;
while ($inserts_required <= 10) {
$this->Match->create();
$this->Match->save($this->data);
echo $inserts_required++;
}
$brackets = $this->Match->Bracket->find('list');
$this->set(compact('brackets'));
}
What happens is:
1) at the top of the screen, above the doc type, the string 12345678910 is displayed, this is displayed on screen
2) a total of 11 records are created, and only the last record has the values passed in the form. I don't know why 11 records as opposed to 10 are created, and why only the last records has the entered form data?
As always, your help and direction is appreciated.
-Paul