statement

problem Keyword token antlr

If the 'for' is used both as a command and as "the English word": for_statement: 'for' ... id: 'for' | ID ; ID: ... right? My problem is how to differentiate the two cases. For example for_statement is only possible beginning of a line (only if preceded by ' ' or '\t'). For example: echo for print example for i in {0..10..2} ...

Is it possible a trigger on a select statement with MySQL?

Hi. I know that triggers can be used on insert, update and delete, but what about a trigger (or sort of) on a select statement. I want to use a trigger to insert data on a table B when it is selected an existent record on a table A, it could be possible?. Thanks in advance. ...

Is it safe to use connection.createStatement().executeQuery(String query);?

Is it safe to do connection.createStatement().executeQuery(String query);, or should each java.sql.Statement object be created and closed by "hand" on every use, even if the connection is closed in a finally block? If multiple queries are executed in one method by one connection it would use much less code if instantiating and closing e...

C++ assignment - stylish or performance?

Having been writing Java code for many years, I was amazed when I saw this C++ statement: int a,b; int c = (a=1, b=a+2, b*3); My question is: Is this a choice of coding style, or does it have a real benefit? (I am looking for a practicle use case) I think the compiler will see it the same as the following: int a=1, b=a+2; int c = b*...

Is this a valid jquery conditional statement?

if (tag == 'td' && $(this).hasClass('status')) { // I am clearing everything inside the td with class status $(this).html('') } But it doesn't seem to clear... Any suggestion... I am customizing a form plugin, $.fn.clearForm = function() { return this.each(function() { var type = this.type, tag = this...

sql select statement based on distinct column values....

select distinct * from Drivers where IsDeleted=0 gives me this, I want select * based on distinct DriverMobNo column ...

Why won't this sql update query work?

I have a table that has 5,000(table1) lines in it. Currently, 3,000 of them are filled up with data. The remaining values are currently null. In a separate table(table2), I have the remaining 2,000 rows of data. I am simply trying to take the values in table2 and put them in table1, but this statement isn't working: Update table1 Set ...

Prepared Statements in MySql 5.1

This one is really puzzling. I can't seem to be able to run any prepared statement on MySql 5.1. Any simple select I'm writing runs fine but when I'm trying to run it from a prepared statement I'm getting Query returned no result set. What Am I doing wrong? Exmaple: prepare s from 'select * from t'; execute s; Thanks! ...

Which of these queries is more efficient?

Which of these queries are more efficient? select 1 as newAndClosed from sysibm.sysdummy1 where exists ( select 1 from items where new = 1 ) and not exists ( select 1 from status where open = 1 ) select 1 as newAndClosed ...

postgres syntax question for OR?

The first one below works, but, just wanted to see if there's a better way... If I'm trying to find all records that start with 'C' with either a flag of 2 or a status of 9, do I need to incorporate the 'C' criteria twice? i.e., "SELECT * FROM mytable WHERE name like 'C%' AND flag = 2 OR name like 'C%' AND status = 9" Or, is ther...

select from rental table in mysql to display items currently rented by user

If you know about sakila sample database, then what is the statement to select items currently rented by a user. If not here is a code explanation: CREATE TABLE IF NOT EXISTS `rentals` ( `item_id` int(10) unsigned NOT NULL, `user_id` int(10) unsigned NOT NULL, `last_change_date` date NOT NULL, PRIMARY KEY (`item_id`,`user_id`,`la...

Why is there excessive use of whitespaces in expressions in most sample code?

A statement that could be written as: foo=(bar*5)+baz; is usually written in sample code (documentation, tutorials etc) as: foo = ( bar * 5 ) + baz; This appears to require extra work and seems counter-productive to me. Is there a rational reason for this? Is this a good coding practice, or just for sample code? (The reason I ask ...

create database on sqlite3 (foreign key issues)

Hi everyone I have 3 tables: CREATE TABLE Destination (DestinationID INTEGER NOT NULL PRIMARY KEY, Destination TEXT NOT NULL, NoGoing INTEGER NOT NULL); CREATE TABLE User (UserID INTEGER NOT NULL PRIMARY KEY, UserName TEXT NOT NULL); CREATE TABLE Query (UserID INT...

How to select first entry of the day grouped by user in SQL

I've looked around and can't quite grasp the whole answer to this SQL query question needed to extract data from an MS Access 2000 table. Here's an example of what the table [Time Sub] looks like: **CLIENT_ID, DATE_ENTERED, CODE, MINUTES** 11111, 5/12/2008 3:50:52 PM, M, 38 11111, 5/12/2008 2:55:50 PM, M, 2 11714, 5/13/2008 1:15:...

how to write sqlite update operation in two tables?

I am using SQLite, TABLE A ( ID FileNAME FOLDERID ) TABLE B ( FOLDERID FOLDERPATH ) I want to write a sql statement to delete all files in A where its Folder is subfolder of C:\ABC\; How Can I make it in one sqlite statement, and is it the best way to do? Many thanks! ...

MYSQL if a select query returns 0 rows then another select query?

if (select * from table where x=1) returns 0 rows then i need (select * from table where x=2 [or some other query]). is it possible to do this in a single MYSQL query with a conditional statement? edit: all answers with 'UNION' work but only if both queries selects from the same table (or tables with the same number of columns). What if...

Convert/Format a column in a select statement sql server 2005..

I have a sql query which is select DateOfBirth from people and it shows up in the result pane as DateOfBirth 07/07/2010 5:08:02 07/09/2010 5:08:02 07/13/2010 5:08:02 I want to format, 07/Jul/2010 09/Jul/2010 13/Jul/2010 NOTE: DateOfBirth column has datatype nvarchar(50) not datetime... ...

In php, how similar to an array can I make an object act? And how would I do that?

I know that by implementing iterable you can make an object able to be foreached over. I'd like to take it further and make an object react like an array would in as many places as possible where an array is called for. (The reason for this is because I'm selecting data from a database, and the statement object that results by default ...

a short statement that consumes lots of CPU cycles

I'm seeking a(very) short statement(in any language) that can make the CPU busy for like a second or a half. The statement should consume CPU cycles, not IO stuff. ...

How can access formulas as I process it with Matlab?

I load an xls file in Matlab, and I need not only the numeric values but the formulas also. Do you have any idea? ...