Viewing the last edit date of a procedure in Oracle SQL Developer - oracle

In SQL Server Management Studio, there's a tab called Object Explorer Details that you can look at to see when a table or a procedure is created or last modified.
Is there something similar for Oracle SQL Developer?

View > Reports > Data Dictionary Reports
Open the All Objects Report
You can filter/sort the report to restrict to a specific schema or object type, or even filter on the last updated date (Last_DDL)

* Query way *
With Oracle, you can query the view all_objects
* GUI way *
Search for the objects that you want and the check the Details tab
Let say you want information about OE_ACKNOWLEDGMENT_PUB package body
Then you click on the object name
Then you click on Details tab

Related

Is there any table where Oracle APEX usage log is stored

I was just wondering if there is any standard table , where we can see which user has accessed which report in Oracle APEX, based on date and time. Basically the audit history ?
I can do it by inserting the needed data in a custom table but, is there any standard way, where we have all this information?
Regards,
Abha
Oracle APEX has indeed internal tables where it stores all of this information. The name of the view to have insight into this data is apex_workspace_activity_log.
select s.workspace,
s.apex_user,
s.application_id,
s.application_name,
s.page_id,
s.page_name,
s.view_date,
s.apex_session_id
from apex_workspace_activity_log s
/
Here you can see WHO accessed a page, WHAT page has been accessed and WHEN that page has been accessed (date and time). This is not on individual report level, as you asked for, but at least you can see it on page level.
Use following views to see what report exists on which page and join that information as you like.
apex_application_page_rpt
apex_application_page_ir
apex_appl_page_igs
select * from APEX_WORKSPACE_ACTIVITY_LOG
select * from APEX_ACTIVITY_LOG

How to get View from Oracle to Jaspersoft Studio?

I have created the following view in Oracle:
CREATE OR REPLACE FORCE VIEW "TEST_ASSIGNMENT"."VPRODUCTCATALOG" ("PRODUCTCODE", "GROUPCODE", "PRODUCTGROUPPATH") AS
select "code" as productCode,
func_groupCode("code") as groupCode,
func_productPath("code") as productGroupPath
from "Products";
I want to create a report in Jaspersoft Studio which will have information from this View.
How can I get this View into Jaspersoft? It seems to me that Jaspersoft only have ordinary SELECT for option.
Firstly, a "View" is not PL/SQL code, it's a standard SQL object.
You have to write a normal SQL query like:
SELECT * FROM "TEST_ASSIGNMENT"."VPRODUCTCATALOG"`
If you want to execute PL/SQL code you must select PL/SQLlanguage from the language list, but it is a more advanced topic and not required in your requirement.

Crystal Reports displays blank (null) values for some fields from an Oracle view

Summary
We have a Crystal Report referencing a single Oracle view. There are no other tables or joins in the report. The view is composed of several selects, joins, and other data transformations (e.g., sum, case, to_date, group by).
Four columns from the view display as blank (null) in the report. These same columns display correctly in Oracle SQL Developer and via a select using the Oracle Data Provider for .NET in a C# application. All other columns display correctly in the report.
In addition the Browse Field option displays no values for the affected fields, but does display options for unaffected fields of the same type. Similarly, if I make an affected field a parameter of the report no options are presented.
We verified that in all cases we are connecting as the same read only user in Crystal Reports, Oracle SQL Developer, and in our Web Application.
Failed Resolution Attempts
We removed and replaced the view and fields in the Crystal Report.
We created a brand new report connecting to the same view.
We created a new view (from the same SQL) to be used in the same report
We verified database via Crystal Reports
We converted implicit date conversion from
score_month = '01-SEP-2017'
to
score_month = TO_DATE('01-SEP-2017', 'dd-MON-yyyy')`
per https://stackoverflow.com/a/37729175/19977
Other Oddities
Exporting the data from the view to a table works, but we want to use a view
We're at a loss as to what the cause of this issue is. Any ideas?
Several edits to the view were required to resolve this issue.
We removed Oracle specific sql per https://stackoverflow.com/a/37729175/19977. Example:
-- replace
TRUNC(sysdate, 'MONTH') AS score_month`
-- with
TO_DATE('01-SEP-2017', 'dd-MON-yyyy')
-- and replace
where score_month = '01-SEP-2017'
-- with
where score_month = TO_DATE('01-SEP-2017', 'dd-MON-yyyy')
Fully qualify all tables and views used in the Oracle view with the schema and table name. Example:
-- replace
FROM table t
-- with
FROM our_schema.table t
It remains unclear why the view would work as intended from Oracle SQL Developer and in application via the Oracle Data Provider for .NET but not from Crystal Reports. Further insight into this issue is welcome.

Oracle query output in excel

I have an Oracle 10G database and I need to write a fairly straightforward query that joins two tables and selects some data. However, I'd like to export the result list to an excel, so end users can use this .xls document to see the results and filter by one of the fields (location)
When I write the query, is there an easy way I can generate/ create an excel document that would hold these results as described above? The SQL doesn't need to run from within excel, but I guess that would be a useful feature now that I think about it!
Thanks.
There is simple solution for your request.
By using ora_excel, small pl/sql package which generates Excel xlsx file, you can select data and export selected data to Excel and set filtering.
Please see following example:
BEGIN
ORA_EXCEL.new_document;
ORA_EXCEL.add_sheet('My sheet');
ORA_EXCEL.query_to_sheet('select * from employees'); -- Select data from database
ORA_EXCEL.set_cells_filter('A1', 'K1'); -- Add cell filtering from column A1 to column K1
-- Save generated Excel to file with name example.xlsx to Oracle folder EXAMPLE_XLSX
ORA_EXCEL.save_to_file('EXPORT_DIR', 'example.xlsx');
END;
For more details please check here
Cheers
Pretty easy to do in excel; and when done user can right click the data and say "Refresh" to get the latest updates.
but why reinvent the wheel lots of online articles already explain how to do this... Here's one
http://blog.mclaughlinsoftware.com/microsoft-excel/how-to-query-oracle-from-excel-2007/
After you've connected to a table, you can edit the properties on the connection and enter custom SQL (copy and paste from your developer tools)
Since you cannot use OLE DB in your version of Excel. Use SPOOL to create a CSV file.
SQL> SET echo off
SQL> SET verify off
SQL> SET colsep ,
SQL> SET pagesize 0
SQL> SET trimspool on
SQL> SET feedback off
SQL> SPOOL ON
SQL> SPOOL C:\data.csv
SQL> SELECT COLUMN1,COLUMN2,COLUMN3....
FROM TABLE;
SQL> SPOOL OFF
The .csv file should open in Excel by default. Use proper column aliases so that users understand the column headers.
Quick way:
At first create a view which contains your Query(Best way because you might need to change this query later).
Be sure to properly have installed oracle client.
In Excel(2007 and above) in Data tab go this way:
From Other sources -> From Data Connection Wizard -> Microsoft Data Access - OLE DB Provider for Oracle
Now Enter your DataSource Name(Stored in tnsnames.ora) and user password
Find you view and Then You'll have what you need.
You can save password and set option to refresh automatically in connection properties.
You are able to query an oracle database directly from Excel 2003 however, your sql statements are interpreted by MS Query and because of this it can often be frustrating. I will assume the machine in question already has the ability to query your database and has properly configured the database naming.
To query your database from excel 2003 you must:
Install and configure oracle's ODBC Driver (You must have the 32bit drivers installed since excel03 is a 32bit application). ODBC can be configured under start > administrative tools > ODBC Data Source Administrator
Open excel 2003 and goto data > import external data > new database query.
This should bring up MS Query which is an Access-like interface.
Obviously this is a very brief starter to get you stepping in the right direction. If you have any specific questions, please comment and I will try and help you.
Step 1
Run Your Query
Right Click on Resultenter image description here
Step 2
Click on Export
enter image description here
Step 3
Select Format To Excel
Enter datasheet name and location
Step 4
Click on Next and then finish
enter image description here
You can do one thing.
First generate the output in a form that includes column separators using symbols (like , or #).
Import the data to the excel and then define the placeholders as the column separators.

Oracle - How to generate script from sql developer

How to take script for schema of the tables, stored procedures of Oracle through SQL Developer tool (SQLPLUS command line interface)?
SQL Developer -> Tools -> Database Export...
If you want to see DDL for the objects, you can use
select dbms_metadata.get_ddl('OBJECT_TYPE','OBJECT_NAME','OBJECT_OWNER')
from dual
/
For example this will give you the DDL script for emp table.
select dbms_metadata.get_ddl('TABLE','EMP','HR')
from dual
/
You may need to set the long type format to big number. For packages, you need to access dba_source, user_source, all_source tables. You can query for object name and type to see what code is stored.
This worked for me:
In SQL Developer, right click the object that you want to generate a script for. i.e. the table name
Select Quick DLL > Save To File
This will then write the create statement to an external sql file.
Note, you can also highlight multiple objects at the same time, so you could generate one script that contains create statements for all tables within the database.
In Oracle the location that contains information about all database objects including tables and stored procedures is called the Data Dictionary. It is a collection of views that provides you with access to the metadata that defines the database. You can query the Data Dictionary views for a list of desired database objects and then use the functions available in dbms_metadata package to get the DDL for each object. Alternative is to investigate the support in dbms_metadata to export DDLs for a collection of objects.
For a few pointers, for example to get a list of tables you can use the following Data Dictionary views
user_tables contains all tables owned by the user
all_tables contains all tables that are accessible by the user
and so on...
use the dbms_metadata package, as described here
This worked for me:
PL SQL Developer -> Tools -> Export User Objects
Select checkboxes: Include privilege and Include storage
Select your file name. Hit export.
You can later use generated export file to create table in another schema.
step 1. select * from <tablename>;
step 2. just right click on your output(t.e data) then go to last option export it will give u some extension then click on your required extension then apply u will get new file including data.
The basic answer appears to be 'use the dbms_metadata package'. The axuilliary question is:
But what if I want to generate a script for all the tables at a time?
And the answer, presumably, is to interrogate the system catalog for the names and owners of all the tables:
SELECT dbms_metadata.get_ddl('TABLE', s.tabname, s.tabowner)
FROM system_catalog_describing_tables AS s
WHERE ...any conditions that are needed...
I'm not sufficiently familiar with Oracle to know the system catalog. In Informix, which I do know, assuming that there was a procedure dbms_metadata.get_ddl, the query would be:
SELECT dbms_metadata.get_ddl('TABLE', s.tabname, s.owner)
FROM "informix".systables AS s
WHERE tabid >= 100 AND tabtype = 'T';
In Informix, tabids less than 100 are reserved for the system catalog, and non-tables (views, synonyms, sequences and a few other esoteric things) are excluded by requiring the right 'tabtype'.
I did not know about DMBS_METADATA, but your answers prompted me to create a utility to script all objects owned by an Oracle user.
Oracle SQL Developer > View > DBA > Select your connection > Expand > Security > Users > Right click your user > Create like > Fill in fields > Copy SQL script > Close
If your user has object privileges, do this also
Oracle SQL Developer > View > DBA > Select your connection > Expand > Security > Users > Double click your user > Object Privs > Select all data > Right click > Export > Export as text file
Edit that text file to grant object privileges to your user.

Resources