oracle

Help building a SQL query from multiple tables

Given the following tables, how might I build a SQL query that includes a list of all the items from the "items" table, and a column for each color from the "colors" table that, for each item listed, indicates what colors the item has a relationship with. If that is unclear at all, please let me know what additional information will hel...

In SQL in a "group by" expression: how to get the string that occurs most often in a group?

Assume we have the following table: Id A B 1 10 ABC 2 10 ABC 3 10 FFF 4 20 HHH As result of a "group by A" expression I want to have the value of the B-Column that occurs most often: select A, mostoften(B) from table group by A; A mostoften(B) 10 ABC 20 HHH How do I achieve this in Oracle 10g? Rema...

Display Dynamic EXECUTE Output Within pl/sql From sqlplus

How to get the dynamic select results of EXECUTE within pl/sql from Oracle sqlplus? I'm writing a simple sqlplus script to collect the sum of all NUMBER columns of a given table -- SET SERVEROUTPUT ON DECLARE CURSOR column_cur IS SELECT column_name FROM ALL_TAB_COLS WHERE owner = '&scheme_name' ...

Return a column in hql select clause without actually using that column

I have a query which returns a list of objects like such: select distinct ref from references where [...] I'd like to order these by a field not on ref but on an association of ref, i.e.: select distinct ref from references where [...] order by ref.foo.name Unfortunately this doesn't work in Oracle (once the query is translated to ...

Need of %NOTFOUND in cursor

Can anybody please tell me what is the use of %NOTFOUND operator? We can use "NOT %FOUND" in cursor also. It will perform same functionality. ...

need to create a proc or anonymous block

hi, we have one table as following Table name: metadata_table strucutre is as follows S.No Tablename Column 1 Fct_sales_summary wk_units 2 Fct_exp_summary mn_units wk_units as in the table Fct_sales_summary are columns and are in range wk_units1 to wk_units105 and similarly in Fct_exp_summary ...

How do I find out if an oracle database is set to autocommit?

And while we're at it, how do I switch between autocommit and non-autocommit? ...

Retrieving key attribute names of a given table

Hi all, I am working on a database middleware application again. I want to retrieve the names of all key values of a given table. For instance: CREATE TABLE foo(A INTEGER PRIMARY KEY, B VARCHAR(255)) I want to ask Oracle for the primary keys of 'foo' and I want to get 'A'. Is this possible in Oracle at all? I tried to search their d...

ORA-01756: quoted string not properly terminated

please let me know the issue with following script (sql,oracle 10g) 1 DECLARE @colname AS NVARCHAR(50) 2 DECLARE @tablename AS NVARCHAR(500) 3 DEClARE @query AS NVARCHAR(500) 4 SET @colname = 'select wk_units1 from cnt_sls_dm.fct_sales_summary' 5 SET @tablename = 'SELECT tablename from dmi_user.fct_sales_meta' 6 set @q...

Script to run other scripts in sqldeveloper

I have a number of scripts used to build a database. These need to be executed in a certain order. Is it possible to create a script to run other scripts in SQL Developer (1.5.3)? I know I can do this with sqlplus, but I was hoping there's a similar ability I just don't know about. ...

Passing BLOB/CLOB as parameter to PL/SQL function

I have this procedure i my package: PROCEDURE pr_export_blob( p_name IN VARCHAR2, p_blob IN BLOB, p_part_size IN NUMBER); I would like for parameter p_blob to be either BLOB or CLOB. When I call this procedure with BLOB parameter, everything is fine. When I call it with CL...

Why does SQL*Plus commit on exit?

Surely this should be the same as a termination of a session and cause a rollback? It seems to me to be the most un-Oracle thing possible. I was actually shocked when I found out that it did this More importantly - would anyone object if Oracle changed it to rollback on exit? ...

Call PL/SQL Web Toolkit procedures from Java

I need to call some PL/SQL procedures from my Java application. I can do it with JDBC. But the problem is that procedures are using the "PL/SQL Web Toolkit" and its packages (htp, owa _ util, owa _ cookie, ...). When I call them I get some exceptions as this: Exception in thread "main" java.sql.SQLException: ORA-06502: PL/SQL: numeric o...

Going to Oracle from MySQL

I'm starting a new semester and for my class "relational databases" they are using Oracle. Now I'm experienced in using MySQL and was wondering what the main differences are between Oracle and MySQL. So I have a couple of questions. What are the fundamental differences in using the database? What are some of the differences in SQL syn...

Recommendations on a sql comparison (schema & data) tool that supports both Oracle and SQL Server?

I'm trying to find a good tool (open source or commercial) for doing comparisons of database instances, for example: Compare 2 database schemas; generate platform specific change script (either direction) to bring one into synch with the other Compare data (table contents), generate platform specific change script (either direction...

How do I write an uploaded file from ejb3 app to Oracle directory.

I'm going to analize some Excel files that the user has to upload in my webapp, I already have the stored procedures that works. But i have no idea how to save the uploaded file to my oracle directoy. I think there are two steps, first creating the file into the specified path. And filling tha file with the info. If somebody has made thi...

Example of Oracle "Instead of" Trigger

Does anyone have a simple example that explains why one would want to use an Oracle instead of trigger ? ...

Oracle: find index creation date from systables/information_schema?

Using Oracle, how can I find index names and creation dates from systables/information_schema? How can I reproduce, from systables/information_schema, the DDL that created the index, e.g., create index indexname on tablename(column_name [, column_name....]) [local]; ...

How do we count rows using Hibernate?

For example, if we have a table Books, how would we count total number of book records with hibernate? Thanks ...

Problem with java not releasing oracle cursors.

Hi, I'm working on the following code below, (edited for clarity), that is giving me a few problems with open cursors in Oracle. Basically I am trying to select data from the DB and for each row returned there is 0 or more rows of sub data to be selected and appended to the record. This is currently being achieved by calling out to anot...