Search Results

Search found 12215 results on 489 pages for 'identity column'.

Page 61/489 | < Previous Page | 57 58 59 60 61 62 63 64 65 66 67 68  | Next Page >

  • How to use SQL trigger to record the affected column's row number

    - by Freeman
    I want to have an 'updateinfo' table in order to record every update/insert/delete operations on another table. In oracle I've written this: CREATE TABLE updateinfo ( rnumber NUMBER(10), tablename VARCHAR2(100 BYTE), action VARCHAR2(100 BYTE), UPDATE_DATE date ) DROP TRIGGER TRI_TABLE; CREATE OR REPLACE TRIGGER TRI_TABLE AFTER DELETE OR INSERT OR UPDATE ON demo REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW BEGIN if inserting then insert into updateinfo(rnumber,tablename,action,update_date ) values(rownum,'demo', 'insert',sysdate); elsif updating then insert into updateinfo(rnumber,tablename,action,update_date ) values(rownum,'demo', 'update',sysdate); elsif deleting then insert into updateinfo(rnumber,tablename,action,update_date ) values(rownum,'demo', 'delete',sysdate); end if; -- EXCEPTION -- WHEN OTHERS THEN -- Consider logging the error and then re-raise -- RAISE; END TRI_TABLE; but when checking updateinfo, all rnumber column is zero. is there anyway to retrieve the correct row number?

    Read the article

  • Row/column counter in 'apply' functions

    - by mortalitysequence
    What if one wants to apply a functon i.e. to each row of a matrix, but also wants to use as an argument for this function the number of that row. As an example, suppose you wanted to get the n-th root of the numbers in each row of a matrix, where n is the row number. Is there another way (using apply only) than column-binding the row numbers to the initial matrix, like this? test <- data.frame(x=c(26,21,20),y=c(34,29,28)) t(apply(cbind(as.numeric(rownames(test)),test),1,function(x) x[2:3]^(1/x[1]))) P.S. Actually if test was really a matrix : test <- matrix(c(26,21,20,34,29,28),nrow=3) , rownames(test) doesn't help :( Thank you.

    Read the article

  • Swing: Multiple CellEditors for a column

    - by Luhar
    Hi, In my JTable, I have two editable numeric columns. The editor for both columns extends AbstractCellEditor and uses a JFormattedTextField as an the editing component. The problem is that the format for input depends on the value of another column in the row. If condition X is met, the number of fraction digits should be Y, otherwise they should be Y+2. I attempted to override the getTableCellEditor(..) method to associate a TableCellEditor per row. See this example. However, since I have two editable columns, sharing a single TableCellEditor object per row gives some very odd results. I don't think this is an appropriate solution. Any ideas on how to approach this would be much appreciated! Thank you!

    Read the article

  • Select one column from a row in hibernate

    - by ComfortablyNumb
    I am trying to do a simple query to get a unique result back in hibernate here is my code. public String getName(Integer id) { Session session = getSessionFactory().openSession(); String name = (String)session.createSQLQuery("SELECT name FROM users WHERE user_id = :userId").setParameter("userId", id).uniqueResult(); return name; } The name that is being returned is stored as HTML text that includes html syntacx language. I think this is what is causing the problem but it doesnt make sense I just want to return it as a string. It is only happening on this one field name, I can get every other field in the row but this one it gives me the error. I am getting an exception. The exception I am getting is No Dialect mapping for JDBC type: -1; nested exception is org.hibernate.HibernateException How do you query for a specific column on a row in hibernate?

    Read the article

  • Getting column info from db with C#

    - by lYriCAlsSH
    In PHP I am able to retrieve information from a db like so: <?php $sql = "SELECT * FROM users"; $result = mysql_query($sql); $data = array(); while($row = mysql_fetch_assoc($result)) { $data[] = $row; } I am trying to acomplish the same thing in C#: OdbcCommand cmd = new OdbcCommand("SELECT * FROM users WHERE id = @id"); cmd.Parameters.Add("@id", id); OdbcDataReader reader = cmd.ExecuteReader(); Dictionary<string, string> data = new Dictionary<string, string>(); while (reader.Read()) { data.Add("id", reader.GetString(0)); data.Add("username", reader.GetString(1)); data.Add("firstName", reader.GetString(2)); } return data; Is it possible to reference the column in the table by name without going through all this trouble?

    Read the article

  • T-SQL Add Column In Specific Order

    - by Aren B
    Im a bit new to T-SQL, Coming from a MySQL background Im still adapting to the different nuances in the syntax. Im looking to add a new column AFTER a specific one. I've found out that AFTER is a valid keyword but I don't think it's the right one for the job. ALTER TABLE [dbo].[InvStockStatus] ADD [Abbreviation] [nvarchar](32) DEFAULT '' NOT NULL ; This is my current query, which works well, except it adds the field at the end of the Table, Id prefer to add it after [Name]. What's the syntax im looking for to represent this?

    Read the article

  • Select only the first rows for each unique value of a column in R

    - by dmvianna
    From a dataframe like this test <- data.frame('id'= rep(1:5,2), 'string'= LETTERS[1:10]) test <- test[order(test$id), ] rownames(test) <- 1:10 > test id string 1 1 A 2 1 F 3 2 B 4 2 G 5 3 C 6 3 H 7 4 D 8 4 I 9 5 E 10 5 J I want to create a new one with the first appearance of each id / string pair. If sqldf accepted R code within it, the query could look like this: res <- sqldf("select id, min(rownames(test)), string from test group by id, string") > res id string 1 1 A 3 2 B 5 3 C 7 4 D 9 5 E Is there a solution short of creating a new column like test$row <- rownames(test) and running the same sqldf query with min(row)?

    Read the article

  • Passing a column name instead of index in sqlite3

    - by user271753
    The problem code: NSString *query = @"SELECT Name FROM Category"; sqlite3_stmt *statement; if (sqlite3_prepare_v2(database, [query UTF8String], -1, &statement, nil) == SQLITE_OK) { while (sqlite3_step(statement) == SQLITE_ROW) { char *row =(char *)sqlite3_column_text(statement,0); char *rowData = (char *)sqlite3_column_text(statement,1); NSString *fieldName = [[NSString alloc] initWithUTF8String:row]; NSString *fieldValue = [[NSString alloc] initWithUTF8String:rowData]; NSLog(@"%@",fieldName); NSLog(@"%@",fieldValue); [fieldName release]; [fieldValue release]; } sqlite3_finalize(statement); } char *row =(char *)sqlite3_column_text(statement,0); In the above code instead of 0 can't I just pass a column name? How can I do that ?

    Read the article

  • Casting a Calculated Column in a MySQL view.

    - by Chris Brent
    I have a view that contains a calculated column. Is there are a way to cast it as a CHAR or VARCHAR rather than a VARBINARY ? Obviously, I have tried using CAST(... as CHAR) but it gives an error. Here is a simple replicable example. CREATE VIEW view_example AS SELECT concat_ws('_', lpad(9, 3,'0'), lpad(1,3,'0'), date_format(now(),'%Y%m%d%H%i%S')) AS calculated_field_id; This is how my view is created: describe view_example; +---------------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------------+---------------+------+-----+---------+-------+ | calculated_field_id | varbinary(27) | YES | | NULL | | +---------------------+---------------+------+-----+---------+-------+ select version(); +-----------------------+ | version() | +-----------------------+ | 5.0.51a-community-log | +-----------------------+

    Read the article

  • Export a MYSQL column to a plain txt file with no headings

    - by Kohl Sharples
    So what I'm trying to do is write a script or CRON job (Linux- CentOS) to export the usernames listed in my wordpress database to a simple .txt file with just on username per line. So with the picture, I would like the .txt file to read like this: Sir_Fluffulus NunjaX007 (Except with all the username in the user_login column.) See screenshot at: http://i.stack.imgur.com/lZQai.png I have found how to export the entire table to a CVS file, but that contains about 10+ fields (Columns) that I DO NOT what to show up in this text file. Can anyone point me in the right direction on how to do this? If it helps, this is going to be for exporting users that have signed up on our website (Wordpress) to a whitelist.txt file for Minecraft. Thanks!

    Read the article

  • Get only Excel column names in C#

    - by Newbie
    Is there any easy way apart from ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+fileName+";Extended Properties='Excel 8.0;HDR=YES;IMEX=1'"; using (objConn = new OleDbConnection(ConnectionString)) { objConn.Open(); Logger.Info("Reading the file "+fileName+"...."); objCmdSelect = new OleDbCommand("SELECT * FROM [" + sheetName + "$] WHERE 0 = 1", objConn); objAdapter = new OleDbDataAdapter(); objAdapter.SelectCommand = objCmdSelect; objDataset = new DataSet(); Logger.Info("Filling the dataset...."); objAdapter.Fill(objDataset, fileName); Logger.Info("Returning the dataset...."); return objDataset; } and then looping the datatables for getting the excel column names given a filename and sheet name? Using C#(and no interop services) Thanks

    Read the article

  • Replacing emty csv column values with a zero

    - by homerjay
    Hey, So I'm dealing with a csv file that has missing values. What I want my script to is: #!/usr/bin/python import csv import sys #1. Place each record of a file in a list. #2. Iterate thru each element of the list and get its length. #3. If the length is less than one replace with value x. reader = csv.reader(open(sys.argv[1], "rb")) for row in reader: for x in row[:]: if len(x)< 1: x = 0 print x print row Here is an example of data, I trying it on, ideally it should work on any column lenghth Before: actnum,col2,col4 xxxxx , , xxxxx , 845 , xxxxx , ,545 After actnum,col2,col4 xxxxx , 0 , 0 xxxxx , 845, 0 xxxxx , 0 ,545 Any guidance would be appreciated

    Read the article

  • Select rows where column LIKE dictionary word

    - by Gerve
    I have 2 tables: Dictionary - Contains roughly 36,000 words CREATE TABLE IF NOT EXISTS `dictionary` ( `word` varchar(255) NOT NULL, PRIMARY KEY (`word`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; Datas - Contains roughly 100,000 rows CREATE TABLE IF NOT EXISTS `datas` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `hash` varchar(32) NOT NULL, `data` varchar(255) NOT NULL, `length` int(11) NOT NULL, `time` int(11) NOT NULL, PRIMARY KEY (`ID`), UNIQUE KEY `hash` (`hash`), KEY `data` (`data`), KEY `length` (`length`), KEY `time` (`time`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=105316 ; I would like to somehow select all the rows from datas where the column data contains 1 or more words. I understand this is a big ask, it would need to match all of these rows together in every combination possible, so it needs the best optimization. I have tried the below query, but it just hangs for ages: SELECT `datas`.*, `dictionary`.`word` FROM `datas`, `dictionary` WHERE `datas`.`data` LIKE CONCAT('%', `dictionary`.`word`, '%') AND LENGTH(`dictionary`.`word`) > 3 ORDER BY `length` ASC LIMIT 15 I have also tried something similar to the above with a left join, and on clause that specified the like statement.

    Read the article

  • SQL query help - merge a value to all rows in a column

    - by Tommy
    I'm trying to migrate a site from a joomla system to a drupal. The problem is that drupal needs filename and sourcepath in the same row, but joomla only has filename. I'm looking for a way to add sourcepath before the filename in all the rows in that column. I'm figuring it's the UPDATE statement that I should use, but I can't figure out how to construct the query. There's a person with a similar problem here, but I don't find the answers in that thread helpful to my problem: http://www.daniweb.com/forums/showth...t+value&page=2 Any suggestions?

    Read the article

  • Stop Entity Framework from updating edmx model with a column that isn't needed

    - by TMan
    I have rowguids in all my tables to help with change tracking in all my tables. I don't want/need these tables in my edmx or my entities. However, I do still need to make changes to other things sometimes so everytime i go to update model from database in the edmx it adds all the rowguids in all my tables everytime and i have to manually delete each one. Is there a way to handle this from happening? Is there a way I can maybe edit the T4 to maybe ignore that 'rowguid' column? Database first Entity framework

    Read the article

  • Generating incremental numeric column values during INSERT SELECT statement

    - by Charles
    I need to copy some data from one table to another in Oracle, while generating incremental values for a numeric column in the new table. This is a once-only exercise with a trivial number of rows (100). I have an adequate solution to this problem but I'm curious to know if there is a more elegant way. I'm doing it with a temporary sequence, like so: CREATE SEQUENCE temp_seq START WITH 1; INSERT INTO new_table (new_col, copied_col1, copied_col2) SELECT temp_seq.NEXTVAL, o.* FROM (SELECT old_col1, old_col2 FROM old_table) o; DROP SEQUENCE temp_seq; Is there way to do with without creating the sequence or any other temporary object? Specifically, can this be done with a self-contained INSERT SELECT statement? There are similar questions, but I believe the specifics of my question are original to SO.

    Read the article

  • Multiple column Union Query without duplicates

    - by Adam Halegua
    I'm trying to write a Union Query with multiple columns from two different talbes (duh), but for some reason the second column of the second Select statement isn't showing up in the output. I don't know if that painted the picture properly but here is my code: Select empno, job From EMP Where job = 'MANAGER' Union Select empno, empstate From EMPADDRESS Where empstate = 'NY' Order By empno The output looks like: EMPNO JOB 4600 NY 5300 MANAGER 5300 NY 7566 MANAGER 7698 MANAGER 7782 MANAGER 7782 NY 7934 NY 9873 NY Instead of 5300 and 7782 appearing twice, I thought empstate would appear next to job in the output. For all other empno's I thought the values in the fields would be (null). Am I not understanding Unions correctly, or is this how they are supposed to work? Thanks for any help in advance.

    Read the article

  • Why is Hibernate not loading a column?

    - by B.R.
    I've got an entity with a few properties that gets used a lot in my Hibernate/GWT app. For the most part, everything works fine, but Hibernate refuses to load one of the properties. It doesn't appear in the query, despite being annotated correctly in the entity. The relevant portion of the entity: @Column(name="HasSubSlots") @Type(type="yes_no") public boolean hasSubSlotSupport() { return hasSubSlotSupport; } And the generated SQL query: Hibernate: /* load entities.DeviceModel */ select devicemode0_.DevModel as DevModel1_0_, devicemode0_.InvModelName as InvModel2_1_0_ from DeviceModels devicemode0_ where devicemode0_.DevModel=? Despite the fact that I refer to that property, it's never loaded, lazily or not, and the getter always returns false. Any ideas on how I can dig deeper into this, or what might be wrong?

    Read the article

  • Sorting results by a char(1) column

    - by Brandon
    I have a stored procedure which basically does something like select top 1 expiryDate, flag, (bunch of other columns) from someTable (bunch of joins) order by expiryDate desc So this will grab the record that expires last. This works for most cases, except some records have a flag that are just a char(1). Most of the time it's just Y or N. So it'll return something like 2010-12-31 N 2010-10-05 Y 2010-08-05 N 2010-03-01 F 2010-01-31 N This works, most of the time, but is there any way to order it by the Flag column as well? So I'd want to group the results by Y, then N, and F and any other flags can go last in any order. I thought this would just be an order by, but since the flags are not weighted by the alphabetic value, I'm a little stumped. (Note: These are not my tables, I don't know if using the characters like this was a good idea or not, but it's not something I can change).

    Read the article

  • Getting changes in one column of an historical table

    - by Javi
    Hello, I have a table which stores historical data. It's mapped to an Entity with the following fields (I use JPA with Hibernate implementation): @Entity @Table(name="items_historical") public class ItemHistory{ private Integer id; private Date date; @Enumerated(EnumType.ORDINAL) private StatusEnum status @ManyToOne(optional=false) private User user; @ManyToOne(optional=false) private Item item; } public enum StatusEnum { OK, BAD,...//my status } In every row I store historical data of another table. I need to get the list of the changes on "status" column: the status, the date and the previous status on a specified item (It would be good as well getting the status and date when status was changed). I don't know if this is possible by using HQL. Thanks.

    Read the article

  • Possible to exclude a column from `*` ?

    - by Earlz
    Is it possible to exclude a column from a select * from table statement with SQL Server? I have a need for this and this is my only option other than parsing a raw SQL string to get out the required field names (I really don't want to do that). Just to be bold. When the query is made I do not have access to the list of fields needed from the table but I do know which field I do not need. This is part of a complex multi-part query. Surely there must be some way even if it's "hackish" such as using table variables or views

    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

  • Strange SQL problem selecting multiple values for same column

    - by Nubber
    Hello there, Been at this for a few hours now and I can't make any sense of it. I've used this way of selecting multiple values for same column a few times, but there is something weird with this one. SELECT * FROM employee as s INNER JOIN works AS w1 ON w1.name = s.name INNER JOIN employee AS w2 ON w2.name = s.name INNER JOIN employee AS w3 ON w3.name = s.name WHERE w2.city = 'Washington' Basically what I want to do is find all companies which have people in all the cities. The company name is under 'works'. The problem is however that if I have the WHERE w2.city='Washington' it will make ALL the cities match Washington when it should only touch w2 and leave w3 alone so I could match it with another value. Anyone know why its doing this? Or know a better way to do it. Thank you very much in advance.

    Read the article

  • Inserting empty string into auto_increment column in MySQL 5

    - by QmunkE
    Hi, I've inherited a project which we are trying to migrate to MySQL 5 from MySQL 4.0(!) and from myISAM to InnoDB. Queries are now falling down because they are being constructed using an ADODB connection's -qstr() on all parameters, including ints. Where no value is provided I end up with: INSERT INTO tablename VALUES ('', 'stuff'...) where the first column is an auto_increment. This causes an error (fair enough since '' isn't an int). Is there a switch in MySQL to make it behave as it used to (I assume it just silently converted to 0?) Thanks.

    Read the article

  • creating a 2 column table dynamically using jquery

    - by user1908568
    I am trying to generate a table dynamically using ajax call. To simplify things i have just added my code to js fiddle here - http://jsfiddle.net/5yLrE/81/ As you click on the button "HI" first two columns are created properly.. but some how as the td length reaches 2 . its not creating another row. The reason is that when i do find on the table elements its actually retrieving the children table elements. Can some one pls help. I want a two column table.. Thank you. sample code: var tr = $("#maintable tbody tr:first"); if(!tr.length || tr.find("td:first").length >= max) { $("#maintable").append("<tr>"); } if(count==0) { $("#maintable tr:last").append("<td>hi"+content+"</td>"); }

    Read the article

< Previous Page | 57 58 59 60 61 62 63 64 65 66 67 68  | Next Page >