select

Select data, setting a calculated value into a column

Hello all, I'm selecting data from a table within a trigger (FOR UPDATE). Some rows I'm selecting have been updated by a transaction, that initiated the trigger, and some rows are not. I'd like to write somewhere in the dataset a flag for every row, which value would be calculated as "id IN (SELECT [id] FROM INSERTED)". This flag would ...

SQL Query - SELECT all rows except where value in column begins with 402 or 403 or A40

I have a (MS) SQL VIEW with no control over and it also queries several other SQL VIEWs that I also have no control over but must use. Get all rows based on "pilot" value except where it starts with 402 or 403, or A40. This is the current query that works fine as long as all "pilot" entries are possible to interpret as INT. SELECT * fr...

How to check if anything was inserted with INSERT SELECT (T-SQL)

I have an insert statement: insert into parentTbl select firstId, secondId, thirdId, dateTm from importTbl where codeId = @codeIdParam I need to reliably find out if that insert inserted anything at all. Ideally, I would like to set a @insertedCount variable to the number of rows inserted, even if that is 0. I am currently using: s...

Oracle: Selecting all records where the table's date fields' hour and minute value are set to certain value

I have a table in a Oracle database containing a date field EXPIRYDATE. I would need to select all records from the table, where the hour and minute portion of the date field are set to 0 (i.e. midnight). How can I achieve this? I tried with the extract function (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions0...

Modify gridview update action to put time in column?

I have a gridview with 3 columns, only one column is going to be edited by the user. Whenever it is edited I'd like to set one of the other columns to the current time. A "time last updated" if you will. Possible? ...

Select behavior

It could probably be a simple question but I couldn't find a clear answer for it. I have multiple threads in c code and one of them uses select to wait for n seconds. The question that I have is that does it blocks the entire process for n seconds (like usleep) or does select blocks only the calling thread (more like nanosleep). Thanks f...

SIGALRM Timeout -- How does it affect existing operations?

I am currently using select() to act as a timer. I have network receive operations which occur within a loop, and every few seconds a processing operation needs to occur. As a result, the select() statement's timeout constantly changes -- decreasing to zero over time and then restarting at 3. rv = select(selectmonitor+1, &readnet, NULL...

Rails 2 options_for_select with an ActiveRecord resultset

Does anyone know a better way of displaying the contents of an activerecord result set as a select box. I would like todo this @users = User.all <%= f.select_box :users, options_for_select(@users) %> But for now I need to parse all the users into a multidimensional array with a sub array [username,user_id] Any ideas? ...

collection_select doesn't let ActiveRecord update its collection when none of options is selected.

I have has_and_belongs_to_many association between two models. I made use of collection_select to represent the other model in this association in a form. When I tried to deselect options in collection_select, collection_select doesn't post its empty value and, thus, it doesn't let ActiveRecord pass any update clause to the database. ...

jQuery - Several select menu options make a field show/hide

Hello, I tried looking for posts like this one but although many are similar, none address my problem properly. Here's my situation: I have two select menus, Country and State, one of top of the other. Their default values are "-Select-". If the user selects another country different than United States or Canada, the State select men...

Why does dynamically populating a select drop down list element using javascript not work in IE?

I have a <select> element that I dynamically populate with different values at runtime. I use the code below to clear the <option> elements and then reload it with new ones. It works in Firefox 3.6.6 and Chrome 5.0. function loadPickerFromObject(pickerControl, values) { pickerControl.empty(); for (var nameProperty in values) { ...

SQL Server - Setting Multiple Values in a Case Statement?

Hi, I have a SQL Select statement where I need to return certain values depending on a condition. I need to return multiple values each time, but my understanding of the Case statement is that you can only return a single value for each case. I'm getting around this by using UNION statements at the moment, but it all looks a bit cum...

Stored procedure SQL SELECT statement issue

Hello everyone, I am using SQL Server 2008 Enterprise on Windows Server 2008 Enterprise. In a stored procedure, we can execute a SELECT statement directly. And it could also be executed in this new way, I am wondering which method is better, and why? New method, declare @teststatement varchar(500) set @teststatement = 'SELECT * from ...

sql where clause in select statement issue

Hello everyone, I am using SQL Server 2008 Enterprise with Windows Server 2008 Enterprise. I have a database table called "Book", which has many columns and three columns are important in this question, they are Author, varchar; Country, varchar; Domain, varchar. I want to write a store procedure with the following logics, but I do ...

Having selected values in a multi select in IE

Hello I have a multiselect box, whose answers would be available already. Now when a page loads, this select multiple control would load with options, and I have to compare all the options to this answer/answers and display them as selected. It is working fine in FF but not in IE. var op = newSelectorElm.options; if(op) for(v...

Getting inserted ID after INSERT ... SELECT on Oracle

This SQL statement works if I run it from my Oracle client (SQL Developer): insert into Person (Name) select 'Bob' from dual It also works if I issue it via Spring JDBC, without using a KeyHolder: final PreparedStatementCreator psc = new PreparedStatementCreator() { @Override public PreparedStatement createPreparedStatement(...

why does a dropdown combobox list (select html tag) disappear very quickly in IE 7 but works fine in firefox

i have a combobox and its on a narrow part of a webpage. below is my dropdown html. THe issue is that in IE 7 only (works fine in firefox) after i click on the dropdown, the list of items pops up and i go to click on an item in the list and it disappears before i get a chance to click. It seems to work fine in IE8 as well but in IE7 ...

Merging two rows to one while replacing null values

Hi. Let's say I've got the following database table Name | Nickname | ID ---------------------- Joe Joey 14 Joe null 14 Now I want to do a select statement that merges these two columns to one while replacing the null values. The result should look like this: Joe, Joey, 14 Which sql statement manages this (if it'...

count query filter

I want to filter counted query result. select count(distinct tmr_id) AS Count ,CONTRACTID from status_handling This query return 2 columns like: Count ContractID 1 23344 2 28344 2 34343 2 29344 1 26344 I just filter 2 (Count) values. How can I do this? Thanks. ...

How to only SELECT part of column value by REGEXP with MySQL ?

Hi, I have a column with values like "A001", "B002" AND "003", "004". I would like have this result : SELECT column from myTable +--------+ | column | +--------+ | 001 | | 002 | | 003 | | 004 | +--------+ Is this possible ? ...