How to create Nested table in oracle stored procedure(Temp Table)
Hi
I am creating Nested table in stored procedure(Temp Table)
type t_v_tbl_rec is record(cumid number,col1 varchar(50),col2 varchar(50),col3 varchar(50),col4 varchar(50),col5 varchar(50),col6 varchar(50));
type t_v_tbl is table of t_v_tbl_rec index by binary_integer;
V_V_TBL t_v_tbl;
But i can't insert value in to this temp table
Plz help me
What is problem?
SQL>declare
2 type t_v_tbl_rec is record( cumid number,
3 col1 varchar(50),
4 col2 varchar(50),
5 col3 varchar(50),
6 col4 varchar(50),
7 col5 varchar(50),
8 col6 varchar(50) );
9 type t_v_tbl is table of t_v_tbl_rec index by binary_integer;
10 v_v_tbl t_v_tbl;
11 begin
12 v_v_tbl(1).cumid := 1;
13 dbms_output.put_line(v_v_tbl(1).cumid);
14 end;
15 /
1
PL/SQL procedure successfully completed.
Similar Messages
-
Command for "How to find Cursor Size" in Oracle Stored Procedure"
Hi
Can u tell me....
How to find Cursor Size" in Oracle Stored Procedure........
I want command for that........why don't you try select count(*) from your_table;That requires running the same query twice - or rather running two different queries twice. Besides it still doesn't guarantee anything, because Oracle's read consistency model only applies at the statement level (unless you're running in a serialized transaction).
This is such a common requirement - users are wont to say "well Google does it" - it seems bizarre that Oracle cannot do it. The truth is that that Google cheats. Firstly it guesses the number on the basis of information in its indexes and refines the estimate as pages are returned. Secondly, Google is under no onus to kepp all its data and indexes synchronized - two simultaneous and identical queries which touch different Google servers can return different results. Oracle Text works the same way, which is why we can get a count with CTX_QUERY.COUNT_HITS in estimate mode.
Cheers, APC
blog: http://radiofreetooting.blogspot.com
. -
How to create AMDP's for sub stored procedures
Hi,
I am migrating Hana data base procedure to AMDP.
I have HANA DP like below.
procedure1.
call procedure 2.
endof procedure1.
how to create AMDP in this case, i have created AMDP methods for both procedure1 and procedure2 but when i am calling AMDP of stored procedure2 in AMDP of stored procedure1 it's giving sqlscript syntax error since call method is an abap statement.
can any one help me how to achieve this.
Thanks
ViswamurthyDear Viswamurthy,
You cannot use CALL METHOD statements inside an AMDP Method as AMDP methods would not understand ABAP syntax.
You need to use SQLScript CALL statements to call an AMDP method from an other AMDP method like below
METHOD increase_price BY DATABASE PROCEDURE
FOR HDB LANGUAGE SQLSCRIPT
USING cl_demo_amdp_call_amdp=>increase_price_amdp.
call "CL_DEMO_AMDP_CALL_AMDP=>INCREASE_PRICE_AMDP"(
CLNT => :CLNT, INCPRICE => :INCPRICE );
ENDMETHOD.
You can find an example in the below link
ABAP Keyword Documentation
Hope this helps.
Thanks
Sundar -
How to create an EIT in Oracle apps with custom table?
Hi,
I have a custom table in APPS schema where training information is loaded everyday by running a control file.
I've to pick the training end date and status of 5 particular trainings and create an EIT.
When I try to create an EIT which is basically a DFF, in value set I'm not able to find my table.
Please guide me through this as I'm doing this for the first time.Hi Rajesh,
You can do the below steps to achieve your requirement (Code may vary to suit your needs, these are just a hint to approach your solution) :
1. Extract the zip file payload from the incoming module data
Object obj = inputModuleData.getPrincipalData();
Message msg = (Message)obj;
Payload attachment = msg.getMainPayload();
2. Construct a new outgoing payload using DOM resembling the structure that you defined in your design.
XMLPayload xmlpayload = msg.getDocument();
DocumentBuilderFactory factory;
factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.newDocument();
<Create your xml structure using DOM APIs>
// Transforming the DOM object to Stream object.
TransformerFactory tfactory = TransformerFactory.newInstance();
Transformer transformer = tfactory.newTransformer();
Source src = new DOMSource(document);
ByteArrayOutputStream out = new ByteArrayOutputStream();
Result dest = new StreamResult(out);
transformer.transform(src, dest);
byte[] docContent = out.toByteArray();
3. Set the newly created xml structure as the new main payload
xmlpayload.setContent(docContent);
msg.setMainPayload(xmlpayload);
4. Add the original document (zip file) as an attachment to the main payload.
msg.addAttachment(attachment);
5. Set the modified message to the inputModuleData and return it to the messaging system
inputModuleData.setPrincipalData(msg);
return inputModuleData;
Regards
Bikash -
Creating Sap Crystal Report Through Oracle Stored Procedure Packages
Hi,
1.How we can create crystal report through oracle stored
procedure packages pls tell me the steps through adding command then
tell me the syntax what should i write in command to call the stored
procedure packages or if have some other option then also tell.
2.can
we link stored procedure column to other table column that used in
report.Hi Ganesh,
As this error comes when you are trying to insert non-numeric value into a numeric column in db it seems that your field might be numeric and you are trying to send it as a string in database.
Please check your Store Proc carefully..
Reference Thread: Oracle/PLSQL: ORA-01722
--Dhana -
How can i create a Global Temporary Table inside a Stored Procedure....
Hi...
I need to create a Global Temporary Table inside a Stored
Procedure....
I have no idea how to do that....
Please....if u can send me a sample, send to me....
Thanks a lotTo create a global temporary table inside a stored procedure,
the minimal syntax would be:
CREATE OR REPLACE PROCEDURE procedure_name
AS
BEGIN
EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE table_name'
|| '(column_name NUMBER)';
END procedure_name;
As Todd stated, it would probably be better to create the global
temporary table outside of the procedure:
SQL> CREATE GLOBAL TEMPORARY TABLE table_name
2 (column_name NUMBER);
Table created.
You can also specify things like ON COMMIT PRESERVE ROWS or ON
COMMIT DELETE ROWS.
It may be that there is something else, like a PL/SQL table of
records or a cursor, that would suit your needs better. It is
difficult to guess without knowing what you want to do with it. -
How Create a Global Temporary Table inside a Stored Procedure?
Hi...
I need to create a Global Temporary Table inside a Stored
Procedure....
I have no idea how to do that....
Please....if u can send me a sample, send to me....
Thanks a lotthere are many ways to do this..
one u can use dbms_utility package to run ddl statements like
for ex:
declare
t varchar2(200):='order_no';
v number;
begin
--dbms_utility.exec_ddl_statement('select '||t||' into '||v||'
from
--ordermaster where rownum=1');
dbms_utility.exec_ddl_statement('create table cvt(t number)');
dbms_output.put_line(v);
end;
but the actual method(recommended) involves a bit coding using
dbms_sql package you will find examples on technet or metalink
to use this package..
I hope this helps
Narendra -
Using XI - RFC table and an Oracle stored procedure that returns a cursor.
I need to create an interface using XI between an RFC table and an Oracle stored procedure that returns a cursor. We are on oarcle 9.2 and SP12.
My stored procedure looks something like this:
CREATE OR REPLACE
PROCEDURE testproc_xi2 (p_recordset1 OUT SYS_REFCURSOR,
in_quoteid IN varchar2 )
AS
BEGIN
OPEN p_recordset1 FOR
SELECT q.quote_id,
q.modified_by,
q.quote_status,
q.total_cost
FROM quote q
WHERE q.quote_id = in_quoteid
AND q.total_cost > 0 ;
END testproc_xi2 ;
My RFC has table and one import parameter .
I wanted to know how to create the data type for the ref cursor? and also for the table type in the RFC?
CAN XI handle multi rows coming from a Stored procedure? Are there any other alternative methods if this is not supported?Any pointers to this would be helpful.
I have called a Oracle SP from an RFC before, but that interface had one input parameter going to the stored procedure from the RFC and about 6 o/p parameters coming from the Stored procedure. This works fine.
Thanks for the help.
MalaMala,
i dont think there is anything called an rfc table...RFC stands for remote function call. That in essence would imply you need a rfc to jdbc connection.
yes XI can handle multiple rows cooming from the the stored procedure if you have them mapped appropriately.
Now as to how to create the data type within xi , you need to know what fields are going to be returned and whether they are nested and then just create them as you would for an xml
for ex
<Details>
<FirstName>
<LastName>
</Details>
that in xi would be smthing like
Details type of data occurence
FirstName type of data occurence
LastName type of data occurence.
Hope that helps.
If it does dont forget the points..:-) -
How to call oracle stored procedure with OUT parameter?
I create oracle stored procedure in eclipse oepe
PROCEDURE SP_SELECT_ORA (
ID_INPUT IN VARCHAR2,
ID_OUTPUT OUT VARCHAR2,
PASSWD_OUTPUT OUT VARCHAR2,
NAME_OUTPUT OUT VARCHAR2) IS
BEGIN
SELECT EMP_ID, EMP_Passwd, EMP_Name
INTO ID_OUTPUT, PASSWD_OUTPUT, NAME_OUTPUT
FROM family
WHERE EMP_ID = ID_INPUT;
END;
and I try to call the sp in jpa like below,
@NamedNativeQueries({
@NamedNativeQuery(name = "callSelectSP", query = "call SP_SELECT_ORA(?,?,?,?)", resultClass = Members.class)
@Entity
@Table(name="family")
public class Members implements Serializable {
@Id
@Column(name = "EMP_ID")
private String ID;
@Column(name = "EMP_Passwd")
private String Passwd;
@Column(name = "EMP_Name")
private String Name;
==============
@PersistenceContext(unitName="MyFamily")
EntityManager em;
query = em.createNamedQuery("callSelectSP");
query.setParameter(1, ID);
String id_output = null;
String passwd_output = null;
String name_output = null;
query.setParameter(2,id_output);
query.setParameter(3,passwd_output);
query.setParameter(4,name_output);
query.executeUpdate();
member = (Members)query.getSingleResult();
But this query throws exception,
19:55:35,500 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http--127.0.0.1-8080-1) SQL Error: 1465, SQLState: 72000
19:55:35,500 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http--127.0.0.1-8080-1) ORA-01465: invalid hex number
I don't know how. Pls, give me your advice. Thanks in advnace.
Best regardsThank you for your reply, Chris!
I tried this one.
@NamedNativeQueries({
@NamedNativeQuery(name = "callSelectSP", query = "exec SP_SELECT_ORA( ?, :id_output, :passwd_output, :name_output) " , resultClass = Members.class)
@Entity
@Table(name="family")
public class Members implements Serializable
===================
query = em.createNamedQuery("callSelectSP");
query.setParameter(1, ID);
String id_output = null;
String passwd_output = null;
String name_output = null;
query.setParameter("id_output", id_output);
query.setParameter("passwd_output", passwd_output);
query.setParameter("name_output",name_output);
query.executeUpdate();
On Console hibernate shew the sql and ora # like below,
19:59:25,160 INFO [stdout] (http--127.0.0.1-8080-1) Hibernate: exec SP_SELECT_ORA( ?, ?, ?, ?)
19:59:25,192 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http--127.0.0.1-8080-1) SQL Error: 900, SQLState: 42000
19:59:25,192 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http--127.0.0.1-8080-1) ORA-00900: Invalid SQL statement
Pls, inform me your advice. Thanks in advance.
Best regards. -
How to Pass parameters to Crystal report 10 based on Oracle Stored Procedur
Hi,
I use the following code to pass the parameters:
Rep.Tables[0].ConnectBuffer := Connection_Str;
Rep.Tables[0].AliasName := 'REP';
Rep.Connect.Propagate := True;
Rep.ParamFields.ByName('Lang', '').CurrentValue := IIF(BiDiMode = bdRightToLeft, '2', '1');
Rep.ParamFields.ByName('SESSION_ID', '').CurrentValue := IntToStr(Session_id);
Rep.WindowState := wsMaximized;
Rep.Show;
The 1st parameter 'Lang' which created from crystal report pass well,
but the 2nd parameter 'SESSION_ID' which created from Oracle Stored Procedures give the following Error:
Error: 202 Parameter Name could not be found u2013 ParamFields.ByName
However in MS SQL Server the above code work fine with the 2 Parameters.
Any one has solution,Hello,
Click on the businessobjects Tab above and then select Samples and dowload the sample app you for your SDK. There are a few samples for changing/setting Parameters.
The Parameter collection has all parameters.
Thank you
Don -
How to create a relational view base on an xmltype table which included sev
Hi,
I am using oracle 11.2.0.1.0.
how to create a relational view base on an xmltype table which content several different .xml files?
Thanks.
for examle:
SQL> SELECT OBJECT_VALUE FROM document;
Edited by: Cow on Jan 6, 2011 7:57 PMFor example I already have these three xml files inserted into the document xmltype table.
These xml files have same schemas. I have attached below.
I want to show all elements/attribute values in xml files to relational view.
Is this possible to create one big relational view to show everything
or I have to create three separate relation views then use UNION to put together? Thanks a lot. Cow
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="http://www.accessdata.fda.gov/spl/stylesheet/spl.xsl" type="text/xsl"?>
<document xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hl7-org:v3 http://localhost:8080/home/DEV/xsd/spl.xsd">
<id root="5ca4e3cb-7298-4948-8cc2-58e71ad32694"/>
</component>
</document>
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="http://www.accessdata.fda.gov/spl/stylesheet/spl.xsl" type="text/xsl"?>
<document xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hl7-org:v3 http://localhost:8080/home/DEV/xsd/spl.xsd">
</component>
</document>
Edited by: Cow on Jan 4, 2011 9:51 AM -
How can I get list of columns used of specific table in all stored procedure?
How can I get used column list of a specific table in among all stored procedure?
Suppose that,
I have a table(VendorMaster) which has 100 columns just I want to know how many columns used in among all stored procedure.We have solved by below query...
IF OBJECT_ID('tempdb.dbo.#SPDependencyDetails') IS NOT NULL
DROP TABLE #SPDependencyDetails
CREATE TABLE #SPDependencyDetails
Or_Object_Database NVARCHAR(128)
,Or_Object_Name NVARCHAR(128)
,Ref_Database_Name NVARCHAR(128)
,Ref_Schema_Name NVARCHAR(128)
,Ref_Object_Name NVARCHAR(128)
,Ref_Column_Name NVARCHAR(128)
,Is_Selected BIT
,Is_Updated BIT
,Is_Select_All BIT
,Is_All_Columns_Found BIT
DECLARE @database_name VARCHAR(100)
DECLARE database_cursor CURSOR
FOR
SELECT name
FROM sys.databases
WHERE database_id =8
OPEN database_cursor
FETCH NEXT FROM database_cursor
INTO @database_name
WHILE @@FETCH_STATUS = 0 --Outer Loop begin
BEGIN
DECLARE @WholeLotofSQL NVARCHAR(MAX) = '
DECLARE @object_name VARCHAR(150)
,@sqlstatement NVARCHAR(2500)
DECLARE object_cursor CURSOR --Inner cursor, iterates list of objects that match type
FOR
SELECT name
FROM '+@database_name+'.sys.objects AS o
WHERE o.type = ''P'' --Change Object type to find dependencies of Functions, Views and etc.
ORDER BY 1
OPEN object_cursor
FETCH NEXT FROM object_cursor INTO @object_name
WHILE @@FETCH_STATUS = 0 --Inner Loop Begin
BEGIN
SET @sqlstatement = ''USE '+@database_name+';
INSERT INTO #SPDependencyDetails
SELECT DB_NAME() AS Or_Object_Database
,'''''' + @object_name + '''''' AS Or_Object_Name
,CASE WHEN referenced_database_name IS NULL THEN DB_NAME()
ELSE referenced_database_name
END AS Ref_Database_Name
,referenced_schema_name AS Ref_Schema_Name
,referenced_entity_name AS Ref_Object_Name
,referenced_minor_name AS Ref_Column_Name
,is_selected
,is_updated
,is_select_all
,is_all_columns_found
FROM sys.dm_sql_referenced_entities(''''dbo.'' + @object_name + '''''', ''''OBJECT'''');''
EXEC sys.sp_executesql @sqlstatement
FETCH NEXT FROM object_cursor INTO @object_name
END
CLOSE object_cursor
DEALLOCATE object_cursor'
EXEC sys.sp_executesql @WholeLotofSQL
FETCH NEXT FROM database_cursor INTO @database_name
END
CLOSE database_cursor;
DEALLOCATE database_cursor;
SELECT Or_Object_Database as 'Database'
,Or_Object_Name as 'Procedure'
,Ref_Object_Name as 'Table'
,Ref_Column_Name as 'Column'
FROM #SPDependencyDetails -
How to create new database on Oracle 10g
Hi All,
Can any one tell me how to create new database on oracle 10g.
Thanks in Advance for your help.again some confusion here.....
u said u need a new database in your first post and now you saying u need a new schema..
one database has many schemas(users)..... ex: scott,sys,system are few of them...
now it depends you need seperate database for test,dev environment - this is in the case u have many schemas under each database and many tables(objects) under each schema.
OR
You just need a separate schema (in same db) for test,dev environment...where in you will have multiple tables in each schema...U need to know the dba credentials of the db to create a new schema.
ideally u need to have different database...You can create one with out sys/system(oracle users) password as these passwords are db dependent.
what you need is access to the any machine where server is installed(can be the same mc where you have your dev db or a diff machine) and that will be the machine where your db will be installed (can do it through database configuration assistance),ofcourse you will need windows authentication for this.
so you login to the same machine or access it from your machine using remote login.
I hope that is clear.Hope i am not listing things that you already know..Just did it coz of confusion between db and schema
Message was edited by:
coolguy -
How to create dynamics columns in oracle query1.
hi,
how to create dynamics columns in oracle query.its very urgent.
regards
prasad..Urgent is it?
Why? Have you forgotten to do your coursework and you'll get thrown off your course if you don't hand it in today?
What makes you believe that your request for help is more important than someone else who has requested help? It's very rude to assume you are more important than somebody else, and I'm sure they would like an answer to their issue as soon as they can get one too, but they've generally been polite and not demanded that it is urgent.
Also, you assume that people giving answers are all sitting here just waiting to answer your question for you. That's not so. We're all volunteers with our own jobs to do. How dare you presume to demand our attention with urgency.
If you want help and you want it answering quickly you simply just put your issue forward and provide as much valuable information as possible.
Looking at your post you haven't told us what database version you are using, you haven't provided any create table DDL's and insert statements to populate that with sample data, and you haven't even shown us that you've had a go at doing something yourself.
You will find if you post on here demanding your post is urgent then most people will just ignore it, some will tell you to get lost, and some will explain to you why you shouldn't post "urgent" requests. Occasionally you may find somebody who's got nothing better to do who will actually provide you with an answer, but you really are limiting your options by not asking properly.
/rant
As a basic example of dyanamic SQL:
DECLARE
cur PLS_INTEGER := DBMS_SQL.OPEN_CURSOR;
cols DBMS_SQL.DESC_TAB;
ncols PLS_INTEGER;
BEGIN
-- Parse the query.
DBMS_SQL.PARSE(cur, 'SELECT hiredate, sal FROM emp', DBMS_SQL.NATIVE);
-- Retrieve column information
DBMS_SQL.DESCRIBE_COLUMNS (cur, ncols, cols);
-- Display each of the column names
FOR colind IN 1 .. ncols
LOOP
DBMS_OUTPUT.PUT_LINE (cols.col_name);
END LOOP;
DBMS_SQL.CLOSE_CURSOR (cur);
END;
/ -
How to invoke Oracle stored procedures in Web Intelligence Custom SQL ?
Hi,
Referring to some older posts, I see that there is a work around to invoke a stored procedure to return results for a Web Intelligence report. Its been posted for calling a MS SQL stored proc, whereas the mentioned method does not seem to work for an Oracle Stored Procedure.
Steps I followed:
a) This is the parameter I have added in the oracle.sbo file => <Parameter Name="Force SQLExecute">Procedures</Parameter>
b) My stored procedure code is as follows:
CREATE OR REPLACE PROCEDURE get_emp_details(var_first_name OUT VARCHAR) AS
BEGIN
SELECT first_name INTO var_first_name
FROM EMP_DETAILS_VIEW
WHERE EMPLOYEE_ID = 100;
END;
c) Custom SQL code I added in my Webi report:
set nocount on;
/* SELECT
EMP_DETAILS_VIEW.FIRST_NAME
FROM
EMP_DETAILS_VIEW
exec get_emp_details;
On trying to validate the SQL it gives me the following error message: "The SQL query has 0 instead of 1 columns.(WIS 10810)"
Has anyone been able to successfully call an Oracle Stored procedure using the above method ?
Version of BO: XI R3 SP2
Oracle version: 11gR2
PS: I am aware that web intelligence since XI R3.1 does allow use of a dedicated Stored Procedure Universe. I would want to know if it could
be made to run in a normal Universe(not a stored procedure Universe)
Thanks for your time and inputs.
Regards,
JezEXECUTE is a SQL Plus command. You can directly call SP in PL/SQL
DECLARE
modif number;
BEGIN
select data_length into modif from user_tab_columns where table_name='CONTROL' and column_name='POSITION';
IF modif < 10 THEN
droptable('CONTROL');
execute immediate('CRETAE TABLE CONTROL ....';
...
Maybe you are looking for
-
How can I tell if an iPhone 5 is locked to a network - without having to try different sims from different networks?
-
Has ANYONE got a printer to work on Time Capsule network?
I've tried two different printers and neither work with Time Capsule. I've checked this community and most state they cannot get the printer to work. Is there any secret to get this working. I just bought Time Capsule and I bought it mainly for pr
-
Require Planned order + Purchase Req. through MRP
Hello Sirs, I have a requirement for following scenario...... I have a FERT which has 2 Components, 1 HALB + 1 ROH (Purchasing Item) When i run MRP (MD02) for FERT, i want Planned Order for HALB + Purchase Requisition for ROH. As at present when i ru
-
9.1.1 just lost all photos - HELP!
Re iPhoto 9.1.1 (527). iPhoto just prompted to convert/update library. Initial message stated that some files were not accessible and asked to repair permissions. Indicated that process could take an hour or more for large libraries, but zipped throu
-
I have a Wi-Fi iPad that I sync with my Mac on a regular basis. I noticed that the clock in my iPad is about 4 minutes fast. The Mac's clock is correct, however, it does not sync the time?? It syncs the time on my old iPod Touch but not the iPad?? Wh