martedì 25 agosto 2009

Execute a procedure under another schema

Problem:
There are two users, A and B.
User A creates a procedure.
User B wants to run that procedure, but he wants to affect the tables of his own schema, not the tables of user A!

Solution:
You can simply add
authid current_user
in the package specification

Authid clause immediatly follows the create procedure, create function, create package or create type statement.

mercoledì 5 agosto 2009

Build a .NET Application on the Oracle Database with Visual Studio 2005 or 2008

Interesting quick tutorial about Oracle and Visual Studio: LINK

venerdì 17 luglio 2009

Oracle SQL Developer Data Modeler

Directly from Oracle's website:

SQL Developer Data Modeler is an independent, standalone product with a full spectrum of data and database modeling tools and utilities, including modeling for Entity Relationship Diagrams (ERD), Relational (database design), Data Type and Multi-dimensional modeling, full forward and reverse engineering and DDL code generation. The Data Modeler imports from and exports to a variety of sources and targets, provides a variety of formatting options and validates the models through a predefined set of design rules.

Oracle SQL Developer Data Modeler can connect to any supported Oracle Database and is platform independent. A read-only SQL Developer Data Modeler Viewer is also available for download. The viewer allows users to open models created in the Data Modeler.

martedì 30 giugno 2009

How to retrieve the start day of the week

trunc(to_date('22-AUG-03'), 'DAY') would return '17-AUG-03'

How to retrieve the first day of the year

trunc(to_date('22-AUG-10'), 'YEAR') would return '01-JAN-10'

How to retrieve the first day of the month

Since there isn't a "first_day" function, we can use the trunc function:

trunc(to_date('22-AUG-03'), 'MONTH') would return '01-AUG-03'

DUP_VAL_ON_INDEX

The DUP_VAL_ON_INDEX is raised when a SQL statement attempts to create a duplicate value in a column on which a unique index exists.


begin

insert into $table_name[...]

exception

when DUP_VAL_ON_INDEX then

update $table_name[...]

or...

dbms_output.put_line('Error');

end;