I have two variable TO_DATE and FROM_DATE. My table has two fields DOJ and DOL. I want to select all the records whose DOJ < TO_DATE and DOL FROM_DATE.
How can i write an SQL query in for this??
In particular, I've been trying to find the name of the ORA-0955 to improve code readability.
Currently I'm using the following:
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE = -00955
What I would prefer is something like:
EXCEPTION
WHEN OBJECT_EXISTS THEN
This seems cleaner to me and I would prefer that. But I've looked in SYS.STANDARD, and it lists relatively few named exceptions. Online documentation seems to mirror what's in SYS.STANDARD. Is there another package to look in? Some other resource?
I have a table with columns named with the number of hour of day like this:
col00 NUMBER(5)
col01 NUMBER(5)
col02 NUMBER(5)
...
col23 NUMBER(5)
...and I have another query that returns a count by hour.
I want to recover the colXX value by hour.... then I can recover with "decode" or "case when..." but I want know if exists any way to recover the column by a text like this:
select "col"||hour from table;
in the hypothetical above example if hour is 13 then would be translated like:
select col13 from table;
there is any way to do this ?
I have a table with columns named with the number of hour of day like this:
col00 NUMBER(5)
col01 NUMBER(5)
col02 NUMBER(5)
...
col23 NUMBER(5)
...and I have another query that returns a count by hour.
I want to recover the colXX value by hour.... then I can recover with "decode" or "case when..." but I want know if exists any way to recover the column by a text like this:
select "col"||hour from table;
in the hypothetical above example if hour is 13 then would be translated like:
select col13 from table;
there is any way to do this ?
I am processing large amounts of data in iterations, each and iteration processes around 10-50 000 records. Because of such large number of records, I am inserting them into a global temporary table first, and then process it. Usually, each iteration takes 5-10 seconds.
Would it be wise to truncate the global temporary table after each iteration so that each iteration can start off with an empty table? There are around 5000 iterations.
I would just like to ask what is the difference between user_constraints and user_objects.
I have this two database. I run a script on both DB that resulted a unique constraint error.
To solve the problem I delete the constraint on user_constraint table for both DB.
After that DB1 run without error.. DB2 however failed, I checked the user_constraint for both db and the constraints was deleted. I was asked to check the user_objects.. and found that DB2 has that same constraint_name as the object_name in user_objects table..
Any info regarding their relationship, use, similarites, etc will be appreciated ...
Thanks..
hi!
i have 3 tables A,B and C.
table A has column employee_name,id
table B is the main table and has columns id,os version.
table c has the columns id,package id and package version.
i want to query the count of employee_name where the id of table a and c are matched with id of table b(which is the main table).
i should also get the names of employees grouped by the os version they have and also the package version.
I am executing a stored procedure which has 2 cusors within the stored procedure.
The 1st cursor which is not return to the jdbc as a resultset is closed within the stored procedure.
The 2nd cursor which returns the resultset to the jdbc is not closed within the stored procedure.
Upon executing I encounter cursor is closed exception which is puzzling.
Since the ResultSet will close all underlying cursor upon invoking the close() method
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
What is faster?
the Merge statement
MERGE INTO table
USING dual
ON (rowid = 'some_id')
WHEN MATCHED THEN
UPDATE SET colname = 'some_val'
WHEN NOT MATCHED THEN
INSERT (rowid, colname)
VALUES ('some_id', 'some_val')
or
querying a select statement then using an update or insert statement.
SELECT * FROM table where rowid = 'some_id'
if rowCount == 0
INSERT INTO table (rowid,colname) VALUES ('some_id','some_val')
else
UPDATE table SET colname='some_val' WHERE rowid='some_id'
Hi,
I have a table of items stored this way :
A1 | B1
A1 | B2
A1 | B3
A2 | B1
A2 | B4
...
And I need to retrieve with a SQL Query :
A1 | B1, B2, B3
A2 | B1, B4
...
I'm using dbms_scheduler to execute a PL/SQL stored procedure. I would like to be able to have that code create some text logging output and associate it with the run to verify it's working, but I can't find anything to do that in the docs. Is there a facility to do this that I'm missing? This is an 11g database running under Unix. It would be real nice if I could use dbms_output so I could also run it from sqlplus and get output.
Hello,
I would like to use a trigger on table which will be fired every time a row is inserted, updated, deleted.
I wrote something like this:
CREATE or REPLACE TRIGGER test001
AFTER INSERT OR DELETE OR UPDATE ON tabletest001
REFERENCING OLD AS old_buffer NEW AS new_buffer
FOR EACH ROW WHEN (new_buffer.field1 = 'HBP00')
and it works.
Since I would like to do the same things if the row is inserted, updated or deleted I would like to know what's happening in the trigger.
I think I can manage to find if the row in inserted or updated (I can check the old_buffer with the new_buffer).
How can I know if the row has been deleted?
Alberto
hi,
I have one table of 50k keywords and I am providing the auto-complete feature for these keywords based on count mechanism. But still getting the keywords takes time..
In what way would the database partitions have to be done for fast retrieving....
help me plz.....
Hi,
I have the following script in Oacle
I do not understand why i get
Bind Variable "DeliveryDate_Variable" is NOT DECLARED
Everything looks ok to me
VARIABLE RollingStockTypeId_Variable NUMBER := 1;
VARIABLE DeliveryDate_Variable DATE := (to_date('2010/8/25:12:00:00AM', 'yyyy/mm/dd:hh:mi:ssam'));
SELECT DISTINCT
rs.Id,
rs.SerialNumber,
rsc.Name AS Category,
(SELECT COUNT(Id) from ROLLINGSTOCKS WHERE ROLLINGSTOCKCATEGORYID = rsc.id) as "Number Owened",
(SELECT COUNT(rs.Id)
FROM ROLLINGSTOCKS rs
WHERE rs.ID NOT IN( select RollingStockId
from ROLLINGSTOCK_ORDER
WHERE :DeliveryDate_Variable BETWEEN DEPARTUREDATE AND DELIVERYDATE)
AND rs.RollingStockCategoryId IN (Select Id
from RollingStockCategories
Where RollingStockTypeId = :RollingStockTypeId_Variable)
AND rs.RollingStockCategoryId = rsc.Id) AS "Number Available"
FROM ROLLINGSTOCKS rs
JOIN RollingStockCategories rsc ON rsc.Id = rs.RollingStockCategoryId
WHERE rs.ID NOT IN(
select RollingStockId
from ROLLINGSTOCK_ORDER
WHERE :DeliveryDate_Variable BETWEEN DEPARTUREDATE AND DELIVERYDATE
)
AND rs.RollingStockCategoryId IN
(
Select Id
from RollingStockCategories
Where RollingStockTypeId = :RollingStockTypeId_Variable
)
ORDER BY rsc.Name
Hi
I want to create a trigger that execute on update of a table.
in particular on update of a table i want to update another table via a trigger but if the trigger fails (REFERENTIAL INTEGRITY-- ENTITY INTEGRITY) i do not want to execute the update anymore.
Any suggestion on how to perform this?
Is it better to use a trigger or do it anagrammatically via a stored procedure?
Thanks
Hi
I have this table:
Reason|Area_Code|Id
x dig 1
x dig 2
y dig 3
h util 4
x dig 5
I'm trying for a SQL that returns:
Reason|Amount of distinct Reason|Area_code
x 3 dig
y 1 dig
h 1 util
I will use this result to plot a chart. I don´t have any idea on how this SQL can be done. Could you help me?
Hi I have this table:
Reason|Area_Code|Id
x dig 1
x dig 2
y dig 3
h util 4
x dig 5
I'm trying a sql that returns:
Reason|Amount of distinct Reason|Area_code
x 3 dig
y 1 dig
h 1 util
I will use this result to plot a chart. I don´t have any ideia on how this SQL can be. Could you help me?
I have the below query
Select
case upper(device_model)
when 'IPHONE' then 'iOS - iPhone'
when 'IPAD' then 'iOS - iPad'
when 'IPOD TOUCH' then 'iOS - iPod Touch'
Else 'Android'
End As Device_Model,
count(create_dtime) as Installs_Oct17_Oct30
From Player
Where Create_Dtime >= To_Date('2012-Oct-17','yyyy-mon-dd')
And Create_Dtime <= To_Date('2012-Oct-30','yyyy-mon-dd')
Group By Device_Model
Order By Device_Model
This spits out multiple rows of results that read "Android"....I would like there to be only 4 results rows, one for each case....so it comes out like this:
Device_Model Installs_Oct17_Oct30
Android 987
iOS - iPad 12003
iOS - iPhone 8563
iOS- iPod Touch 3482
Is there anyway to remove a character from a given position?
Let's say my word is:
PANCAKES
And I want to remove the 2nd letter (in this case, 'A'), so i want PNCAKES as my return.
Translate doesnt work for this.
Replace doesnt work for this.
Regex is damn complicated...
Ideas?
How do I calculate number of years since product was made (rounded to 1 decimal point) for products that were made less than five years ago? Thank you.
Suppose I have a table like this:
NAME GROUP
name1 groupA
name2 groupB
name5 groupC
name4 groupA
name3 groupC
I'd like to have a result like this:
GROUP NAMES
groupA name1,name4
groupB name2
groupC name3,name5
If there were only one column in the table, I could concatenate the records by doing the following, but with grouping in the context, I really don't have much idea. Any suggestion is welcome, thanks in advance!
Concatatenating one column table:
SELECT names
FROM (SELECT SYS_CONNECT_BY_PATH(names,' ') names, level
FROM name_table
START WITH names = (SELECT names FROM name_table WHERE rownum = 1)
CONNECT BY PRIOR names < names
ORDER BY level DESC)
WHERE rownum = 1