how can we extract system time in vb and do calculation ie. adding or subtracing time then store change time in oracle database table in earlier format .
Here is the query in Oracle I was trying to remove the redundant math operation from:
SELECT name,
CASE
when nvl(num1,0) + nvl(num2,0) - nvl(num3,0) > 0
THEN nvl(num1,0) + nvl(num2,0) - nvl(num3,0)
ELSE 0
END
as result,
.... from ....
How do I not repeat the summation above?
There's a field with type of varchar. It actually stores a float point string.
Like 2.0 , 12.0 , 34.5 , 67.50 ...
What I need is a update statement that remove the ending zeros of fields like 2.0 , 12.0 , change them to their integer representation , that is 2 , 12 ...,and leave 3.45 , 67.50 unchanged . How should I do this ? I am using oracle 10.
I've got a table (col1, col2, ...) with an index on (col1, col2, ...). The table has got millions of rows in it, and I want to run a query:
SELECT col1, COUNT(col2) WHERE col1 NOT IN (<couple of exclusions>) GROUP BY col1
Unfortunately, this is resulting in a full table scan of the table, which takes upwards of a minute. Is there any way of getting oracle to use the index on the columns to return the results much faster?
from the following data basis i need to select all IDQ's which do not have an entry for the 11.11.2011.
IDQ | DATE
----------------
1 | 08.11.2011
1 | 09.11.2011
1 | 10.11.2011
1 | 12.11.2011
1 | 13.11.2011
i can't figure out how to express the sql
select
IDQ
from
TBL_WITH_IDQ T
where not exists ( DATE = '11.11.2011' ) // sql does not the job
Database is a Oracle 11g.
maybe someone can help me?
Hey all,
I am trying to put together a query that will display one specific record (found by the record's primary ID) at the top, and display all other records below it, sorted by date (I have "date_added" as one of the fields in the table, in addition to primary ID).
I could do this with a UNION (first select would locate the record I want, and the other select would display all other records), but I'm wondering if is there perhaps a better way?
I'm using Oracle, by the way.
We are using utl_file in Oracle 10g to copy a blob from a table row to a file on the file system and when we call utl_file.fclose() it takes a long time. It's a 10mb file, not very big, and it takes just over a minute to complete. Anyone know why this would be so slow?
Thanks
Does MySQL have any equivalent feature to Oracle's virtual private databases in 10g. It is also known as row level security.
I prefer not to implement anything like columns and triggers. I am looking for a solution similar to Oracle's.
I am trying to do something like this but am having trouble putting it into oracle coding.
BEGIN
IF ((SELECT complete_date FROM task_table WHERE task_id = 1) IS NULL)
THEN
UPDATE task_table SET complete_date = //somedate WHERE task_id = 1;
ELSE
UPDATE task_table SET complete_date = NULL;
END IF;
END;
But this does not work i also tried
IF EXISTS(SELECT complete_date FROM task_table WHERE task_id = 1)
with no luck
When you query the ALL_TAB_COLS view on Oracle 9i, it lists columns marked as UNUSED as well as the 'active' table columns. There doesn't seem to be a field that explicitly says whether a column is UNUSED, or any view I can join to that lists the unused columns in a table. How can I easily find out which are the unused columns, so I can filter them out of ALL_TAB_COLS?
Is it practically possible to create a triangle of stars like this as below in SQL.I know that this could be done easily in any other programming language like C,C++,Java but want to know whether it is really possible with just SQL or PL/SQL.I tried working on it with dual table in Oracle but couldn't get through it.
* *
* * * *
* * * or * * *
Can someone please shed somelight if anyone knows about it.
I saw couple of SO questions (SO) concerning SQL-server. For SQL-server there was no decent solution. All were hacks/workarounds. What about Oracle? Is it same answer (Paremeterizing each value)? Any Oracle example without LINQ would be appreciated (I have .NET 2.0).
Thanks & BR -Matti
I have a SQL query in which I am passing sysdate to the query problem is that when there is no matching date in table with sysdate then it don't shows the zero even if there is nvl applied
here is my query
select * from molasses
where trunc(trn_dte) = trunc(sysdate)
But it show data only when current date is present in table but I want to show zero if no data found in table.please help me to do this in oracle 10 g. Because some times the situation is like above and I have to display zero when no data found
I am on an oracle DB. Lets say I have one view that joins to three tables. The view has two fields each. Each field only needs data from two of the three tables.
If I query the view and return only one field, does the view still join to three tables or just to the two tables that it needs to calculate the field?
I've gone through ODBC API searching for a function that can extract information of a data source. The closest I found is SQLDataSources that enumerates all data sources and gives you the DSN name/description.
But specifically I would to extract the TNS service name of an Oracle data source. This property appears in the registry under ServerName but I found no way to access it through an API.
I need to verify that the provided string has only allowed characters using Oracle regular expressions (REGEXP_LIKE).
Allowed chars are: abcdefghijklmnopqrstuvwxyz0123456789_-.
Trying to execute
SELECT CASE
WHEN REGEXP_LIKE('abcdefghijklmnopqrstuvwxyz0123456789_-.'
, '^[a-z0-9_\-\.]+$')
THEN 'true'
ELSE 'false'
END tmp
FROM dual;
results in 'false'.
Any ideas on this?
Hi folks,
In Oracle 10g, is there a way to do the following in PL/SQL?
for each table in database
for each row in table
for each column in row
if column is of type 'varchar2'
column = trim(column)
Thanks!
I have a exception to prevent inserting same records on my oracle.
I've haerd that COUNT(*) has lots of cost which I don't want to use.
Is there any alternative way to make it at least cost?
How do I know when a project is just to big for MySQL and I should use something with a better reputation for scalability?
Is there a max database size for MySQL before degradation of performance occurs? What factors contribute to MySQL not being a viable option compared to a commercial DBMS like Oracle or SQL Server?
Oracle 9i has nested tables, however it doesn't have the all_nested_table_cols sysview (like 10g and 11g) which lets me see what the columns are for these nested tables. How can I find this information on a 9i database?
I have many columns in oracle database and some new are added with values. I like to find out which columns have values other than 0 or null. So I am looking for column names for which some sort of useful values exists at least in one row.
How do I do this?
Update: This sounds very close. How do I modify this to suit my needs?
select column_name, nullable, num_distinct, num_nulls
from all_tab_columns
where table_name = 'SOME_TABLE'
What is a candidate row when talking about Oracle and SQL? Using it in a sentence would be as such:
"The candidate row is fetched from the table specified in the outer query."
I got a little problem
i need a sql query that gives all rows back that only contains 0 in it.
the column is defined as varchar2(6)
the values in the column looks like this:
0
00
00
100
bc00
000000
00000
my first solution would be like this:
Oracle:
substr('000000' || COLUMN_NAME, -6) = '000000'
SQL Server:
right('000000' + COLUMN_NAME, 6) = '000000'
is there an other way?
(it needs to work on both systems)
I am using Oracle 11g and when I query data from database manually, it looks ok. But when I view it using Notepad++, there is a special character that gets inserted anywhere in the xml produced. Please see image below:
I tried everything and deleted some parts of the xml, updated the db and query again but the invalid character just differ in location. Any idea is much appreciated, thanks!
Best regards,
Racs
how can we extract system time in vb and do calculation ie. adding or subtracing time then store change time in oracle database table in earlier format .