Why are nested comments forbidden in C++, Java inspite of the fact that nested comments are useful, neat, and elegant and can be used to comment out statements that have comments?
Can anyone enlighten me as to the differences between the two statements below.
[self playButtonSound];
AND:
[self performSelector:@selector(playButtonSound)];
I am just asking as I had some old code that used @selector, now with a little more knowledge I can't think why I did not use [self playButtonSound] instead, they both seem to do the same as written here.
gary
Where should I put require_once statements, and why?
Always on the beginning of a
file, before the class,
In the actual method when the
file is really needed
It depends
?
Most frameworks put includes at the beginning and do not care if the file is really needed.
Using autoloader is the other case here.
So,
I can run the following statements from within mysql itself successfully.
SET @fname = 'point1';
SELECT * FROM country WHERE name=@fname;`
But when I try to pass the query through php like this and run it, I get an error on the second line
$query = "SET @fname = 'point1';";
$query .= "SELECT * FROM country WHERE name=@fname;";
I've already set
<property name="show_sql">false</property>
& disable all messages in log4j.properties
But Hibernate shit to console with all queries & statements.
What would be appropriate scenario when stored procedures should be used?
I stumbled upon implementation where almost whole data manipulation was handled by store procedures, even simplest form of INSERT/DELETE statements were wrapped and used via SP's.
So, what's the rationale for using stored procedures in general?
Sorry for such a beginners question..
Hi,
In an if statement with multiple conditions is second executed if the outcome is clear after checking the first condition?
example:
if(i>0 && array[i]==0){
}
If I swap the conditions a seg fault may occur for negative values of i but this way the memory debugger doesn't find a problem. Can I be sure that this works always or do have have to use nested if statements?
I need to get a WHERE clause to only evaluate certain statements. something like:
WHERE field_a = field_b AND
(CASE WHEN <PARAM>type</PARAM> = 5
THEN {field_c = 1 OR field_c = 2}
WHEN <PARAM>type</PARAM> = 6
THEN {field_c = 3 OR field_c = 4}
ELSE field_c = <PARAM>type</PARAM>
so that when the Param type = 5, it only checks if field_c = 1 or 2. Any thoughts?
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 a number of classes that are decorated with DebuggerDisplayAttribute.
I want to be able to add trace statements to Unit Tests that will display instances of these classes.
Does there exist a method in the .NET Framework that will display an object formatted using DebuggerDisplayAttribute (or fall back to using .ToString() if no DebuggerDisplayAttribute is defined)?
The man says that case statements use "filename expansion pattern matching".
I usually want to have short names for some parameters, so I go:
case $1 in
req|reqs|requirements) TASK="Functional Requirements";;
met|meet|meetings) TASK="Meetings with the client";;
esac
logTimeSpentIn "$TASK"
I tried patterns like "req*" or "me{e,}t" which I understand would expand correctly to match those values in the context of filename expansion, but it doesn't work.
Thanks.
I wish to give different licenses to different parts of my code.
Also I need to put some copy rights on several SQL statements.
Is it possible?
How should I organize my code to make it happen?
Even I used break() and exit() statements many times, I am bit confused between them. I need to know exact meaning of both, when we should use them. Please explain with small example.
Thank you.
If an action has been decorated with [Authorize(Roles="Administrators")] is there a way to not display the link for the currently logged in user who is not in the declared role?
It seems to me that baking a lot of if statements into the view to give this kind of "selective disclosure" is contrary to the MVC way, but I'm not sure what the alternative is?
I was looking for a tool that can convert C code expressions for the form:
a = (A) ? B : C;
into the 'default' syntax with if/else statements:
if (A)
a = B
else
a = C
Does someone know a tool that's capable to do such a transformation?
I work with GCC 4.4.2 and create a preprocessed file with -E but do not want such structures in it.
I've got quite a few SQL statements like such:
SELECT foo FROM things WHERE user_id IN (1,2,3..n)
Is there a known limit to the number of elements that will safely fit in an IN clause like that?
I have an application with existing data, that has Zero in the date column.
When I look at it from sqlplus I see:
00-DECEMB
when I use the dump function on this column, I Get:
Typ=12 Len=7: 100,100,0,0,1,1,1
I need to work with the existing data from .Net (no changes to the data,or the data structure or even existing sql statements)
How the hack do I read this value, or write it.
The db version varies, from 8 to 11.
Help would be appreciated
I trying to find out how to get the mail server information on the server I connect to with Javamail. I know in the debug statements when you connect you will get something like "S: +OK [MAIL_SERVER_NAME] ready.". Is there an easier way to get this information (and hopefully more information) than just parsing the debug output?
Is there any good reason to avoid unused import statements in Java? As I understand it, they are there for the compiler, so lots of unused imports won't have any impacts on the compiled code. Is it just to reduce clutter and to avoid naming conflicts down the line?
(I ask because Eclipse gives a warning about unused imports, which is kind of annoying when I'm developing code because I don't want to remove the imports until I'm pretty sure I'm done designing the class.)
Hello everyone,
I see there's a lot of talk here about how to go about sanitizing data. Could it
be as simple as adding this rewrite rule to .htaccess?
RewriteRule ^([\w\-]+)$ index.php?page=$1
To my understanding this will allow only letters, numbers, _ and - in $1, am I right?
If you add to this usage of prepared statements for SQL queries, it should be pretty proof,
is that right?
Somehow feels like too easy to be true, am I missing something, any ways to firm it up?
I used this trick:
List statuses = new ArrayList();
Criteria criteria = session.createCriteria(MessageQueue.class);
criteria.add(Restrictions.not(Restrictions.in("message_status", statuses)));
and this code creates:
...from MESSAGE_QUEUE mq where not (mq.message_status in (?, ?, ?, ?))...
but I need:
...from MESSAGE_QUEUE mq where mq.message_status NOT IN (?, ?, ?, ?)
Du you think they are equal statements?
I can:
declare @idOrder int
set @idOrder = 21319
I want:
declare @idOrder int
set @idOrder = (21319, 21320)
for use in a series of statements where the 'WHERE' clause uses the IN operator
delete Orders where idOrder in @idOrder
instead of
delete Orders where idOrder in (21319, 21320)
I have several possible occurrences to test with strstr.
if ((a = strstr(string, "FOO")) != NULL || (a = strstr(string, "BAR")) != NULL ||
(a = strstr(string, "FOO2")) != NULL ||(a = strstr(string, "BAR2")) != NULL ||
(a = strstr(string, "FOO3")) != NULL ||(a = strstr(string, "BAR3")) != NULL) // do something
and then based on the occurrence found I need to do
var = strlen("THE_ONE_MATCHED_ABOVE");
What would be a good way to do this without using lots of if statements?
The function essentially contains 2 statements:
statement1; and statement2;
If statement1 fetches some records,just return them as result;If it doesn't fetch any result,return the result of statement2.
for a table valued function in sql why cant we write sql statements inside begin and end tags like-
create function dbo.emptable()
returns Table
as
BEGIN --it throws an error
return (select id, name, salary from employee)
END
go
while in scalar valued function we can use these tags like
create function dbo.countemp()
returns int
as
begin
return (select count(*) from employee)
end
go
is there any specific rule where we should use BEGIN & END tags