Search Results

Search found 7127 results on 286 pages for 'calculated columns'.

Page 221/286 | < Previous Page | 217 218 219 220 221 222 223 224 225 226 227 228  | Next Page >

  • OneToMany association updates instead of insert

    - by Shvalb
    I have an entity with one-to-many association to child entity. The child entity has 2 columns as PK and one of the column is FK to the parent table. mapping looks like this: @OneToMany(cascade = {CascadeType.ALL}, fetch = FetchType.EAGER ) @JoinColumn(name="USER_RESULT_SEQUENCES.USER_RESULT_ID", referencedColumnName="USER_RESULT_ID", unique=true, insertable=true, updatable=false) private List<UserResultSequence> sequences; I create an instance of parent and add children instances to list and then try to save it to DB. If child table is empty it inserts all children and it works perfectly. if the child table is not empty it updates existing rows! I don't know why it updates instead of inserts, any ideas why this might happen?? Thank you!

    Read the article

  • question about adding another column to a sql statement

    - by every_answer_gets_a_point
    i am starting with this table: SELECT [Lab Occurrence Form].[Practice Code], [Lab Occurrence Form].[1 0 Preanalytical (Before Testing)], Count([Lab Occurrence Form].[1 0 Preanalytical (Before Testing)]) AS [CountOf1 0 Preanalytical (Before Testing)] FROM [Lab Occurrence Form] WHERE ((([Lab Occurrence Form].[Occurrence Date]) Between [Forms]![By Number]![Text4] And [Forms]![By Number]![Text2])) GROUP BY [Lab Occurrence Form].[Practice Code], [Lab Occurrence Form].[1 0 Preanalytical (Before Testing)] HAVING ((([Lab Occurrence Form].[Practice Code])<>"") AND ((Count([Lab Occurrence Form].[1 0 Preanalytical (Before Testing)]))<>0)); it selects 3 columns but i need to aggregate the comments and put it in the fourth column where the first two values are the same

    Read the article

  • Beginners PHP / mySQL question

    - by Reg H
    I'm brand new to PHP & MySQL, and one function I'm creating needs to access a large table or database. I've created the database and it's currently in a MySQL table, which I'm accessing with no problem. The table is 11,000 rows in length, with 8 columns (all text less than 8 characters long) - it's static, and will never change. Without getting too particular, my users will hit a button which will trigger scripts to access the data, say 500 times or more. So in general would it be better practice to include all of this data in a big 'switch' or 'if... then' conditional right in my scripts, rather than opening and accessing the database connection hundreds, or maybe even thousands of times? It just seems like that might be a bottleneck waiting to happen. Thanks!

    Read the article

  • How to map one class against multiple tables with SQLAlchemy?

    - by tote
    Lets say that I have a database structure with three tables that look like this: items - item_id - item_handle attributes - attribute_id - attribute_name item_attributes - item_attribute_id - item_id - attribute_id - attribute_value I would like to be able to do this in SQLAlchemy: item = Item('item1') item.foo = 'bar' session.add(item) session.commit() item1 = session.query(Item).filter_by(handle='item1').one() print item1.foo # => 'bar' I'm new to SQLAlchemy and I found this in the documentation (http://www.sqlalchemy.org/docs/05/mappers.html#mapping-a-class-against-multiple-tables): j = join(items, item_attributes, items.c.item_id == item_attributes.c.item_id). \ join(attributes, item_attributes.c.attribute_id == attributes.c.attribute_id) mapper(Item, j, properties={ 'item_id': [items.c.item_id, item_attributes.c.item_id], 'attribute_id': [item_attributes.c.attribute_id, attributes.c.attribute_id], }) It only adds item_id and attribute_id to Item and its not possible to add attributes to Item object. Is what I'm trying to achieve possible with SQLAlchemy? Is there a better way to structure the database to get the same behaviour of "dynamic columns"?

    Read the article

  • How to remove row which has one or more empty or null cell ?

    - by Harikrishna
    I have datagridview on my winform. I am displaying records in the datagridview. Now after displaying the records on the datagridview, I want to remove the row from datagridview which has one or more empy cells that is no value in the cell for that row. So for that I am checking each cell for every row if there is any cell empty or null then I remove that rows using RemoveAt() function. My code is : for (int i = 0; i < dataGridView1.Rows.Count - 1; i++) { for (int j = 0; j < dataGridView1.Columns.Count; j++) { if (string.IsNullOrEmpty(dataGridView1.Rows[i].Cells[j].Value.ToString())) { dataGridView1.Rows.RemoveAt(i); break; } } }

    Read the article

  • C# - Saving a DataGridView to file and loading

    - by Rekar
    Hello, To start off, what I have is a simple Winforms app, with just a save and load button, and with a datagridview control to hold data. What I am looking to do is input some data into the control, hit the save button, and it save all the data to a file locally on the computer, and when I hit load, it loads the file and populates the control appropriately, keeping all rows, columns, and data the same as when saved. Although it sounds fairly simple to me, I cant seem to figure a good way to save and load the data. Can I get a few pointers or examples to get myself started? Thank you.

    Read the article

  • Wierd characters in exported csv files when converting

    - by Ahue
    Hey guys, I came across a problem I cannot solve on my own concerning the downloadable csv formatted trends data files from Google Insights for Search. I'm to lazy to reformat the files I4S gives me manually what means: Extracting the section with the actual trends data and reformatting the columns so that I can use it with a modelling program I do for school. So I wrote a tiny script the should do the work for me: Taking a file, do some magic and give me a new file in proper format. What it's supposed to do is reading the file contents, extracting the trends section, splitting it by newlines, splitting each line and then reorder the columns and maybe reformat them. When looking at a untouched I4S csv file it looks normal containing CR LF caracters at line breaks (maybe thats only because I'm using Windows). When just reading the contents and then writing them to a new file using the script wierd asian characters appear between CR and LF. I tried the script with a manually written similar looking file and even tried a csv file from Google Trends and it works fine. I use Python and the script (snippet) I used for the following example looks like this: # Read from an input file file = open(file,"r") contents = file.read() file.close() cfile = open("m.log","w+") cfile.write(contents) cfile.close() Has anybody an idea why those characters appear??? Thank you for you help! I'll give you and example: First few lines of I4S csv file: Web Search Interest: foobar Worldwide; 2004 - present Interest over time Week foobar 2004-01-04 - 2004-01-10 44 2004-01-11 - 2004-01-17 44 2004-01-18 - 2004-01-24 37 2004-01-25 - 2004-01-31 40 2004-02-01 - 2004-02-07 49 2004-02-08 - 2004-02-14 51 2004-02-15 - 2004-02-21 45 2004-02-22 - 2004-02-28 61 2004-02-29 - 2004-03-06 51 2004-03-07 - 2004-03-13 48 2004-03-14 - 2004-03-20 50 2004-03-21 - 2004-03-27 56 2004-03-28 - 2004-04-03 59 Output file when reading and writing contents: Web Search Interest: foobar ??????????? ? ? ? ????????? ????????? ???? ?????? Week foobar ?? ?? ?? ? ? ? ?? ??? ????? 2004-01-11 - 2004-01-17 44 ?? ?? ???? ? ? ?? ????????? 2004-01-25 - 2004-01-31 40 ?? ?? ?? ? ? ? ?? ?? ?????? 2004-02-08 - 2004-02-14 51 ?? ?? ???? ? ? ?? ????????? 2004-02-22 - 2004-02-28 61 ?? ?? ???? ? ? ?? ?? ?????? 2004-03-07 - 2004-03-13 48 ?? ?? ???? ? ? ?? ??? ?? ?? 2004-03-21 - 2004-03-27 56 ?? ?? ???? ? ? ?? ?? ?????? 2004-04-04 - 2004-04-10 69 ?? ?? ???? ? ? ?? ????????? 2004-04-18 - 2004-04-24 51 ?? ?? ???? ? ? ?? ?? ?????? 2004-05-02 - 2004-05-08 56 ?? ?? ?? ? ? ? ?? ????????? 2004-05-16 - 2004-05-22 54 ?? ?? ???? ? ? ?? ????????? 2004-05-30 - 2004-06-05 74 ?? ?? ?? ? ? ? ?? ????????? 2004-06-13 - 2004-06-19 50 ?? ?? ??? ? ? ?? ????????? 2004-06-27 - 2004-07-03 58 ?? ?? ?? ? ? ? ?? ??? ????? 2004-07-11 - 2004-07-17 59 ?? ?? ???? ? ? ?? ?????????

    Read the article

  • Why is [date] + [time] non-deterministic in SQL Server 2008?

    - by John Gietzen
    I'm trying to do the following for my IIS logs table: ALTER TABLE [W3CLog] ADD [LogTime] AS [date] + ([time] - '1900-01-01') PERSISTED However, SQL Server 2008 tells me: Computed column 'LogTime' in table 'W3CLog' cannot be persisted because the column is non-deterministic. The table has this definition: CREATE TABLE [dbo].[W3CLog]( [Id] [bigint] IDENTITY(1,1) NOT NULL, ... [date] [datetime] NULL, [time] [datetime] NULL, ... ) Why is that non-deterministic? I really need to index that field. The table currently has 1598170 rows, and it is a pain to query if we can't do an index seek on the full time. Since this is being UNION'd with some other log formats, we can't very easily just use the two columns separately.

    Read the article

  • Variable from block is put into a calculation but throws off wrong reading

    - by user2926620
    I am having troubles with trying to retrieve a double variable that is already established outside the block and called inside but I want to return the value of the same variable so that I can apply it to a calculation. the variable that I want returned is: double quarter = 0; but when I plug it into quarter in my first else/if statement, it plugs in 0 and not the value in my switch block. What can I do to retrieve the value? double quarter = 0; //Date entry will be calculated by how much KW user enters switch (input) { case "2/15/13": quarter = kwUsed * 0.10; break; case "4/15/13": quarter = kwUsed * 0.12; break; case "8/15/13": quarter = kwUsed * 0.15; break; case "11/15/13": quarter = kwUsed * 0.15; break; default: System.out.println("Invalid date"); } //Declaring variables for calculations double base = 0; double over = 0; double excess = 0; double math1 = 0; double math2 = 0; //KW Calculations if (kwUsed <= 350) { base = quarter; }else if (kwUsed <= 500) { math1 = ((kwUsed - 350) * quarter); base = ((kwUsed * quarter) - math1); over = ((math1 * 0.1) + math1); }else if (kwUsed > 500) { math2 = ((kwUsed - 350) * 0.1); base = ((kwUsed * 0.1) - math2); math2 = ((kwUsed -350) - 50); over = ((math2 * 0.1) + (15 * 0.1)); double math3 =((kwUsed - 500) * 0.1); excess = ((math3 * 0.25) + math3); } Edited to clarify question.

    Read the article

  • 'For' Loop Within a 'For' Loop and Then Another?

    - by BenjaminFranklin
    This has confused me quite a bit, but it's also really interesting! I want to loop through a grid of 9 elements in an array, multiply them all by 1/9. Then, I want to find the sum of those 9 elements and replace each individual element's with the value calculated as the sum. After I've done this, I want to move on to the next nine elements. To clarify, I want all 9 elements to be changed to myVal, in the code below. So far I've got the loop within a loop bit, but I don't know how to then go back and replace each of the values with the sum of all of them combined. Here's my code:- previousx = 0; previousy= 0; for (int x = previousx; x < previousx+4; x++) { for(int y = previousy; y < previousy+4; y++) { y = y*(1/9); yVal += y; } } Any advice would, of course, be greatly appreciated.

    Read the article

  • SQL - logical AND among multiple rows

    - by potrnd
    Hello, First of all sorry that I could not think of a more descriptive title. What I want to do is the following using only SQL: I have some lists of strings, list1, list2 and list3. I have a dataset that contains two interesting columns, A and B. Column A contains a TransactionID and column B contains an ItemID. Naturally, there can be multiple rows that share the same TransactionIDs. I need to catch those transactions that have at least one item ID that exists whithin each list (list1, list2 AND list3). I also need to count how many times does that happen for each transaction. I hope that makes enough sense, perhaps I will be able to explain it better with a clear head. Thanks in advance

    Read the article

  • Android SDK and Java

    - by Soonts
    Android SDK Manager complains "WARNING: Java not found in your path". Instead of using the information from Windows registry, the software tries to search Java in the default installation folders, and fails (I don't install software in program files because I don't like space characters in my paths). Of course I know how to modify the %PATH% environment variable. The question is — which Java does it need? After installing the latest JDK, I’ve got 4 distinct versions of java.exe file, in the following 4 folders: system32, jre6\bin, jdk1.6.0_26\bin, and jdk1.6.0_26\jre\bin. Size ranges from 145184 to 171808. All of them print version “1.6.0_26” when launched with the “-version” argument. The one in system32 has .exe version “6.0.250.6”, the rest of them is “6.0.260.3”. All 4 files are different (I’ve calculated the MD5 checksums). Q1. Which folder should I add to %PATH% to make the Android SDK happy? Q2. Why does Oracle build that many variants of java.exe of the same version for the same platform? Thanks in advance! P.S. I'm using Windows 7 SP1 x64 home premium, and downloaded the 64-bit version of JDK, jdk-6u26-windows-x64.exe.

    Read the article

  • I want to make a wrapped acces type for certain internals of one of classes and I have some performa

    - by Alex
    I am writing an abstract matrix class (and some concrete subclasses) for use on very differing hardwares/architectures, etc. and I want to write a row and column type that provides a transparent reference to the rows and columns of the matrix. However, I want to tune for performance, so I'd like this class to be essentially a compiler construct. In other words, I'm willing to sacrifice some dev time to making the overhead of these classes as small as possible. I assume all (small) methods would want to be virtual? Keep the structure small? Any other suggestions?

    Read the article

  • compare two characters based on subset

    - by schultem
    I have a simple dataframe with two columns: df <- data.frame(x = c(1,1,2,2,3), y = c(rep(1:2,2),1), target = c('a','a','a','b','a')) I would like to compare the strings in the target column (find out whether they are equal or not, i.e., TRUE or FALSE) within every level of x (same number for x). First I would like to compare lines 1 and 2, then 3 and 4 ... My problem is that I am missing some comparisons, for example, line 5 has only one case instead of two - so it should turn out to be FALSE. Variable y indicates the first and second case within x. I played around with ddply doing something like: ddply(df, .(x), summarise, ifelse(as.character(df[df$y == '1',]$target), as.character(df[df$y == '2',]$target),0,1)) which is ugly ... and does not work ... Any insights how I could achieve this comparison? Thanks

    Read the article

  • How to make UPDATE queries in LINQ to SQL?

    - by Alex
    I like using LINQ to SQL. The only problem is that I don't like the default way of updating tables. Let's say I have the following table with the following columns: ID (primary key), value1, value2, value3, value4, value5 When I need to update something I call UPDATE ... WHERE ID=@id LINQ to SQL call UPDATE ... WHERE ID=@id and value1=@value1 and value2=@value2 and value3=@value3 and value4=@value4 and value5=@value5 I can override this behavior by adding UpdateCheck=UpdateCheck.Never to every column, but with every update of the DataContext class with the GUI, this will be erased. Is there any way to tell LINQ to use this way of updating data?

    Read the article

  • Getting id of row just inserted into MySQL database

    - by James P
    I have my table columns set like this: likes(id, like_message, timestamp) id is the primary key that is auto incrementing. This is the SQL that I use to add a row: $sql = "INSERT INTO `likes` (like_message, timestamp) VALUES ('$likeMsg', $timeStamp)"; Everything works, but now I need to throw back the id attribute of the newly inserted row. For example, if I insert a row and the id of that row is 13, I need to echo out 13 so my AJAX request can pick that up and use it. Any help would be appreciated, as well as related code samples. Thanks :)

    Read the article

  • rails summing column values of rows with similar attributes

    - by butterywombat
    Hi all, I have a Sites table that has columns name, and time. The name does not have to be unique. So for example I may have the entries 'hi.com, 5', 'hi.com, 10', 'bye.com, 4'. I would like to sum up all the unique sites so that i get 'hi.com, 15' and 'bye.com, 4' for plotting purposes. How can I do that? (For some reference I was looking at http://railscasts.com/episodes/223-charts but I couldn't get the following (translated to my table) to work def self.total_on(date) where("date(purchased_at) = ?", date).sum(:total_price) end nor do I really understand the syntax of the 'where("date(purchased_at) = ?", date)' part. Thanks for helping a rails newbie!

    Read the article

  • how to integrate my users database table with the aspnet_users table that comes with asp.net members

    - by ooo
    i have a database that already has a users table COLUMNS: userID - int loginName - string First - string Last - string i just installed the asp.net membership table. Right now all of my tables are joined into my users table foreign keyed into the "userId" field How do i integrate asp.net_users table into my schema? here are the ideas i thought of: Add a membership_id field to my users table and on new inserts, include that new field in my users table. This seems like the cleanest way as i dont need to break any existing relationships. break all existing relationship and move all of the fields in my user table into the asp.net_users table. This seems like a pain but ultimately will lead to the most simple, normalized solution any thoughts?

    Read the article

  • How to create "lock" (stop updating of cells) in Excel?

    - by Oozi
    My question is pretty simple, but one to which I can't really find a solution myself. I use Excel quite frequently, but rarely the fancy stuff. Anyway, to the point: How do I create a dropmenu that will lock certain cells, rows or columns? (by lock I mean unable to change via hand and stops updating itself). Example: A1 = 5 B1 = A1 * 100 Can I "lock" the B1-cell, so that changing A1 will have no effect on B1 (Will remain at value 500)? I would preferably want to be able to "unlock" the cell as well, instead of simply making function into value. Is this possible? Thanks in advance!

    Read the article

  • Ruby on Rails - can't access datetime model object

    - by NomadicRiley
    I've created a model that has 3 string columns and a datetime. Everything is running in SQLite3 and I can view the records in my table just fine using Lita. I'm trying to display the values in a page (index action) using code like this: <% @details.each do |lifeCycle| % <%= debug(lifeCycle)% <%= lifeCycle.lifeCycleId % <%= lifeCycle.eventType % <%= debug(lifeCycle.timeId) % <% end % From the debug I get a result like this: --- !ruby/object:LifeCycle attributes: eventType: Order created_at: "2111359287.23037" timeId: "2455364.89983796" eventId: "98765" updated_at: "2111359287.23037" lifeCycleId: "12345" id: "1" attributes_cache: {} But whenever I try to access the event timeId - i' getting a nil value. This is true if i try to run debug on just that field debug(lifeCycle.timeId), or call a function on it. Is there something obvious I'm missing here?

    Read the article

  • SQL Server - how to determine if indexes aren't being used?

    - by rwmnau
    I have a high-demand transactional database that I think is over-indexed. Originally, it didn't have any indexes at all, so adding some for common processes made a huge difference. However, over time, we've created indexes to speed up individual queries, and some of the most popular tables have 10-15 different indexes on them, and in some cases, the indexes are only slightly different from each other, or are the same columns in a different order. Is there a straightforward way to watch database activity and tell if any indexes are not hit anymore, or what their usage percentage is? I'm concerned that indexes were created to speed up either a single daily/weekly query, or even a query that's not being run anymore, but the index still has to be kept up to date every time the data changes. In the case of the high-traffic tables, that's a dozen times/second, and I want to eliminate indexes that are weighing down data updates while providing only marginal improvement.

    Read the article

  • SQL Check Constraint cannot reference other column

    - by user1777711
    I trying to add this sql check in ALTER TABLE School add Role check_role CHECK (check_role IN ('Teaching Assistant', 'Lecturer', 'Professor')); I get the error below ERROR at line 3: ORA-02438: Column check constraint cannot reference other columns SQL> desc School; Name Null? Type ----------------------------------------- -------- ---------------------------- STAFFNUM NOT NULL VARCHAR2(12) NAME NOT NULL VARCHAR2(50) ADDRESS NOT NULL VARCHAR2(300) DOB DATE I am trying add a column call Role, with the check constraint check_role I am using Oracle SQL. Thanks for all help!

    Read the article

  • SQL Server FTS: possible to get information how/why rows were matched?

    - by jimmy_keen
    Is it possible to get the information why/how given row returned by FTS query was matched (or which substring caused row to match)? For example, consider simpliest table with id and text columns, with FTS index on the later one. SELECT * FROM Example WHERE CONTAINS(text, 'FORMSOF(INFLECTIONAL, jump)'); This examplary query could return, say row {1, 'Jumping Jack'}. Now, is it possible to somehow get information that this very row was matched because of 'Jumping' word? It doesn't even have to be exact information, more of a which substring caused row to match. Why I'm asking - I got C# app that builds up those queries basing on user input (keywords to search for), and I need the very basic information why/how row was matched back, to use further in C# code. If it's not possible, any alternatives?

    Read the article

  • Query does not subtract correctly

    - by Chris
    I have these two tables: SQL> SELECT * FROM TAB_A; MYDATE P4 D1 D2 P5 P6 --------- ---------- ---------- ----------- ----------- ----------- 30-OCT-12 949,324 4,437,654 10,203,116 25,303,632 13,900,078 SQL> SELECT * FROM TAB_B; MYDATE P4 D1 D2 P5 P6 --------- ---------- ---------- ----------- ----------- ----------- 30-OCT-12 937,796 4,388,477 10,091,811 25,028,402 13,755,882 I need to subtract their respective columns and store the results into a third table like so: SQL> INSERT INTO TAB_C (MYDATE, P4) SELECT SYSDATE,A.P4-B.P4 FROM TAB_A A,TAB_B B WHERE A.MYDATE=B.MYDATE; SQL> SELECT * FROM TAB_C; MYDATE P4 D1 D2 P5 P6 --------- ---------- ---------- ----------- ----------- ----------- 30-OCT-12 926,268 The result is wrong. Basic math: 949324-937796=11528. Numeric values are stored as number datatypes. What am I missing here?

    Read the article

  • Very basic database theory.

    - by John R
    I have a set of tables to show the relationship between organziations and supporters below. Although I have done some basic mySQL querries, I know very little about database 'design'. I plan to querry the database for: -a list of contributors to a specific organization... or, -a list of organizations that a specific suporter supports. The database tables for organiations and contributors may have other columns in the future and recieve a lesser amount of querries based on that information. A | X A | Y A | Z B | X B | Y C | X C | Z How should the tables be set up? I assume that there should be a third table, but there is still redundent information in the third table. Is there a better way of setting up the tables? +----+-------+ +-------------+----------+ +----+-------+ | id | org | | org | contr | | id | contr.| +----+-------+ +-------------+----------+ +----+-------+ | 1 | A | | 1 | 1 | | 1 | X | | 2 | B | | 1 | 2 | | 2 | Y | | 3 | C | | 1 | 3 | | 3 | Z | +----+-------+ | 2 | 1 | +----+-------+ | 2 | 2 | | 3 | 1 | | 3 | 3 | +-------------+----------+

    Read the article

< Previous Page | 217 218 219 220 221 222 223 224 225 226 227 228  | Next Page >