how to store a value returned from a sql query in a variable in batch programming ?
i can invoke sqlserver queries from my cmd prompt using sqlcmd server name then the qwery
this is query statement i m going to use
SELECT
CASE
WHEN DATEDIFF(minute, record_timestamp, GETDATE()) < 10 THEN 1
ELSE 0
END
how to store the value returned
i tried using set variablename but it save the statement rather than the return value ..
and if i save this in a variable what type of variable it will can i compare it with numeric values in if condition
I am facing a peculiar problem where i need to update a particular value in database to say 'Hellò'. When i run normal update statement the values are updated fine. But when i put it i a .sql script file and then run the update statement the last character gets replaced by a junk value. Can some one enlighten me on this and how oracle processes script files?
while using
USE mssqltips_tde;
CREATE DATABASE ENCRYPTION KEY with ALGORITHM = AES_256 ENCRYPTION BY SERVER CERTIFICATE TDECert
GO
getting error
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword
'KEY'. Msg 319, Level 15, State 1,
Line 3 Incorrect syntax near the
keyword 'with'. If this statement is a
common table expression or an
xmlnamespaces clause, the previous
statement must be terminated with a
semicolon.
please help in resolving the same as i need to implement Encryption on my DB
I noticed in Objective C that xcode automatically uses a strange position of braces:
if (statement) {
}
whereas I am used to using:
if (statement)
{
}
it just makes it easier to read. Is it a matter of preference or is a standard that should be followed when writing Objective C applications?
Hey there everyone,
I am quite new to C++, but have worked with C# for years, however it is not helping me here! :)
My problem: I have an Actor class which Ball and Peg both derive from on an objective-c iphone game I am working on. As I am testing for collision, I wish to set an instance of Ball and Peg appropriately depending on the actual runtime type of actorA or actorB. My code that tests this as follows:
// Actors that collided
Actor *actorA = (Actor*) bodyA->GetUserData();
Actor *actorB = (Actor*) bodyB->GetUserData();
Ball* ball;
Peg* peg;
if (static_cast<Ball*> (actorA)) { // true
ball = static_cast<Ball*> (actorA);
}
else if (static_cast<Ball*> (actorB)) {
ball = static_cast<Ball*> (actorB);
}
if (static_cast<Peg*> (actorA)) { // also true?!
peg = static_cast<Peg*> (actorA);
}
else if (static_cast<Peg*> (actorB)) {
peg = static_cast<Peg*> (actorB);
}
if (peg != NULL) {
[peg hitByBall];
}
Once ball and peg are set, I then proceed to run the hitByBall method (objective c).
Where my problem really lies is in the casting procedurel Ball casts fine from actorA; the first if (static_cast<>) statement steps in and sets the ball pointer appropriately.
The second step is to assign the appropriate type to peg. I know peg should be a Peg type and I previously know it will be actorB, however at runtime, detecting the types, I was surprised to find actually the third if (static_cast<>) statement stepped in and set this, this if statement was to check if actorA was a Peg, which we already know actorA is a Ball! Why would it have stepped here and not in the fourth if statement?
The only thing I can assume is how casting works differently from c# and that is it finds that actorA which is actually of type Ball derives from Actor and then it found when static_cast<Peg*> (actorA) is performed it found Peg derives from Actor too, so this is a valid test? This could all come down to how I have misunderstood the use of static_cast. How can I achieve what I need? :)
I'm really uneasy about what feels to me like a long winded brute-casting attempt here with a ton of ridiculous if statements. I'm sure there is a more elegant way to achieve a simple cast to Peg and cast to Ball dependent on actual type held in actorA and actorB.
Hope someone out there can help! :)
Thanks a lot.
char *sample = "String Value";
&sample is a pointer to the pointer of "String Value"
is the above statement right?
If the above statement right, what is the equivalent of &sample if my declaration is
char sample[] = "String Value"
messagecontroller is nothing but object of initialize nib file.
[self.navigationController pushViewController:messageController animated:YES];
this statement executes in normal condition
this statement also works on state maintainace testing ,
this line executes properly but not open new view ,why?
Is better to use the below statement
Convert.ToInt32("0" + stringValue)
If not then why?
I know that it is better to user int.TryParse() function, which is better, but what about the above statement.
I am including chapters in my latex file one by one by using the \include{} statement, up till now I've had no problem with that. But I've recently written a chapter which I've saved under a name including spaces...because you can.
Now the include{} statement apparently doesn't like spaces, and prints just the filename in my document in stead of the chapter.
It is probably a pretty easy fix (apart from removing the spaces in the filename, ;-) ), but I can't find it.
I use clientgen ant task shipped with weblogic to generate web-service clients. Currently I have one different clientgen statement for each wsdl. Is there any possibility do not iterate each wsdl? It will be perfect just set directory where all wsdl live for one clientget statement.
while using
USE mssqltips_tde;
CREATE DATABASE ENCRYPTION KEY with ALGORITHM = AES_256 ENCRYPTION BY SERVER CERTIFICATE TDECert
GO
getting error
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword
'KEY'. Msg 319, Level 15, State 1,
Line 3 Incorrect syntax near the
keyword 'with'. If this statement is a
common table expression or an
xmlnamespaces clause, the previous
statement must be terminated with a
semicolon.
please help in resolving the same as i need to implement Encryption on my DB
Hi,
How do you get a datetime column in sqlite objective-c ?
I have a table with 4 fields: pk, datetime, value1 and value 2. pk (primary key), value1 and value2 are integer so I am using:
int value1 = sqlite3_column_int(statement, 2);
int value1 = sqlite3_column_int(statement, 3);
But what should I used for datetime?
Thx
I am using c#.NET 2.0 to execute DOS commands to ftp a file. All works except for 1 thing, in the cmd file I call, it runs a PUT statement. Right now the put statement has a hardcoded local file path. I need to specify a dynamic path. I've tried
put %~dp0\myfile.DTL myfile.dtl
but it says it can't find the file.
Is it possible to get the duplicate count when executing MySQL "INSERT IGNORE" statement via JDBC?
For example, when I execute an INSERT IGNORE statement on the mysql command line, and there are duplicates I get something like
Query OK, 0 rows affected (0.02 sec)
Records: 1 Duplicates: 1 Warnings: 0
Note where it says "Duplicates: 1", indicating that there were duplicates that were ignored.
Is it possible to get the same information when executing the query via JDBC?
Thanks.
i have 2 tables in access
this is what i need:
1. if the PK from table1 exists in table2, then delete the entire record with that PK from table2 and add the entire record from table1 into table2
2. if the PK does not exist then add the record
i need help with both the sql statement and the VBA
i guess the VBA should be a loop, going through every record in table1. inside the loop i should have the select statement
Before i go any further it would be nice to know if there is any major design flaws in my program so far. Is there anything worth changing before i continue?
Model
package model;
import java.sql.*;
import java.util.*;
public class MovieDatabase {
@SuppressWarnings({ "rawtypes", "unchecked" })
public List queryMovies() throws SQLException {
Connection connection = null;
java.sql.Statement statement = null;
ResultSet rs = null;
List results = new ArrayList();
try {
DriverManager.registerDriver(new com.mysql.jdbc.Driver());
connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "password");
statement = connection.createStatement();
String query = "SELECT * FROM movie";
rs = statement.executeQuery(query);
while(rs.next()) {
MovieBean bean = new MovieBean();
bean.setMovieId(rs.getInt(1));
bean.setTitle(rs.getString(2));
bean.setYear(rs.getInt(3));
bean.setRating(rs.getInt(4));
results.add(bean);
}
} catch(SQLException e) {
}
return results;
}
}
Servlet
public class Service extends HttpServlet {
@SuppressWarnings("rawtypes")
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Movies!");
MovieDatabase movies = new MovieDatabase();
try {
List results = movies.queryMovies();
Iterator it = results.iterator();
while(it.hasNext()) {
MovieBean movie = new MovieBean();
movie = (MovieBean)it.next();
out.println(movie.getYear());
}
}
catch(SQLException e) {
}
}
}
Bean
package model;
@SuppressWarnings("serial")
public class MovieBean implements java.io.Serializable {
protected int movieid;
protected int rating;
protected int year;
protected String title;
public MovieBean() {
}
public void setMovieId(int movieidVal) {
movieid = movieidVal;
}
public void setRating(int ratingVal) {
rating = ratingVal;
}
public void setYear(int yearVal) {
year = yearVal;
}
public void setTitle(String titleVal) {
title = titleVal;
}
public int getMovieId() {
return movieid;
}
public int getRating() {
return rating;
}
public int getYear() {
return year;
}
public String getTitle() {
return title;
}
}
select @[email protected]('*')
for xml raw,type
Above statement will generate following alert:
Msg 6819, Level 16, State 3, Line 2
The FOR XML clause is not allowed in a ASSIGNMENT statement.
Good Morning,
Say I have an insert statement:
Insert INTO tblTest (fieldOne,FieldTwo,fieldThree) VALUES ('valueOne','valueTwo','null')
This statement doesn't seem to want to insert a null value into the database... I have also tried to insert the word "nothing".
Has anyone any ideas how to make this work? I am using SQL server 2005.
I am curious to know if there is a way to edit code in VS 2008 right when it has hit a breakpoint and I am walking thru the code... can I modify the code (such as the value in a variable or if my stepthrough line is about to hit an if statement ... can I modify the if statement....etc)?
So far, I have to stop running VS, modify the code, then hit F5 and wait till the breakpoint is hit again.
In my MySQL database, I have a float field named "HoursSpent" with values like "0.25", "1.75", "2.5", etc. Is there a way that I can have my SELECTstatement format those values in a friendly format like this?:
0.25 = 15 minutes
1.75 = 1 hour and 45 minutes
2.5 = 2 hours and 30 minutes
The "HoursSpent" field is supposed to only have values in 0.25 increments, but if somebody were to put something random like 0.16, it would be nice if the SELECTstatement handled that by rounding it up to the nearest 0.25 (so in this case 0.16 would become 0.25, or 15 minutes).
I have a parent table and a child table related to the parent table by some REFERENCE.
Suppose I exec a SELECTstatement on the child and that it returns the at least one result. Can I arrange for my search to automatically yield all the content of all related parents with this child too?
Or must I always take the reference from the child and put this in a second SELECTstatement and exec this myself?
I have an SQL query that has an alias in the SELECTstatementSELECT
CONCAT(YEAR(r.Date),_utf8'-',_utf8'Q',QUARTER(r.Date)) AS 'QuarterYear'
Later, I want to refer to this in my group by statement.
I'm a little confused...should I wrap this with backticks, single quote or just leave it unwrapped int he group by
GROUP BY
`QuarterYear `
or should I do this?:
GROUP BY
'QuarterYear'
or just this?:
GROUP BY
QuarterYear