I tried this but only got a syntax error:
<?php
$a = true;
$str = <<< EOF
{$a ? 1 : 2}
EOF;
echo $str;
Is it possible to use such kind of conditional statement inside heredoc?
Can we use Replace function in a update statement ?
If yes then How?
I have a column 'enrollno' having values like '800-00001' to '800-01800'.
I want to replace inital '800-' to '800' in all 1800 records.
(Output should be '8000001' to '80001800')
Is it possible through replace function or any other option is there in ORACLE8i ?
MaheshA...
Lets assume my database table structure is something like
| items | weight |
|============|==========|
| item_1 | 50 |
| item_2 | 90 |
| item_2 | 45 |
| item_2 | 60 |
| item_3 | 40 |
In the select statement, I want to show an item only for once with the highest weight also ordered by height. So the result should be :
| items | weight |
|============|==========|
| item_2 | 90 |
| item_1 | 50 |
| item_3 | 40 |
I tried something like
SELECT DISTINCT items, weight FROM mytable ORDER BY weight DESC
but it didn't work because the results are actually distinct.
How can I make that selection?
I am trying to figure out how to create an 'if' statement that uses a time value as a condition. For example:
if (time <= 10:00) {
score = 3;
} elseif (time <= 20:00) {
score = 5;
} else {
score = 9;
}
I know that a string of "5:23" cannot be compared this way but I don't think I can just turn a string value like that directly into an integer. Any thoughts?
What is the difference between JOIN, Inner Join, Left Join and Outer Join.
Let me put you on what i know.
JOIN Statement is used to join two tables and fetch the result.
I tried to put an ifstatement inside an echo but this parse error came up, is it not possible to do that? should I use heredoc instead?
echo "<input name='main_branch' type='radio' value='1' <?php if($restaurant['main_branch'] == 1) { echo "checked"; } ?> />Yes
<input name='main_branch' type='radio' value='0' <?php if($restaurant['main_branch'] == 0) { echo " checked"; } ?> />No";
This is a statement referring to problem caused by page fault:(from Silberschatz 7th ed P-310 last para)
'We cant simply restart instructions when instruction modifies several different location
Ex:when a instruction moves 256 bytes from source to dest and either src or dest straddles on page boundary , then,after a partial move, if a page fault occurs, 'we can't simply restart the instructions'
My question is Why not?
Simply restart the instruction again do the same copy after page is in.
Is there any problem in it?
when I input
mysql -u root -p XXXX dbname < c:/filename.sql
alway get this error "error 1064 <42000:" you have an error in your SQL suntax; check the manual that corresponds to your MySql server version for the right syntax to use near .....
what is wrong with this statement?
An insert statement with a large number of values returns 'Error converting data type varchar to numeric.'
How can I find which value actually triggers the error?
MS SQL Server 2008 is used.
As I am a MySQL newbie. What does PARTITION mean in this MySQL statement?
CREATE TABLE employees (
id INT NOT NULL,
fname VARCHAR(30),
lname VARCHAR(30),
hired DATE NOT NULL DEFAULT '1970-01-01',
separated DATE NOT NULL DEFAULT '9999-12-31',
job_code INT NOT NULL,
store_id INT NOT NULL
)
PARTITION BY RANGE (store_id) (
PARTITION p0 VALUES LESS THAN (6),
PARTITION p1 VALUES LESS THAN (11),
PARTITION p2 VALUES LESS THAN (16),
PARTITION p3 VALUES LESS THAN (21)
);
Experienced Java programmer trying to learn Python. I have an applicaiton on Google App Engine and want to move my admin Handlers to a separate file. So now I have main.py and admin.py. I've set up app.yaml to route traffic properly, and have added the call to WSGIApplication() in each file to route to the appropriate Handler.
My question is does each script file need def main() and the corresponding if statement:
application = webapp.WSGIApplication([(r'/admin/(.*)', Admin)],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == '__main__':
main()
Class.forName("org.sqlite.JDBC");
Connection conn =
DriverManager.getConnection("jdbc:sqlite:userdata.db");
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery("SELECT * from table WHERE is_query_processed = 0;");
How can I find out if rs is empty?
Assume I have the following:
unsigned int *start;
unsigned int total;
#define OFF_MASK (1 << 31)
#define ON_MASK (~(1 << 31))
if (!(*start & OFF_MASK) && ((*start & ON_MASK) >= total)))
How do I change the above ifstatement so that it makes just one comparison like this:
if (*start >= total)
I'm in the process of creating an SSIS package on a server (server1) that looks at the data in a sql db on another site (server2) and copies relevant rows across.
The SQL statement required is:
SELECT *
FROM server2.ordersTable
WHERE
OrderID Not In (SELECT OrderID FROM server1.ordersTable
This selects data from server1 which isn't in the table on server2 (based on order id)
I then need to insert the result into a table on server1
How would I approach this? What components do I need etc...?
What was the most stupid code mistake you have ever made that had great consequences, e.g. you were fired?
For example, a friend of mine wrote a cycle with conditional statement for break that was never true, which caused one high-loaded site to hang up for the whole night.
In C# I could easily write the following:
string stringValue = string.IsNullOrEmpty( otherString ) ? defaultString : otherString;
Is there a quick way of doing the same thing in Python or am I stuck with an 'if' statement?
For example I have:
create table a (i int);
Assume there are 10k rows.
I want to count 0's in the last 20 rows.
Something like:
select count(*) from (select i from a limit 20) where i = 0;
Is that possible to make it more efficient? Like a single SQL statement or something?
PS. DB is SQLite3 if that matters at all...
The UPSERT operation either updates or inserts a row in a table, depending if the table already has a row that matches the data:
if table t has a row exists that has key X:
update t set mystuff... where mykey=X
else
insert into t mystuff...
Since Oracle doesn't have a specific UPSERT statement, what's the best way to do this?
Python needs a framework, so does Java (for the web). I don't know much about Ruby or Coldfusion. But is there another language out there for the web that can stand alone as it is without a need for a framework or without strict adherence to a design pattern (MVC and the likes) aside from PHP? BTW, the statement that Python and Java needs a framework to work with the web came purely from my readings on articles and books; I might be mistaken.
The following procedure gives me an error when I invoke it using the CALL statement:
CREATE DEFINER=`user`@`localhost` PROCEDURE `emp_performance`(id VARCHAR(10))
BEGIN
DROP TABLE IF EXISTS performance;
CREATE TABLE performance AS
SELECT time_in, time_out, day FROM attendance WHERE employee_id = id;
END
The error says "Unknown table 'performance' ".
This is my first time actually using stored procedures and I got my sources from Google. I just cant figure out what I am doing wrong.
I have a primary key auto increment attribute in my table. I want to know the value assigned to it for a row that is inserted using statement.executeQuery(). How to achieve this in the best possible manner?
When i run a mysql select statement, it takes very long because i have already previously deleted a very large number of rows.
Is there a way for the table to start scanning from the bottom, as opposed to from the top?
Example:
switch( x )
{
case y:
if ( true )
{
break;
}
cout << "Oops";
break;
}
If the switch statement selects y, will Oops be written to the standard output?
- Is break in switch statements a dynamic keyword like continue which can be called under conditions or static like a closing bracket }?
I have the a simple LinqToSQL statement that is not working. Something Like this:
List<MyClass> myList = _ctx.DBList
.Where(x => x.AGuidID == paramID)
.Where(x => x.BBoolVal == false)
.ToList();
I look at _ctx.DBList in the debugger and the second item fits both parameters.
Is there a way I can dig into this more to see what is going wrong?