when the optional parameters are null or empty how can i ignore that condition?
e.g.
declare @color nvarchar(50)
declare @time datetime
set @color = null
select *
from apples
where apple.color = @color
and apple.time = @time
if @color or @time is null , i would like to ignore that condition.
...
I have a dataset something like this
A | B | C | D | E
-----------------------------------------------
1 | Carrot | <null> | a | 111
2 | Carrot | <null> | b | 222
3 | Carrot | zzz | c | 333
4 | Banana | <null> | a | 444
5 | Banana | ...
Hello,
SQL beginner here.
I have a query which takes around 10 seconds to run, so we have a slow down in the application.
Would it be possible in MySQL or more generally in SQL for the server to periodically (every 1 to 5 minutes) run the query and store it somewhere, so that I can query this "cache" table for easy access ?
Many tha...
hi guys,
i'm a pl/sql newbie. now i have a question about oracle type. i saw there are two types of type :
CREATE OR REPLACE TYPE "TYPE_NAME1" AS OBJECT
(
temp_trans_id number(10),
trans_id number(10),
resion_id number(10)
)
or
type new_type_name is record(
column1 number,
co...
For a relational database that represents the current term enrollment at a large university, what is the ER diagram for a schema that takes into account all the assertions given:
• 100 instructors, 200 courses, and 800 students.
• An instructor may teach one or more courses in a given term
(average is 2.0 courses).
• An instructor mus...
I have the following table (highscores),
id gameid userid name score date
1 38 2345 A 100 2009-07-23 16:45:01
2 39 2345 A 500 2009-07-20 16:45:01
3 31 2345 A 100 2009-07-20 16:45:01
4 38 ...
I have a database that tracks players through their attempts at a game. To accomplish this, I keep a table of users and store the attempts in a separate table. The schema for these tables is:
CREATE TABLE users (
id BIGINT PRIMARY KEY, -- the local unique ID for this user
name TEXT UNIQUE, -- a self-chosen username for the user
...
So...
It is possibile to use a WHERE clause after a HAVING clause?
The first thing that comes to my mind is sub queries, but I'm not sure.
P.S. If the answer is affirmative, could you give some examples?
...
Hi,
Below is my Oracle Procedure. When i call this procedure using java, it throws error like this.
CREATE OR REPLACE PROCEDURE sp_Get_Menu_Parents
(
v_inMenuID IN VARCHAR2 DEFAULT NULL,
cv_1 IN OUT SYS_REFCURSOR
)
AS
BEGIN
OPEN cv_1 FOR
SELECT MenuItemId,
MenuItemName,
MenuItemDisplayName,
...
I want to update some data in a specified case, else these fields are not to be updated.
What can i write code in a stored procedure for this?
...
My table name is table_1, fields are:
name
dept
location
status
Status is already 1, but I want to update the status into 2 based on a certain condition else not update. My code is
UPDATE Table_1
SET model = @model,
make = @make,
[Asset Serial No / Service Tag] = @Asset,
[IT Asset Tag] = @AssetTag,
...
We have lots of stored procedures which all contain a lot of comments.
Is there a way to extract the comments from the stored procedures for deployment so the users can't see them when they modify a stored procedure with SQL Server Management Studio?
Note: We're using SQL Server 2008.
...
Hi,
i have three tables and 2 JPA model classes:
Unit
------------
id [PK] - Integer
code - String
unitGroups - List<UnitGroup>
UnitGroup
------------
id [PK] - Integer
ugKey - String
units - List<Unit>
units and unitGroups have many-to-many relationship between themselves.
briefly i want to write an HQL query...
Hello !
I have the following line in a script and I don't understand what the "using" part is used for.
I couldn't find anything on google. Anybody familiar with that ?
Thanks a lot !!
CREATE MATERIALIZED VIEW "PVTRNDM"."DM_MVW_DAILY_CAL"
USING ("DM_MVW_DAILY_CAL",
(8, 'PLANVP.XXXX.INT', 1, 0, 0, "PVTRN", "DAILY_CAL", '2009-...
Hi! I try to import sql script, generated with Server Management Studio, into SQL Compact 3.5 and get a lot of error. What I am doing wrong?
I generate script with "Task/Generate Script" context menu. Part of my script:
CREATE TABLE [LogMagazines](
[IdUser] [int] NOT NULL,
[Text] [nvarchar](500) NULL,
[TypeLog] [int] NOT NULL,
[Date...
Hey there, was wondering if anyone could help a newbie on SQL and Python. I thought I had a pretty decent grasp of it, however something odd happened recently.
Here is the the following code snipped from a larger portion:
try:
self.db.query("SELECT * FROM account WHERE email = '{0}' AND pass = '{1}'".format(self.mail.strip(self...
Suppose you have a few, quite large (100k+) objects in available and can provide this data (e.g. name) in 20+ languages. What is an efficient way to store/handle this data in a SQL database.
The obvious way to do that looks like this - however, are there other ways which make more sense? I'm a bit worried about performance.
CREATE TA...
Hi All
I am trying to work out how to configure PHPUnit to use the "test database" that is described on this wiki page: http://www.phpunit.de/wiki/TestDatabase However I can't find any documentation on how to enable and configure it.
Has Anyone got any ideas?
Thanks
...
Hi,
The following simple query takes a very long time (several minutes) to execute.
I have an index: create index IX on [fctWMAUA] (SourceSystemKey, AsAtDateKey)
SELECT MAX([t0].[AsAtDateKey]) AS [Date], [t0].[SourceSystemKey] AS [SourceSystem]
FROM [fctWMAUA] (NOLOCK) AS [t0]
WHERE SourceSystemKey in (1,2,3,4,5,6,7,8,9)
GROUP BY [t0...
I have a complex sql query that I have in a stored procedure and am calling from C#.
The procedure requires a date-time which I pass in as DateTime object from c#, the problem seems to occur with the format of the date. If I change the parameter to string and pass it in as 'yyyy-MM-dd' it works fine.
Is there anyway to use the datetim...