How to generate a report from stored procedure
I would like to generate a report from stored procedure.
I used to work on sql server. this can be done as easy as put a select statement at the end of stored procedure.
The resule can be displayed on the development IDE, like sql developer or consume by Java JDBC client.
is there equivalent way to do this in Oracle stored procedure?
Hi,
What type of report you are looking..for.. ??
As you said that "I used to work on sql server. this can be done as easy as put a select statement at the end of stored procedure. "
When you execute it will return the result set and you will display directly on the FrontEnd.. Is my Understanding is correct Up to here.
See, In oracle you have call some custom stored procedures as you did in SQL Sever, but you have return the Results Sets, with help of Out put paramter, Either Cursors or Varrays..
or Else you can generate the Html reports based on your requirement, HTML can be used in the stored procedures of Oracle which will generate for your, you need to code it.
I could not able get the relevant link for your reference.
I will get back to you on this.
- Pavan Kumar N
Similar Messages
-
Problem while running the report from stored procedure
Hi,
I using stored procedure to generate my report.
my stored procedure's code looks like this.
CREATE OR REPLACE PROCEDURE PROJECTOVERVIEWREPORT1(query in VARCHAR2)
IS
myPlist SRW_PARAMLIST;
myIdent SRW.Job_Ident;
myStatus SRW.Status_Record;
BEGIN
srw.start_Debugging;
myPlist := SRW_PARAMLIST(SRW_PARAMETER('',''));
srw.add_parameter(myPlist,'GATEWAY','http://localhost:8888/reports/rwservlet');
srw.add_parameter(myPlist,'SERVER','rep_kalyan1');
srw.add_parameter(myPlist,'REPORT','BillFormat.RDF');
srw.add_parameter(myPlist,'USERID','atl3_dev_jul04/atl3_dev_jul04@mgi');
srw.add_parameter(myPlist,'destype','file');
srw.add_parameter(myPlist,'desformat','pdf');
srw.add_parameter(myPlist,'documentnumber','17181');
srw.add_parameter(myPlist,'papertype','N');
srw.add_parameter(myPlist,'desname','c:\temp\17181.pdf');
myIdent := srw.run_report(myPlist);
myStatus := srw.report_status(myIdent);
srw.stop_Debugging;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
WHEN OTHERS THEN
NULL;
END PROJECTOVERVIEWREPORT1;
Iam running the oc4j instance and the report server in my local machine.
when i have typed http://localhost:8888/reports/rwservlet
Iam able to see the help page.
My rdf file is placed in OralceHome/reports/integ folder.
Iam executing my stored procedure it is returning some error.
Iam doing any thing wrong.
Do i need to modify anything.
Is the place of rdf file correct.
plz help me solving the above problem.
--KalyanThis is the error message iam getting..
any idea????
* WELCOME TO EVENT-BASED-REPORTING API *
* API-Version : 9i *
* (C) Oracle Corporation, 2000 *
* Debugging turned ON *************************************
*** Length of Paramlist : 1
OK : Parameter added : GATEWAY=http://localhost:8888/reports/rwservlet
*** Length of Paramlist : 2
OK : Parameter added : SERVER=rep_kalyan1
*** Length of Paramlist : 3
OK : Parameter added : REPORT=BillFormat.RDF
*** Length of Paramlist : 4
OK : Parameter added : USERID=atl3_dev_jul04/atl3_dev_jul04@mgi
*** Length of Paramlist : 5
OK : Parameter added : DESTYPE=file
*** Length of Paramlist : 6
OK : Parameter added : DESFORMAT=pdf
*** Length of Paramlist : 7
OK : Parameter added : DOCUMENTNUMBER=17181
*** Length of Paramlist : 8
OK : Parameter added : PAPERTYPE=N
*** Length of Paramlist : 9
OK : Parameter added : DESNAME=c:\temp\17181.pdf
Starting run_report: building url
*** Building URL (RUN_REPORT)
OK : URL built : http://localhost:8888/reports/rwservlet?SERVER=rep%5Fkalyan1&REPORT=BillFormat%2ERDF&USERID=atl3%5Fdev%5Fjul04%2Fatl3%5Fdev%5Fjul04%40mgi&DESTYPE=file&DESFORMAT=pdf&DOCUMENTNUMBER=17181&PAPERTYPE=N&DESNAME=c%3A%5Ctemp%5C17181%2Epdf&statu
*** Submitting HTTP Request
*** using URL :http://localhost:8888/reports/rwservlet?SERVER=rep%5Fkalyan1&REPORT=BillFormat%2ERDF&USERID=atl3%5Fdev%5Fjul04%2Fatl3%5Fdev%5Fjul04%40mgi&DESTYPE=file&DESFORMAT=pdf&DOCUMENTNUMBER=17181&PAPERTYPE=N&DESNAME=c%3A%5Ctemp%5C17181%2Epdf&statusf
ERROR : HTTP request failed -
How to generate a report from crm table to find out user status changes
Dear all,
Could you please help me on generating a report from SAP CRM table level
to find out user status changes in crm orders for a specific period of time?
Thanks in advance,
Regards,
ShaikHi Shaik.
You would not need to write report for this. You need to create a Table view mainenance for the CRMD_ORDERADM_H or CRMD_ORDERADM_I for whichever you need.
Follow the below or search on google for more on table view maintenance.
Go to SE11, give the table name and click on change. Then Go to utilities--> Table maintenance generator.
In the table maintenance generator screen, you should give Authorization Group,
Function Group name (Function Group name can be same as table name),
Maintenance type can be one step or two step, usually you will create with one
step. You should give maintenance screen number. After clicking on create button,
a table maintenance generator will be created.
To check it go to SM30 . In SM30, you find display, Maintain options.
You can view the table contents by choosing Display and supplying the selection criteria of dates.
Regards
Apoorva -
Calling Oracle Reports from stored procedures
Hi ,
Can anybody tell me whether this is possible and if so, how it can be done. Thanks for your help.
Regards,
DeepaOracle Forms allows you to easily integrate Oracle Reports into your
applications. However, on the Macintosh, it is not possible to use
the normal Oracle Reports runtime to generate ASCII text files. In
order to allow ASCII text files to be generated with Oracle Reports
on the Macintosh, the Reports<TEXT> Runtime applications was
developed. This version of the runtime only allows you to generate
text files and should not be used for other purposes.
While the Reports<TEXT> Runtime application has been provided, there
is no built in integration with Forms. This bulletin explains a
method which you can use integrate these two applications with little
effort. In order to use this method, you will need the following
items installed on your computer:
* Oracle Forms 4.0
* Oracle Reports 2.0
* Oracle Command 1.0
* AppleScript 1.1. This is available as part of the Macintosh
Operating System version 7.5 as well as with certain 3rd party
applications.
Because the only way to use the Reports<TEXT> Runtime application is
through Oracle Command, we will be using Oracle Command to run the
Reports<TEXT> Runtime application. However, we need some way to
communicate with Oracle Command which report we would like to run and
what parameters we would like to pass in to Reports. To accomplish
this goal, an AppleScript application will be used. Forms can use
AppleEvents (Apple's method for inter-application communication) to
communicate with this AppleScript application which can then create
an Oracle Command script file to run. So, the summary of events
which will take place are as follows:
1. Forms dynamically creates a command line to run the
Reports<TEXT> Runtime application.
2. Using AppleEvents, Forms communicates this command line to the
AppleScript application which writes out an Oracle Command
script file.
3. The AppleScript application communicates with Oracle Command and
tells it to run the script which it just created.
4. Oracle Command runs the script which invokes the Reports<TEXT>
Runtime application.
1. Creating the AppleScript Application
The core of this solution is the AppleScript Application. While it
is not necessary for you to be familiar with AppleScript, it will
help tremendously in your understanding of how everything works.
Here we provide you with an AppleScript which provides the
functionality we need to implement our procedure.
Note: This AppleScript is designed to work with the Macintosh
Operating System version 7.5. It should work with earlier
versions of the Operating System, but no guarantees are
made. Furthermore, there are known problems with the version
of AppleScript provided with version 7.1.2 of the Operating
System which will cause your machine to crash when this
script is executed. These problems with AppleScript were
corrected for the version 7.5 release of the Operating System.
-- This AppleScript Application is responsible for being a
-- "go-between" between Oracle Forms and Oracle Command. It is
-- responsible for both dynamically creating Oracle Command script
-- files and disposing of these files.
-- NOTE: This AppleScript Application was written for the Macintosh
-- Operating System version 7.5. It has not been tested
-- on any other version of the Macintosh Operating
-- System.
-- Author
-- ======
-- Doug Bitting
-- Oracle Worldwide Technical Support
-- Apple Desktop Products Group
-- Date: 21-MAR-95
-- The syntax "on <<...>> args" is how you setup an AppleScript to
-- accept AppleEvents.
-- Be careful, the << and >> characters are option-\ and option-|
-- respectively. They are not two less-than signs and two
-- greater-than signs.
on <<event R20Trunt>> cmdScript
-- First, let's construct a, hopefully, unique file name
set dt to ((current date) as string)
set hr to (word 5 of dt)
set mn to (word 6 of dt)
set sec to (word 7 of dt)
set fName to (hr * 3600 + mn * 60 + sec as string)
-- For this example, we will put all dynamically constructed
-- script files onto the desktop.
set tFold to (path to desktop)
set fName to (tFold & "tmp." & fName as string)
-- set up a mnemonic for the Return character
set cr to (ASCII character 13)
try
-- open our Oracle Command script file
-- The sequence <opt-l> at the end of the following line
-- should be type in as an option-l (that is, a lowercase L).
set fRef to (open for access file fName with write <opt-l>
permission)
-- Now, write the Oracle Command command line which was
-- passed to us via AppleEvents.
-- The sequence <opt-l> at the end of the following line
-- should be type in as an option-l (that is, a lowercase L).
write (cmdScript & cr) starting at <opt-l>
((get eof fRef) + 1) to fRef
-- Now we have to also ask Oracle Command to let us know
-- when it is finished with the script file we are
-- creating. Basically, we are asking Oracle Command to
-- use AppleEvents to let us know when to throw away the
-- file we are creating
-- The sequence <opt-l> at the end of the following lines
-- should be type in as an option-l (that is, a lowercase L).
write ("host SENDAE aplt R20T remv ---- t \"" & fName <opt-l>
& "\";" as string) starting at <opt-l>
((get eof fRef) + 1) to fRef
-- close the Oracle Command script file
close access fRef
-- Now that we have setup the temporary file,
-- tell Oracle Command to execute it.
tell application "Oracle Command 1.0"
runscript fName
end tell
-- You can put some error handling here if you'd like.
end try
end <<event R20Trunt>>
-- This is the AppleEvent handler to clean up when we are done. It
-- simply throws the temp file into the trash can.
-- Be careful, the << and >> characters are option-\ and option-|
-- respectively. They are not two less-than signs and two
-- greater-than signs.
on <<event R20Tremv>> fName
tell application "Finder"
move (fName as alias) to (path to trash)
end tell
end <<event R20Tremv>>
2. Setting Up Forms
It is useful to setup a PL/SQL Program Unit to hide the details
behind running the Text Runtime. Here is a suggested PL/SQL Program
Unit for you to use:
-- The following procedure is used to hide some of the details in
-- using the AppleScript Application. It accepts 4 arguments:
-- * The report name
-- * The name of the output file
-- * The parameters you would like to pass in. These need to be
-- formatted just as if you were calling reports from a
-- command line.
-- * A connect string for Reports<TEXT> Runtime to connect with.
procedure run_text_report (
rName in char,
oName in char,
params in char,
cString in char) is
cLine varchar2(1000);
begin
cLine := 'execute r20text module='| |rname;
cLine := cLine | | ' userid='| |cString;
cLine := cLine | | ' paramform=no batch=yes';
cLine := cLine | | ' destype=file desname='| |oname;
cLine := cLine | | ' desformat=dflt.prt '| |params| |';';
host('SENDAE aplt R20T runt ---- t "'| |cLine| |'"');
-- NOTE: in the above host() command, the series of quotes at the
-- end reads as follows: double-quote, single-quote, vertical
-- bar, vertical bar, the word cLine, vertical bar, vertical
-- bar, single-quote, double-quote, single-quote.
end;
Here is an example of how I can use the above procedure. In a
WHEN-BUTTON-PRESSED trigger, I might have:
declare
reportName varchar2(16);
outputName varchar2(64);
paramVals varchar2(64);
connectStr varchar2(16);
begin
-- We want to run the report named "myreport". The output from this
-- report should go into a file named "output.txt" located in the
-- "Reports" directory on my hard drive. This report accepts two
-- parameters: p_start_date and p_end_date. The connect string for
-- the database I am using is simply "scott/tiger"
-- Setup some variables to hold all the information I want to pass
-- in to run_text_report(). This information is put into variables
-- for readability.
reportName := 'myreport';
outputName := 'HD:Reports:output.txt';
paramVals := 'p_start_date=''01-MAR-95'' p_end_date=''31-MAR-95''';
connectStr := 'scott/tiger';
-- Run the report
run_text_report(reportName, outputName, paramVals, connectStr);
end;
3. Putting the pieces together
In order for this solution to function, you need to make sure that
both your AppleScript application and Oracle Command are running when
you make a call to run_text_report(). It is possible for you to
launch Oracle Command from within Oracle Forms with the following
line of code:
host('LAUNCHID oBTL');
If you place the above line of code in a WHEN-NEW-FORM trigger, you
can assure that Oracle Command will be running when your form is
launched.
It is also possible for you to have Oracle Forms launch your
AppleScript application. However, in order for you to do this, you
need to be very familiar with the Macintosh Operating System, how to
change the creator type of a file, and know what effects that change
can produce. If you do not know how to change the creator type of
your AppleScript application or are not comfortable doing so, you
should simply document that your users need to make sure to launch
your AppleScript application before trying to use your Form.
However, if you know how to change the creator type of your
AppleScript application and are comfortable doing so, here are the
steps you will need to take to have Oracle Forms launch your
AppleScript application for you:
* Change the creator type of your AppleScript application to
something unique.
* Modify the run_text_report() procedure. You need to change the
four character sequence "aplt" found in the host() command to the
new creator type of your AppleScript application.
* Add the line host('LAUNCHID <your new creator type>'); to your
WHEN-NEW-FORM trigger or to whichever trigger you placed the
host('LAUNCHID oBTL'); statement.
There is one significant difference between RUN_PRODUCT and this
solution. With RUN_PRODUCT, you have the option of specifying
whether or not the call should be synchronous or asynchronous.
However, the call to run_text_report() will always be asynchronous.
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Deepa Pai:
Hi ,
Can anybody tell me whether this is possible and if so, how it can be done. Thanks for your help.
Regards,
Deepa <HR></BLOCKQUOTE>
null -
How to generate a report from data entered by users in XML forms
hi,
i have a requirement to generate report from xml forms which are created using XML forms Builder and stored in Km folders. management want to see in a single report all the activities of all the users in the xml form in such a way that one row in the report presents data blongs to each user. i have no idea regarding this.
can any one help me in detail.
Thanking you in adavance
sajeerHi Sajeer,
You have given quite few information what data should be collected / showed in detail. Anyhow, it sounds as if you want to provide data which isn't provided within the standard portal so far (see http://help.sap.com/saphelp_nw2004s/helpdata/en/07/dad131443b314988eeece94506f861/frameset.htm for a list of existing reports).
For your needs you probably have to develop a repository service which reacts on content / property changes and then you would have to log these changes somewhere, for example in a DB. On the other side, you then could implement a report iView which accesses this data and displays it as whished.
Hope it helps
Detlev
PS: Please consider rewarding points for helpful answers on SDN. Thanks in advance! -
How to call 'C' programs from stored procedures?
Hi
Did anybody tried to call 'C' programs
from oracle stored procedures?
If anybody knows, can you please send
how to configure the listener.ora and
tnsnames.ora. If its possible post all the
information from the begining with examples.
thanks....Oracle JDBC did not support return a result set, if you are using Oracle 9i, you can use pipeline function, then using the TABLE() function the get the row.
Good Luck.
Welcome to http://www.anysql.net/en/ -
How to generate CCMS report from ECC system
Hi,
I have implemented CCMS between my SAP ECC system 6.0 and SAP SRM7.0. How can i generate CCMS report for my SRM system from ECC system. Can any one please tell me the steps to configure CCMS between my ECC (CEN) system and SRM 7.0 ABAP system.
Regards,
Pradeep JPradip_jag12 wrote:
> I have implemented CCMS between my SAP ECC system 6.0 and SAP SRM7.0.
>Can any one please tell me the steps to configure CCMS between my ECC (CEN) system and SRM 7.0 ABAP system.
Hi,
Contradicting statements.
However check the link for CCMS Configuration:
http://www.sdn.sap.com/irj/sdn/index?rid=/webcontent/uuid/30237989-0901-0010-70a4-944691eb5e52 [original link is broken]
Ideally the CEN system should be a double stack i.e. best if its a solution manager.
Regards,
Srikishan -
How to get a resultset from Stored Procedures
How to efficiently and portably get resultsets from Oracle stored procedures? Oracle does not seem to follow JDBC standards here. A standard way in Oracle is to use a ref cursor and call getObject() on CallableStatement. However, Oracle seems to get all the data in the resultset in getObject(), which is inefficient and leads to large memory usage when the resultset is large.
Another way in Oracle is to use getCursor() on an OracleCallableStatement, which is efficient but not portable across different application servers. For example, in WebSphere, this OracleCallableStatement is not available if we want WebSphere to manager the datasource.
Any ideas will be greatly appreciated. Please email to [email protected]Oracle JDBC did not support return a result set, if you are using Oracle 9i, you can use pipeline function, then using the TABLE() function the get the row.
Good Luck.
Welcome to http://www.anysql.net/en/ -
How to get return values from stored procedure to ssis packge?
Hi,
I need returnn values from my stored procedure to ssis package -
My procedure look like and ssis package .Kindly help me to oget returnn value to my ssis package
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [TSC]
-- Add the parameters for the stored procedure here
@P_STAGE VARCHAR(2000)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
--SELECT <@Param1, sysname, @p1>, <@Param2, sysname, @p2>
truncate table [INPUTS];
INSERT
INTO
[INPUTS_BASE]
SELECT
[COLUMN]
FROM [INPUTS];
RETURN
END
and i am trying to get the return value from execute sql task and shown below
and i am taking my returnn value to result set variableYou need to have either OUTPUT parameters or use RETURN statement to return a value in stored procedures. RETURN can only return integer values whereas OUTPUT parameters can be of any type
First modify your procedure to define return value or OUTPUT parameter based on requirement
for details see
http://www.sqlteam.com/article/stored-procedures-returning-data
Once that is done in SSIS call sp from Execute SQL Task and in parameter mapping tabe shown above add required parameters and map them to variables created in SSIS and select Direction as Output or Return Value based on what option you used in your
procedure.
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
How to capture return value from stored procedure?
Hi All,
I want to capture the retun values from this procedure to a table - CALL SYS.GET_OBJECT_DEFINITION('SCHEMA_NAME', 'TABLE_NAME').
The below approach is not working -
Insert into STG.STG_DDL
Call SYS.GET_OBJECT_DEFINITION('DWG', 'DWG_SITE')
Could you please have a look on the same?
Thank you,
VijeeshThanks a lot Everyone.
Considering the discussed options, and an approach explained in this thread - -http://scn.sap.com/thread/3291461 , I have written an SQL to build the Alter statements to add the columns & Constrains to table.
The below Query will provide the scripts to build a table in another environment.
select * from (
select TABLE_name,'tbl_Create' column_name, 1 as position, 'CREATE TABLE '|| schema_name ||'.'|| table_name ||' ( DUMMY_CLMN INTEGER);' as SQLCMD
from tableS
where schema_name ='DWG'
and TABLE_name ='DWG_PRODUCTION_VOLUME_TRX'
UNION ALL
-- MASS change of NOT NULL COLUMNS
-- set to NOT NULL - character data type, double, decimal fixed - need the length but not the scale
select TABLE_name,column_name, position + 100, 'ALTER TABLE '|| schema_name ||'.'|| table_name ||' ADD ('||column_name ||' '||data_type_name ||' (' || length ||') NOT NULL) ;' as SQLCMD
from table_columns
where is_nullable = 'FALSE'
and schema_name ='DWG'
and TABLE_name ='DWG_PRODUCTION_VOLUME_TRX'
and data_type_name in ('VARCHAR', 'NVARCHAR', 'DOUBLE')
and scale is NULL
UNION ALL
-- MASS change of NOT NULL COLUMNS
-- set to NOT NULL - character data type, double, decimal fixed - need the length but not the scale
select TABLE_name,column_name, position + 100,'ALTER TABLE '|| schema_name ||'.'|| table_name ||' ADD ('||column_name ||' '||data_type_name ||' (' || length ||') );' as SQLCMD
from table_columns
where is_nullable = 'TRUE'
and schema_name ='DWG'
and TABLE_name ='DWG_PRODUCTION_VOLUME_TRX'
and data_type_name in ('VARCHAR', 'NVARCHAR', 'DOUBLE')
and scale is NULL
UNION ALL
-- set to NOT NULL - DECIMAL (FLOATING POINT)- needs length and scale
select TABLE_name,column_name, position + 100, 'ALTER TABLE '|| schema_name ||'.'|| table_name ||' ADD ('||column_name ||' '||data_type_name ||' (' || length ||','|| scale ||') NOT NULL) ;' as SQLCMD
from table_columns
where is_nullable = 'FALSE'
and schema_name ='DWG'
and TABLE_name ='DWG_PRODUCTION_VOLUME_TRX'
and data_type_name in ('DECIMAL' )
and scale is not null
UNION ALL
-- set to NOT NULL - DECIMAL (FLOATING POINT)- needs length and scale
select TABLE_name,column_name, position + 100, 'ALTER TABLE '|| schema_name ||'.'|| table_name ||' ADD ('||column_name ||' '||data_type_name ||' (' || length ||','|| scale ||') ) ;' as SQLCMD
from table_columns
where is_nullable = 'TRUE'
and schema_name ='DWG'
and TABLE_name ='DWG_PRODUCTION_VOLUME_TRX'
and data_type_name in ('DECIMAL' )
and scale is not null
UNION ALL
-- set to NOT NULL - DECIMAL (FLOATING POINT)- needs length and null scale
select TABLE_name,column_name, position + 100, 'ALTER TABLE '|| schema_name ||'.'|| table_name ||' ADD ('||column_name ||' '||data_type_name ||' (' || length ||') NOT NULL) ;' as SQLCMD
from table_columns
where is_nullable = 'FALSE'
and schema_name ='DWG'
and TABLE_name ='DWG_PRODUCTION_VOLUME_TRX'
and data_type_name in ('DECIMAL' )
and scale is null
UNION ALL
-- set to NOT NULL - DECIMAL (FLOATING POINT)- needs length and null scale
select TABLE_name,column_name, position + 100, 'ALTER TABLE '|| schema_name ||'.'|| table_name ||' ADD ('||column_name ||' '||data_type_name ||' (' || length ||') NOT NULL) ;' as SQLCMD
from table_columns
where is_nullable = 'TRUE'
and schema_name ='DWG'
and TABLE_name ='DWG_PRODUCTION_VOLUME_TRX'
and data_type_name in ('DECIMAL' )
and scale is null
UNION ALL
-- set to NOT NULL - DATE | TIME | SECONDDATE | TIMESTAMP | TINYINT | SMALLINT | INTEGER - don't need length or scale
select TABLE_name,column_name, position + 100, 'ALTER TABLE '|| schema_name ||'.'|| table_name ||' ADD ('||column_name ||' '||data_type_name ||' NOT NULL) ;' as SQLCMD
from table_columns
where is_nullable = 'FALSE'
and schema_name ='DWG'
and TABLE_name ='DWG_PRODUCTION_VOLUME_TRX'
and data_type_name in ('DATE', 'LONGDATE', 'TIME', 'SECONDDATE', 'TIMESTAMP', 'TINYINT', 'SMALLINT', 'INTEGER' )
-- and scale is not null
UNION ALL
-- set to NOT NULL - DATE | TIME | SECONDDATE | TIMESTAMP | TINYINT | SMALLINT | INTEGER - don't need length or scale
select TABLE_name,column_name, position + 100, 'ALTER TABLE '|| schema_name ||'.'|| table_name ||' ADD ('||column_name ||' '||data_type_name ||' ) ;' as SQLCMD
from table_columns
where is_nullable = 'TRUE'
and schema_name ='DWG'
and TABLE_name ='DWG_PRODUCTION_VOLUME_TRX'
and data_type_name in ('DATE', 'LONGDATE', 'TIME', 'SECONDDATE', 'TIMESTAMP', 'TINYINT', 'SMALLINT', 'INTEGER' )
-- and scale is not null
UNION ALL
select table_name, 'PK' AS column_name, 9990, 'ALTER TABLE '||table_name||' ADD CONSTRAINT Primary_key PRIMARY KEY ('||PK_COLUMN_NAME1||
case when PK_COLUMN_NAME2 is null then ' ' else ','|| PK_COLUMN_NAME2 end ||
case when PK_COLUMN_NAME3 is null then ' ' else ','|| PK_COLUMN_NAME3 end ||
case when PK_COLUMN_NAME4 is null then ' ' else ','|| PK_COLUMN_NAME4 end ||');'
from
(SELECT DISTINCT C1.table_name , C1.COLUMN_NAME AS PK_COLUMN_NAME1, C2.COLUMN_NAME AS PK_COLUMN_NAME2, C3.COLUMN_NAME AS PK_COLUMN_NAME3, C4.COLUMN_NAME AS PK_COLUMN_NAME4
FROM (SELECT * FROM CONSTRAINTS WHERE POSITION=1 AND IS_PRIMARY_KEY = 'TRUE') C1
LEFT JOIN (SELECT * FROM CONSTRAINTS WHERE POSITION=2 AND IS_PRIMARY_KEY = 'TRUE') C2
ON C1.table_name = C2.table_name
LEFT JOIN (SELECT * FROM CONSTRAINTS WHERE POSITION=3 AND IS_PRIMARY_KEY = 'TRUE') C3
ON C2.table_name = C3.table_name
LEFT JOIN (SELECT * FROM CONSTRAINTS WHERE POSITION=4 AND IS_PRIMARY_KEY = 'TRUE') C4
ON C3.table_name = C4.table_name
LEFT JOIN (SELECT * FROM CONSTRAINTS WHERE POSITION=5 AND IS_PRIMARY_KEY = 'TRUE') C5
ON C4.table_name = C5.table_name
) PK
where table_name = 'DWG_PRODUCTION_VOLUME_TRX'
UNION ALL
select table_name, 'UK' AS column_name, 9991, 'ALTER TABLE '||table_name||' ADD CONSTRAINT UNIQUE ('||UK_COLUMN_NAME1||
case when UK_COLUMN_NAME2 is null then ' ' else ','|| UK_COLUMN_NAME2 end ||
case when UK_COLUMN_NAME3 is null then ' ' else ','|| UK_COLUMN_NAME3 end ||
case when UK_COLUMN_NAME4 is null then ' ' else ','|| UK_COLUMN_NAME4 end ||');'
FROM
(SELECT DISTINCT C1.table_name , C1.COLUMN_NAME AS UK_COLUMN_NAME1, C2.COLUMN_NAME AS UK_COLUMN_NAME2, C3.COLUMN_NAME AS UK_COLUMN_NAME3, C4.COLUMN_NAME AS UK_COLUMN_NAME4
FROM (SELECT * FROM CONSTRAINTS WHERE POSITION=1 AND IS_PRIMARY_KEY = 'FALSE') C1
LEFT JOIN (SELECT * FROM CONSTRAINTS WHERE POSITION=2 AND IS_PRIMARY_KEY = 'FALSE') C2
ON C1.table_name = C2.table_name
LEFT JOIN (SELECT * FROM CONSTRAINTS WHERE POSITION=3 AND IS_PRIMARY_KEY = 'FALSE') C3
ON C2.table_name = C3.table_name
LEFT JOIN (SELECT * FROM CONSTRAINTS WHERE POSITION=4 AND IS_PRIMARY_KEY = 'FALSE') C4
ON C3.table_name = C4.table_name
LEFT JOIN (SELECT * FROM CONSTRAINTS WHERE POSITION=5 AND IS_PRIMARY_KEY = 'FALSE') C5
ON C4.table_name = C5.table_name
) UK
where table_name = 'DWG_PRODUCTION_VOLUME_TRX'
UNION ALL
SELECT REFERENCED_TABLE_NAME AS table_name,'FK' AS column_name, 9992,
'ALTER TABLE DWG.'||TABLE_NAME||' ADD FOREIGN KEY ( '||COLUMN_NAME||' ) REFERENCES '|| REFERENCED_TABLE_NAME||'('||COLUMN_NAME||' ) ON UPDATE CASCADE ON DELETE RESTRICT;'
FROM REFERENTIAL_CONSTRAINTS
WHERE REFERENCED_TABLE_NAME = 'DWG_SITE'
UNION ALL
select TABLE_name,'tbl_ClmnDrop' column_name, 9995 as position, 'ALTER TABLE '|| schema_name ||'.'|| table_name ||' DROP ( DUMMY_CLMN );' as SQLCMD
from tableS
where schema_name ='DWG'
and TABLE_name ='DWG_PRODUCTION_VOLUME_TRX'
order by position; -
Steps to generate AWR report from Oracle 11g OEM
I have gone through online documentation for generating an AWR report from Oracle 11g OEM but the documentation is more focused on generating the AWR report manually. I would request if there is a link or documentation to go through for generating AWR report from Oracle 11g enterprise manager.
I hope my question is clear.
Please revert with the reply to my query.
RegardsHI ,
Please check following link: Siva Oracle: How to generate AWR Report from OEM Grid
Thank you -
System command execution from stored procedure
Hello World,
How to run System command from stored procedure ?
For example :
Delete a file
running a programm,
Is it possible ?
H.MYears ago I did this by writing an output file with commands into a directory and had a cron job looking for this file. At the end of the run the file was removed.
Never checked if there are other possibilities nowadays.
cu
Andreas -
How to generate a report in pdf from a stored proc
Hi, i need guidance on how to generate a report in pdf from an oracle stored proc.
The environment is oracle 10gas + 10gdb.
On a specific event, a PL/SQL stored procedure is called to do some processing and at the end of the processing to generate report which has to be sent to the printer (and optionally previewed by the user).
Can anyone assist me with this?Hi ,
One 'simple' way is by using the DBMS_SCHEDULER db package and the procedure CREATE_JOB(....) using as job_type the value 'EXECUTABLE'...
Read for further info in 'PL/SQL Packages and Types Reference'.
If you have access to OEM ... you can configure this there using wizard.....
Other way is to use the External Procedure call capabiblity of Oracle DB Server...:
http://www.oracle.com/pls/db102/ranked?word=external+procedure+call&remark=federated_search
My greetings,
Sim -
Crystal Reports 2008 Stored Procedure and Parameters from LOVs
Quite simple report using stored procedure as data source. When editing some of the parameters we get this error when clicking OK to close "This stored procedure parameter can only accept multiple values. Please ensure that Allow Multiple Values is true."
As we all know stored procedure parameters do not access multiple values at all, so this message is very hard to debug. The report does work if we set the 'Allow Multiple Values' to true, but only when using exactly one value for the parameter. We have tried verify database and other things, but cannot find any way around this issue.
All ideas are appreciated as this is stopping us from utilizing the dynamic parameters.
Thanks, StigWe managed to work around the issue by creating a new stored procedure. First we used the same parameter names and changed the data source to the new stored procedure. After renaming the parameter with the issue the problem then was resolved.
Note that another parameter that was earlier affected by this issue in the way that it could not be edited and saved due to the same error message now also works fine. This even if this parameter has not changed names.
Quite a complex situation to debug this. Maybe if the source of the error message is found in the code we could help testing.
Stig -
How to call a sql server stored procedure from oracle
Hi all,
Please anybody tell me how to call a sql server stored procedure from oracle.
I've made an hsodbc connection and i can do insert, update, fetch data in sql server from oracle. But calling SP gives error. when I tried an SP at oracle that has line like
"dbo"."CreateReceipt"@hsa
where CreateReceipt is the SP of sql server and hsa is the DSN, it gives the error that "dbo"."CreateReceipt" should be declared.
my database version is 10g
Please help me how can i call it... I need to pass some parameters too to the SP
thanking youhi,
thank you for the response.
when i call the sp using DBMS_HS_PASSTHROUGH, without parameters it works successfully, but with parameters it gives the following error
ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
[Generic Connectivity Using ODBC][Microsoft][ODBC SQL Server Driver]Invalid parameter number[Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index (SQL State: S1093; SQL Code: 0)
my code is,
declare
c INTEGER;
nr INTEGER;
begin
c := DBMS_HS_PASSTHROUGH.OPEN_CURSOR@hsa;
DBMS_HS_PASSTHROUGH.PARSE@hsa(c, 'Create_Receipt(?,?)');
DBMS_HS_PASSTHROUGH.BIND_VARIABLE@hsa(c,1,'abc');
DBMS_HS_PASSTHROUGH.BIND_VARIABLE@hsa(c,2,'xyz');
nr:=DBMS_HS_PASSTHROUGH.EXECUTE_NON_QUERY@hsa(c);
DBMS_HS_PASSTHROUGH.CLOSE_CURSOR@hsa(c);
end;
Create_Receipt is the sp which requires two parameters.
please give me a solution
thanking you
sreejith
Maybe you are looking for
-
This should be a simple process, but I can't find out how to do it. (I get it to work after hours of trial and error, usually, but this time I'm stuck) I make a Keynote show - beautiful photos, text, etc - but without the music since I've been told t
-
My wife's 3g keeps asking her for a voicemail password. She has never had a password nor does she want one but this keeps happening. Any thoughts?
-
Hello all I'm stuck on this issue. I am calling a sql select function from a page, which runs the following: public function checkFileDownloadHistory(thisVersionNumber:String):void { var sqlText:String = "SELECT * FROM fileHistory WHERE VERSION_NUMBE
-
I wanted to parse a XML gfile and store the data in my defined schema and tables. How can that be done ?
-
QuickTime Logo and question mark on iWeb site!
Hi All I have a podcast page hosted at an external URL. I have got the RSS feeds working, and linking to itunes, but the media file, dispite being in the correct folder does not display on the page. Is there a line of code I need to change. If so I t