I'm having trouble simplifying this conditional statements logic. Is there a more effervescent way of writing this?
if(($x || $a) && ($x || $y))
{
if($x){
return true;
}
}
return false;
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 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 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?
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)?
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?
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?
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.
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'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?
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 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?
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
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?
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.)
Most of the languages like C++ when writing into a file, put an EOF character even if we miss to write statements like :
filestream.close
However is there any way, we can put the EOF character according to our requirement, in C++, for an instance.
Or any other method we may use apart from using the functions provided in C++.
If you need to ask more of information then kindly do give a comment.
Thanks in advance.
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?
Does anyone know of a stand-alone tool for C# code cleaning/auditing that can run outside of Visual Studio IDE so as to be part of a build. Or if that isn't possible can someone provide some guidance as to how to make Visual Studio part of a build process -- by that I mean it would be nice to run the IDE's Sort and Remove unused using statements on all files as part of the build, but even better would be an exe that can read the .sln, or .csproj and do the job as part of build system.
Thanks,
L-
Trying to convert this tax-like IRS function http://stackoverflow.com/questions/1817920/calculating-revenue-share-at-different-tiers to SQL. The assumption is the table would be one column (price) and the tiers will be added dynamically.
My first attempt has some case statements that didn't work out well. I have since scrapped it :) Thanks for the help!
I have two insert statements.Second one will be executed only after successful execution of First one.What I wd like to do is-
$sqlone="Insert into .....";
$sqltwo="Insert into.....";
If(mysql_query($sqlone))
{
If(mysql_query($sqltwo))
{
show message Data inserted in both tables.
}
}
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.
As I found out that I can use only numerical values in C++'s switch statements, I thought that there then must be some deeper difference between it and a bunch of if-else's.
Therefore I asked myself:
(How) does switch differ from if-elseif-elseif in terms of runtime speed, compile time optimization and general compilation? I'm mainly speaking of MSVC here.
Hi,
AFAIAK, freeing a NULL will result in nothing.i mean nothing is being done by the compiler/no functionality is performed.
Still i do see some statements where people say that one of the scenario,where a memory corruption can occur is "freeing a memory twice"?
Is this still true?
I have various VB6 projects I'm maintaining with some of the queries being passed to the server having "ELSE:" with the colon used in case statements.
I'm wondering can someone tell me what the **ll the colon is used for? It causes errors in SQL2005 and greater, but SQL2000 works with no complaints.
I'd like to just remove it from the code & re-compile, but I'm afraid it'll break 10 other things in the application..
Thanks in advance...
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.