Select into OBJECT TYPE
Gotta run this some folks as it is driving me nuts. Using the nested table types so I have a simple type declared as this....
CREATE OR REPLACE
TYPE MAGIC_ARRAY AS TABLE OF FLOAT;
I want to use a function which gets the values in the table by column attempts to select into the collection......
FUNCTION getMagicNumbers()
RETURN magic_array
IS
v_magic_array magic_array := magic_array();
BEGIN
v_magic_array.extend(10);
select cbe.Field1,
cbe.Field2,
cbe.Field3,
cbe.Field4,
cbe.Field5,
cbe.Field6,
cbe.Field7,
cbe.Field8,
cbe.Field9,
cbe.Field10
INTO v_magic_array
from cbe_magic_number cbe
WHERE ROWNUM=1;
--Return the value
return (v_magic_array);
end getMagicNumbers;
Looks like it should work but I get ORA-00947: not enough values. If I replace the "INTO v_magic_array" with individual indexed values....
INTO v_magic_array(1),
v_magic_array(2),
v_magic_array(3),
v_magic_array(4),
v_magic_array(5),
v_magic_array(6),
v_magic_array(7),
v_magic_array(8),
v_magic_array(9),
v_magic_array(10),
It compiles and works fine. Do I need to use the indexes for the assignment of values all the time?
you need to specifically list the elements by subscript.It seems simpler to just instantiate a new collection in-line in your SQL.
SQL> SET SERVEROUTPUT ON;
SQL> DECLARE
2 FUNCTION getmagicnumbers
3 RETURN magic_array
4 IS
5 v_magic_array magic_array;
6 BEGIN
7 SELECT magic_array (
8 cbe.field1, cbe.field2,
9 cbe.field3, cbe.field4,
10 cbe.field5, cbe.field6,
11 cbe.field7, cbe.field8,
12 cbe.field9, cbe.field10)
13 INTO v_magic_array
14 FROM cbe_magic_number cbe
15 WHERE ROWNUM = 1;
16
17 RETURN v_magic_array;
18 END;
19 BEGIN
20 DBMS_OUTPUT.PUT_LINE (
21 'getmagicnumbers ().COUNT => ' ||
22 getmagicnumbers ().COUNT);
23 END;
24 /
getmagicnumbers ().COUNT => 10
PL/SQL procedure successfully completed.
SQL>
Similar Messages
-
Oracle 10.2.0.5.0
Using Pl/SQL Developer
Hi I'm new to collections, object types etc, so I aologize for any poor wording and missed concepts...
I need to output a ref cursor from my package (for a summary report in SQL Server Reporting Services 2005). The summary report has two fields that come from the database table and 5 calculated fields. My idea for creating the ref cursor is as follows:
1. Define an object type at the schema level
2. Define a table (collection) type at the schema level
3. Define a ref cursor at the package level
4. Using dynamic SQL create a sql statement creating virtual columns for the 5 calculated fields
5. Fetch cursor with dynamic sql into object type one record at a time
6. Calculate the other five field values and update the object for each record processed
7. Add the object 'record' to the table (collection) after each record is processed
8. After the fetch is complete, convert the table to a ref cursor for returning to my application
Here is what I have so far. I have cut out several of the calculated fields for simplicities sake. It is not complete and I don't know how to fetch the database row into the object, nor convert the collection to a ref cursor.
Any help would be greatly appreciated.
create or replace type dlyout.srvCtr_sum_rec_type as object (
zoneNo number,
zonetx varchar2(15),
distNo varchar2(4),
distTx varchar2(30),
numOccr number,
MEError varchar2(1));
create or replace type dlyout.srvCtr_sum_tbl_of_recs is table of srvCtr_sum_rec_type;
CREATE OR REPLACE PACKAGE DLYOUT.REPORTS_PKG is
TYPE CUR IS REF CURSOR;
PROCEDURE testABC(startDate IN date,
endDate IN date,
startTime IN varchar2,
endTime IN varchar2,
zoneNo IN dlyout.loc.zone_no%type,
distNo IN dlyout.loc.dist_cd%type,
CUROUT OUT CUR);
END;
CREATE OR REPLACE PACKAGE BODY DLYOUT.REPORTS_PKG IS
PROCEDURE testABC(startDate IN date,
endDate IN date,
startTime IN varchar2,
endTime IN varchar2,
zoneNo IN dlyout.loc.zone_no%type,
distNo IN dlyout.loc.dist_cd%type,
CUROUT OUT CUR) as
startDateTimeStr varchar2(10) := to_Char(startDate, 'MM/DD/YYYY') ;
endDateTimeStr varchar2(10) := to_Char(endDate, 'MM/DD/YYYY');
startDateTime date := to_date(startDateTimeStr || ' ' || startTime, 'MM/DD/YYYY HH24:MI:SS');
endDateTime date := to_date(endDateTimeStr|| ' ' || endTime, 'MM/DD/YYYY HH24:MI:SS');
distClause varchar2(1000);
sqls varchar2(2000);
zoneClause varchar2(1000) :='';
idx number :=0;
curSrvCtr cur;
srvCtrRec srvCtr_sum_rec_type;
srvCtrTbl srvCtr_sum_tbl_of_recs :=srvCtr_sum_tbl_of_recs();
BEGIN
if zoneNo <> 9999 then
zoneClause := ' and zone_no member of dlyout.reports_common_stuff_pkg.convert_to_collection(zoneNo)';
end if;
if distNo <> '9999' then
distClause := ' and dist_cd member of dlyout.reports_common_stuff_pkg.convert_to_collection(distNo) ';
end if;
sqls := 'select distinct l.zone_no zoneNo, l.zone_tx zoneTx,
l.dist_cd distCd , l.dist_tx distTx, 0 numOccr, '''' MEError
from dlyout.loc l
where l.ts between :startts and :endts ' ||
zoneClause ||
distClause ||
' order by l.zone_no, l.dist_tx ';
open curSrvCtr for sqls using startDateTime, endDateTime;
LOOP
FETCH curSrvCtr INTO srvCtrRec; --ORA:00932 inconsistent datatype expected - got -
EXIT WHEN curSrvCtr%NOTFOUND;
--call other functions to get calculated fields
srvCtrRec.numOccr := dlyout.reports_common_stuff_pkg.Num_Loc_Exc_Mom(startDateTimeStr, endDateTimeStr, starttime, endTime, srvctrRec.distno);
srvCtrRec.MEError := dlyout.reports_common_stuff_pkg.ME_Error(startDateTimeStr, endDateTimeStr, starttime, endTime, srvCtrRec.distNo, null);
dbms_output.put_line(srvCtrRec.distTx || ' ' || srvCtrRec.numoccr|| ' ' || srvCtrRec.MEError);
end loop;
end testABC;
END;
Then I need to add the object to the table. Something like this?
-- add object 'record' to table
srvCtrTbl.extend;
srvCtrTbl.last := srvCtrRec;
Then I am not sure how to do the cast to get the table to a ref cursor. Something like this?
open curout for SELECT *
FROM TABLE (CAST (srvCtrTbl AS srvCtr_sum_tbl_of_recs))
ORDER BY zoneNo, distTx;Ok, so after more research if seems that in 10.2 you cannot assign an object (SQL) type to a ref cursor (PLSQL). SO i changed my direction and used a global temp table - created at the schema level.
Create global temporary table dlyout.srvCtr_summary (
zoneNo number,
zonetx varchar2(15),
distNo varchar2(4),
distTx varchar2(30),
numOccr number,
MEError varchar2(1)
) on commit delete rows;Here is what the procedure looks like now.
PROCEDURE testABC(startDate IN date,
endDate IN date,
startTime IN varchar2,
endTime IN varchar2,
zoneNo IN dlyout.location.zone_no%type,
distNo IN dlyout.location.dist_cd%type,
CUROUT OUT CUR) as
startDateTimeStr varchar2(10) := to_Char(startDate, 'MM/DD/YYYY') ;
endDateTimeStr varchar2(10) := to_Char(endDate, 'MM/DD/YYYY');
startDateTime date := to_date(startDateTimeStr || ' ' || startTime, 'MM/DD/YYYY HH24:MI:SS');
endDateTime date := to_date(endDateTimeStr|| ' ' || endTime, 'MM/DD/YYYY HH24:MI:SS');
distClause varchar2(1000);
sqls varchar2(2000);
zoneClause varchar2(1000) :='';
curSrvCtr cur;
--Still need the PLSQL record type to put in the cursor for the dynamic SQL
type srvCtr_sum_rec_type is record (zoneNo dlyout.location.zone_no%type,
zonetx dlyout.location.zone_tx%type,
distNo dlyout.location.dist_cd%type,
distTx dlyout.location.dist_tx%type,
numOccr number,
MEError varchar2(1));
srvCtrRec srvCtr_sum_rec_type;
BEGIN
--create clauses for dynamic sql by calling other functions
if zoneNo <> 9999 then
zoneClause := ' and zone_no member of dlyout.reports_common_stuff_pkg.convert_to_collection(zoneNo)';
end if;
if distNo <> '9999' then
distClause := ' and dist_cd member of dlyout.reports_common_stuff_pkg.convert_to_collection(distNo) ';
end if;
--here is the dynamic sql
sqls := 'select distinct l.zone_no, l.zone_tx,
l.dist_cd , l.dist_tx, 0, 0,
0, 0, ''''
from dlyout.location l
where l.enrgz_ts between :startts and :endts ' ||
zoneClause ||
distClause ||
' order by l.zone_no, l.dist_tx ';
open curSrvCtr for sqls using startDateTime, endDateTime;
LOOP
--fetch in part of the record
FETCH curSrvCtr INTO srvCtrRec;
EXIT WHEN curSrvCtr%NOTFOUND;
--do the calculations to get the other field values
srvCtrRec.numOccr := dlyout.reports_common_stuff_pkg.Num_Loc_Exc_Mom(startDateTimeStr, endDateTimeStr, starttime, endTime, srvctrRec.distno);
srvCtrRec.MEError := dlyout.reports_common_stuff_pkg.MEC_Error(startDateTimeStr, endDateTimeStr, starttime, endTime, srvCtrRec.distNo, null);
dbms_output.put_line(srvCtrRec.distTx || ' ' || srvCtrRec.numoccr|| ' ' || srvCtrRec.MEError);
--add record to GTT
insert into dlyout.srvCtr_summary(zoneNo, zoneTx, distNo, distTX, numOccr, MEError )
values(srvCtrRec.zoneNo, srvCtrRec.zoneTx, srvCtrRec.distNo, srvCtrRec.distTX, srvCtrRec.numOccr, srvCtrRec.MEError);
end loop;
--open GTT and return ref cursor to app
open curout for SELECT *
FROM srvCtr_summary
ORDER BY zoneNo, distTx;
end testABC; -
Unable to find selection field "object type" in IP19
Hi there,
Is there any way to add the equipment "Object Type" into standard report IP19 as i couldn't find the selection field in the report.
Thanks in advance.
Regards.Calyn Kua,
Here's a work-around:
Go to IP19 and press Multiple Selection button on the Equipment field
In the next popup select the Multiple Selection button again
Select the search-help for Equipment by equipment list
In the next selection screen enter your data including the Technical obj type data and execute the report
Select the equipment in the list as required and select the lower green tick. This should return your equipment numbers back into the IP19 equipment field
Choose the With object list checkbox if required
Execute the IP19 report
Alternatively you can copy the IP19 report and add your own customer-specific fields/logic.
PeteA -
Hi,
I have a problem to get a valid PL/SQL wrapper for the web-service at http://adostest.armstrongconsulting.com/DSX/DocumentServices.asmx?wsdl
I use jpub to generate the web service callout (jar file and pl/sql wrapper) and the generation of that file completes without an error, but if I try to load the pl/sql package into the database it fails, because one of the generated object types has an invalid definition.
-- Create SQL type for oracle.j2ee.ws.common.encoding.literal.AttributeMap
CREATE OR REPLACE TYPE OBJ_AttributeMap AS OBJECT (); The object type for the java class oracle.j2ee.ws.common.encoding.literal.AttributeMap doesn't contain any attributes.
Software used:
-) Latest JPublisher 10g Release 10.2 (http://download.oracle.com/otn/utilities_drivers/jdbc/10201/jpub_102.zip)
-) 10.1.3.1 Callout Utility for 10g and 11g RDBMS (http://download.oracle.com/technology/sample_code/tech/java/jsp/dbws-callout-utility-10131.zip)
-) Oracle DB 10.2.0.3
Command used to generate files:
jpub -proxywsdl="http://adostest.armstrongconsulting.com/DSX/DocumentServices.asmx?wsdl" -proxyopts=noload -package=ados -plsqlpackage=ADOS_WebServiceBTW, I noticed that the dbwsa.jar contains this class, but the "runtime" classes contained in dbwsclientws.jar which are loaded into the database do not contain this class. If I look into the previous version of the Callout Utility (10.1.3.0) at http://download.oracle.com/technology/sample_code/tech/java/jsp/dbws-callout-utility-10R2.zip it is contained in the dbwsclient.jar which is loaded into the database.
What is wrong or what can I do to get a valid object type mapping?
Thanks
PatrickYes. We are calling a .NET web service as well.
I got around the problem by the following steps:
1. Forcing JPub to use the jar files that come with JDeveloper 10.1.3.3, rather than dbwsa.jar and dbwsclientws.jar.
2. Upload the JDeveloper 10.1.3.3 web service libraries into the database
3. Manually edit the JPub wrapper code (static methods) generated by JPub. I have to comment out all references to AttributeMap. Not sure why JPub wants to use it... -
Error Thrown while assinging the value into OBJECT TYPE
Hi Oracle Experts:
i was create one Oracle OBJECT, that object contain only one variable, and i created one function which is return the object(system date), but while i complied that procedure i was thrown the error message like ORA-06530: Reference to uninitilized composite .
can any one tell me how can i use the object variable in the select statement into clause .
Below i pasted my code.
CREATE OR REPLACE TYPE str_batch IS OBJECT
sys_date DATE
CREATE OR REPLACE FUNCTION F_Ln_Getodperd
p_s_actype VARCHAR2,
p_s_acno VARCHAR2,
p_n_bal NUMBER,
p_d_prodt DATE
)RETURN str_batch
IS
lstr_od str_batch ;
BEGIN
SELECT SYSDATE INTO lstr_od.sys_date FROM dual; -- Error(Error message shown in below)
dbms_output.put_line('');
RETURN lstr_od;
END;
Error:
ORA-06530: Reference to uninitilized composite
Thanks in advance
Arun M MHi Mr. Saubhik
Below i Paste my original source code. Still am facing the same problem while i execute the function. can you please tell me the solution for this.
OBJECT :
CREATE OR REPLACE TYPE str_batch IS OBJECT
batchno NUMBER,
batchslno NUMBER,
act_type VARCHAR2(20),
act_no VARCHAR2(20),
curr_code VARCHAR2(10),
amount NUMBER(23,5),
MOD VARCHAR2(10),
drcr VARCHAR2(2),
cheqno VARCHAR2(20),
cheqdt DATE,
sts VARCHAR2(4),
operid NUMBER,
narr VARCHAR2(300),
srno VARCHAR2(10),
rem_type VARCHAR2(10)
Function :
CREATE OR REPLACE FUNCTION F_Ln_Getodperd
p_s_actype IN VARCHAR2,
p_s_acno IN VARCHAR2,
p_n_bal IN NUMBER,
p_d_prodt IN DATE
)RETURN str_batch
IS
lstr_od str_batch ;
-- Variable Declaration
v_n_perd NUMBER;
v_n_lnperd NUMBER;
v_n_mon NUMBER;
v_n_effmon NUMBER;
v_n_instno NUMBER;
v_n_odno NUMBER;
v_n_actual NUMBER(23,5);
v_n_diff NUMBER(23,5);
v_n_inst NUMBER(23,5);
v_d_first DATE;
v_d_exp DATE;
v_d_oddt DATE;
v_d_lastprod DATE;
v_s_instmode VARCHAR2(10);
v_s_inst VARCHAR2(10);
v_s_branch VARCHAR2(10);
v_s_errm VARCHAR2(20000);
BEGIN
SELECT F_Get_Brcode INTO v_s_branch FROM dual;
SELECT pay_c_final,lon_d_expiry, lon_d_lastprod
INTO v_s_inst,v_d_exp, v_d_lastprod
FROM LOAN_MAST
WHERE branch_c_code = v_s_branch AND
act_c_type = p_s_actype AND
act_c_no = p_s_acno;
IF (p_d_prodt > v_d_exp) THEN
SELECT CEIL(MONTHS_BETWEEN(p_d_prodt,v_d_exp)) INTO lstr_od.batchslno FROM dual;
lstr_od.cheqdt := v_d_exp;
SELECT v_d_lastprod - p_d_prodt INTO lstr_od.batchslno FROM dual;
--lstr_od.batchslno = DaysAfter(DATE(ldt_lastprod), DATE(adt_prodt))
ELSE
IF (v_s_inst = 'N') THEN
IF p_d_prodt > v_d_exp THEN
SELECT CEIL(MONTHS_BETWEEN(p_d_prodt,v_d_exp)) INTO lstr_od.batchslno FROM dual;
lstr_od.cheqdt := v_d_exp;
ELSE
lstr_od.batchslno := 1;
END IF;
ELSIF (v_s_inst = 'Y') THEN
SELECT first_d_due,lon_c_instperd,lon_n_perd
INTO v_d_first,v_s_instmode,v_n_lnperd
FROM LOAN_MAST
WHERE branch_c_code = v_s_branch AND
act_c_type = p_s_actype AND
act_c_no = p_s_acno;
SELECT CEIL(MONTHS_BETWEEN(p_d_prodt,v_d_first)) INTO v_n_mon FROM dual;
IF v_n_mon > 0 THEN
SELECT NVL(ln_n_balance,0),NVL(ln_n_instlamt,0),NVL(ln_n_instlno,0)
INTO v_n_actual,v_n_inst,v_n_instno
FROM LOAN_INST_SCH
WHERE act_c_type = p_s_actype AND
act_c_no = p_s_acno AND
ln_d_effdate = (SELECT MAX(ln_d_effdate)
FROM LOAN_INST_SCH
WHERE act_c_type = p_s_actype AND
act_c_no = p_s_acno AND
ln_d_effdate < p_d_prodt);
IF (p_n_bal > v_n_actual) THEN
IF v_n_inst > 0 THEN
lstr_od.batchslno := (p_n_bal - v_n_actual) / v_n_inst;
END IF;
ELSE
lstr_od.batchslno := 1;
END IF;
IF lstr_od.batchslno = 0 THEN
lstr_od.batchslno := 1;
END IF;
--FOR FULL OD
IF (v_n_mon > v_n_lnperd) THEN
lstr_od.batchslno := (v_n_mon - v_n_lnperd) + lstr_od.batchslno;
END IF;
IF v_s_instmode = 'Q' THEN
lstr_od.batchslno := lstr_od.batchslno * 3;
ELSIF v_s_instmode = 'H' THEN
lstr_od.batchslno := lstr_od.batchslno * 6;
ELSIF v_s_instmode = 'Y' THEN
lstr_od.batchslno := lstr_od.batchslno * 12;
END IF;
SELECT p_d_prodt - lstr_od.batchslno INTO lstr_od.cheqdt FROM dual;
IF v_s_instmode = 'M' THEN
v_n_odno := v_n_instno - lstr_od.batchslno; -- TO get OD DATE
SELECT ln_d_effdate
INTO lstr_od.cheqdt
FROM LOAN_INST_SCH
WHERE act_c_type = p_s_actype AND
act_c_no = p_s_acno AND
ln_n_instlno = v_n_odno;
IF SQLCODE = -1 THEN
lstr_od.batchslno := -1;
RETURN lstr_od;
END IF;
END IF;
ELSE
lstr_od.batchslno := 1;
END IF;
END IF;
END IF;
RETURN lstr_od;
EXCEPTION
WHEN OTHERS THEN
v_s_errm := SQLERRM;
dbms_output.put_line(SQLERRM);
lstr_od.batchslno := -1;
RETURN lstr_od;
END;
/ -
How to add elements into Object[][] type of list, in runtime?
I have Object list, ie.
final Object[][] data = {
{"January", new Integer(150) },
{"February", new Integer(500) },
{"March", new Integer(54) },
{"April", new Integer(-50) }
};How can I dynamicly add new elements in it, at the runtime?
Thank you in advance!Do I have to remove 'final' for that, and then add
elements?
No. you can't change an array's size.
You can do this
Object[][] arr = new Object[numRows][numCols];But once you've created it, its size can't change.*
I don't know what you're doing, though, and what actual data you're putting in, but Object[][] holding rows of [String, Integer] is almost certainly a poor data structure. Think about creating a class the represents one "row" here and then create a 1D array of that class.
* Okay, you can kinda sorta effectively "change" the size of second and subsequent dimensions, since a multidimensional array is an array of arrays. I wouldn't recommend it though: int[][] arr = new int[3][2]; // a 3 x 2 rectangular array of int--it's an array of array of int, with 3 "rows", each of which is an array of int with 2 elements.
arr[0] = new int[10]; // now it's a jagged array whose first row has 10 elments instead of 2Here we haven't changed an array's size, just replaced one of its elements, which is also an array, with a new, larger array. -
Cannot SELECT into a user-defined type variable
Hi All,
Oracle 11.2 on Linux.
See the steps below. I am not able to insert/select into a TYPE variable. I do not want to do a TABLE declaration in my PL/SQL block, but want to use a user defined type. Is it possible ?
SQL> create or replace type sample_obj_rec as object
2 (
3 object_id number,
4 object_name varchar2(32),
5 object_type varchar2(32)
6 );
7 /
Type created.
SQL> create or replace type sample_obj_tab as table of sample_obj_rec ;
2 /
Type created.
-- ------------ CASE 1 ---------------------
SQL> declare
2 v_tab sample_obj_tab := sample_obj_tab() ;
3 begin
4 select object_id, object_name, object_type
5 bulk collect into v_tab
6 from dba_objects
7 where rownum < 11 ;
8 end ;
9 /
from dba_objects
ERROR at line 6:
ORA-06550: line 6, column 5:
PL/SQL: ORA-00947: not enough values
ORA-06550: line 4, column 5:
PL/SQL: SQL Statement ignored
-- ------------ CASE 2 ---------------------
SQL> declare
2 v_rec sample_obj_rec;
3 begin
4 select object_id, object_name, object_type
5 into v_rec
6 from dba_objects
7 where rownum = 1;
8 end ;
9 /
from dba_objects
ERROR at line 6:
ORA-06550: line 6, column 5:
PL/SQL: ORA-00947: not enough values
ORA-06550: line 4, column 5:
PL/SQL: SQL Statement ignoredWhat is the issue with both the above cases? what am I missing here?
Thanks in advance.One small detail in the SELECT.
SQL> create or replace type sample_obj_rec as object
2 (object_id number,
3 object_name varchar2(32),
4 object_type varchar2(32));
5 /
Type created.
SQL>
SQL> create or replace type sample_obj_tab as table of sample_obj_rec ;
2 /
Type created.
SQL>
SQL> declare
2 v_tab sample_obj_tab := sample_obj_tab() ;
3 begin
4 select sample_obj_rec(object_id, object_name, object_type)
5 bulk collect into v_tab
6 from dba_objects
7 where rownum < 11 ;
8 end ;
9 /
PL/SQL procedure successfully completed.
SQL> -
Object type error while creating ECR
Hi All
When creating a Engineering change request ECR (T.code: CC31), after entering the change type, selecting the object type(document & material) when i try to save the ECR, i am getting the following error message "is not a valid object type for a task". The error message didnt show in which object type the error is coming, its simply showing the above mentioned message. Could anybody help me in fixing the problem?.
Regards
S.SivakumarHi,
To grant that allways the currenct screens and authorizations were
called please maintain also the value "1" into the "Authorization"
column. For further informations on this maintainance please see the
attached note 375452. It's important that you not enter the mentioned
screen number wihtout the leading "1" as this number is added
automatically by the system (e.g. object MARA 1201 maintain like MARA
201). You can do this in customizing under:
Transaction SPRO
> Cross-Application-Component
> Document Management
> Control Data
> Define screen for object links
If you need the dynpro number or object you will find all standard SAP
objects and their screen number in function module CV130 (Screens) by
transaction SE80. Please maintain all necessary SAP objects.
Best regards,
Christoph -
Dynamically built query on execution How to save the data in Object Type
Hi,
In pl/sql I am building and executing a query dynamically. How can I stored the output of the query in object type. I have defined the following object type and need to store the
output of the query in it. Here is the Object Type I have
CREATE OR REPLACE TYPE DEMO.FIRST_RECORDTYPE AS OBJECT(
pkid NUMBER,
pkname VARCHAR2(100);
pkcity VARCHAR2(100);
pkcounty VARCHAR2(100)
CREATE OR REPLACE TYPE DEMO.FIRST_RECORDTYPETAB AS TABLE OF FIRST_RECORDTYPE;Here is the query generated at runtime and is inside a LOOP
--I initialize my Object Type*
data := new FIRST_RECORDTYPETAB();
FOR some_cursor IN c_get_ids (username)
LOOP
x_context_count := x_context_count + 1;
-- here I build the query dynamically and the same query generated is
sql_query := 'SELECT pkid as pid ,pkname as pname,pkcity as pcity, pkcounty as pcounty FROM cities WHERE passed = <this value changes on every iteration of the cursor>'
-- and now I need to execute the above query but need to store the output
EXECUTE IMMEDIATE sql_query
INTO *<I need to save the out put in the Type I defined>*
END LOOP;
How can I save the output of the dynamically built query in the Object Type. As I am looping so the type can have several records.
Any help is appreciated.
Thankshai ,
solution for Dynamically built query on execution How to save the data in Object Type.
Step 1:(Object creation)
SQL> ED
Wrote file afiedt.buf
1 Create Or Replace Type contract_details As Object(
2 contract_number Varchar2(15),
3 contrcat_branch Varchar2(15)
4* );
SQL> /
Type created.
Step 2:(table creation with object)
SQL> Create Table contract_dtls(Id Number,contract contract_details)
2 /
Table created.
Step 3:(execution Of procedure to insert the dynamic ouput into object types):
Declare
LV_V_SQL_QUERY Varchar2(4000);
LV_N_CURSOR Integer;
LV_N_EXECUTE_CURSOR Integer;
LV_V_CONTRACT_BR Varchar2(15) := 'TNW'; -- change the branch name by making this as input parameter for a procedure or function
OV_V_CONTRACT_NUMBER Varchar2(15);
LV_V_CONTRACT_BRANCH Varchar2(15);
Begin
LV_V_SQL_QUERY := 'SELECT CONTRACT_NUMBER,CONTRACT_BRANCH FROM CC_CONTRACT_MASTER WHERE CONTRACT_BRANCH = '''||LV_V_CONTRACT_BR||'''';
LV_N_CURSOR := Dbms_Sql.open_Cursor;
Dbms_Sql.parse(LV_N_CURSOR,LV_V_SQL_QUERY,2);
Dbms_Sql.define_Column(LV_N_CURSOR,1,OV_V_CONTRACT_NUMBER,15);
Dbms_Sql.define_Column(LV_N_CURSOR,2,LV_V_CONTRACT_BRANCH,15);
LV_N_EXECUTE_CURSOR := Dbms_Sql.Execute(LV_N_CURSOR);
Loop
Exit When Dbms_Sql.fetch_Rows (LV_N_CURSOR)= 0;
Dbms_Sql.column_Value(LV_N_CURSOR,1,OV_V_CONTRACT_NUMBER);
Dbms_Sql.column_Value(LV_N_CURSOR,2,LV_V_CONTRACT_BRANCH);
Dbms_Output.put_Line('CONTRACT_BRANCH--'||LV_V_CONTRACT_BRANCH);
Dbms_Output.put_Line('CONTRACT_NUMBER--'||OV_V_CONTRACT_NUMBER);
INSERT INTO contract_dtls VALUES(1,CONTRACT_DETAILS(OV_V_CONTRACT_NUMBER,LV_V_CONTRACT_BRANCH));
End Loop;
Dbms_Sql.close_Cursor (LV_N_CURSOR);
COMMIT;
Exception
When Others Then
Dbms_Output.put_Line('SQLERRM--'||Sqlerrm);
Dbms_Output.put_Line('SQLERRM--'||Sqlcode);
End;
step 4:check the values are inseted in the object included table
SELECT * FROM contract_dtls;
Regards
C.karukkuvel -
No authorization for number range object type BTI and activity SHOW
Hi All,
When I try to execute
SAP Easy Access screen - > Auto-ID Infrastructure -> Master data -> Number Ranges -> Number Range Administration
on the next web window when I select the object type BTI , it comes up with the error
Number range table not maintained for object BTI in customizing
No authorization for number range object type BTI and activity SHOW
I am using AIN 5.1 . Is this an authorization issue ?. If so which all roles I should give to the user? IF you have any idea about this please share some tips.Hi Sahad,
Only few number range object types are available in the standard system:
Follow the link for help .
http://help.sap.com/saphelp_autoid2007/helpdata/EN/45/e2240c7abb56dde10000000a114a6b/frameset.htm
Follow the for setting up the others.
http://help.sap.com/saphelp_autoid2007/helpdata/EN/45/e2240c7abb56dde10000000a114a6b/frameset.htm -
Does it much matter what you select for "Object Type" when you add and name something to an InDesign library?
Sometimes the name ID Picks for a new library item relates to one of the file types of an element being added to a library.. I don't know whether it actually matters to get the Type right in the eyes of InDesign, or whether that's just for human eyes.
Thoughts/wisdom on this?
Thank you!
wThank you, Mary..that's about what I was theorizing..I'm working a project right now with a library where I thought, "Oh, I'll just toss a few things in here.."
I'm 1/3 through, and have about 50 things, with probably many more to come..
thanks for helping -
In CC01, why can I not add object types
Greetings experts.
We need to add an object type to the list which shows on CC01(2 etc) . The New Entries button is greyed out. Can anyone point me to the reason, or what I need to do to make it active?
thanksHi,
Define a profile in OS59. In the profile under Object type profile (detail) section, click on new entries & select the object types from the list as per your need & then save as a custom profile.
Use this profile on the initial screen of CC01 & then go to Object Types, you should find the object types which you need.
Regards,
Vivek -
How to insert with select in table with object types
I am in the proces of redesigning some tables, as i have upgraded from
personal oracle 7 to personal oracle 8i.
I have constructed an object type Address_type, which is one of the columns
in a table named DestTable.
The object type is created as follows:
CREATE OR REPLACE TYPE pub.address_type
AS OBJECT
Street1 varchar2(50),
Street2 varchar2(50),
ZipCode varchar2(10));
The table is created as follows:
CREATE TABLE pub.DestTable
(id INTEGER PRIMARY KEY,
LastName varchar2(30),
FirstName varchar2(25),
Address pub.address_type);
Inserting a single row is ok as i use the following syntax:
Insert into DestTable(1, '******* ', 'Lawrence', pub.address_type(
'500 Oracle Parkway', 'Box 59510', '95045'));
When i try to insert values into the table by selecting from another table i
cannot do it and cannot figure out what is wrong
I have used the following syntax:
Insert into DestTable
id, name, pub.address_type(Street1, Street2, ZipCode))
select
id, lastname, firstname, street1, street2, ZipCode
from SourceTable;
I have also tried the following syntax:
Insert into DestTable
id, name, pub.address_type(Address.Street1, Address.Street2,Address.ZipCode))
select
id, lastname, firstname, street1, street2, ZipCode
from SourceTable;
What is wrong here ?
nullMagnus,
1. Check out the examples on 'insert with subquery' in http://otn.oracle.com/docs/products/oracle8i/doc_library/817_doc/server.817/a85397/state21b.htm#2065648
2. Correct your syntax that repeated the column definition after "insert into ..."
Insert into DestTable
id, name, pub.address_type(Street1, Street2, ZipCode))
select
id, lastname, firstname, street1, street2, ZipCode
from SourceTable;
Regards,
Geoff
null -
SELECT VALUES FROM OBJECT TYPES
Hi
I want to select values in a object types in a table over the database link.
like
select name from [email protected]
where name is of type varray of varchar2(100)
and db.com is database link.
It is giving me error ORA-22804.
Oracle supports this or not?SQL> var a refcursor
SQL> declare
2 bb emp%ROWTYPE;
3 begin
4 select * into bb from emp where rownum = 1;
5 open :a for select bb.ename ename, bb.empno empno from dual;
6 end;
7 /
PL/SQL procedure successfully completed.
SQL> print a
ENAME EMPNO
SMITH 7369Rgds. -
is there a way to create form fields to tab into and type and or drop down selection fields in pages as you can with microsoft word?
No
Maybe you are looking for
-
trying to reconnect airport express to time machine but express not showing up in base station. unfortunately clicked forgot in airport utility and express no longer shows up. how to reconnect?
-
Posting only possible in periods 2007/09 and 2007/08 in CoCd 1234.
Hello all, I would appreciate some clarification on the following issue. We are getting a error message. It is a Goods movement error log message. This is how it appreas in the system: <b>MT.....Area.....Msg....Item.....Message text</b> E.........M7.
-
Table name for WBS element deleted
If a WBS element is deleted , the corresponding object id which is internally created by the system is also deleted from the PRPS table, Is there a way to find all the deleted WBS elements and what is the table name for the same.
-
Table breaking - More Newbie Q's
http://www.oerica.com/test.htm The text in table cell breaks when it extends past the width of cell. I've tried tabe-layout__fixed, min/max widths, div tag within the table cell. Not sure what I am missing.
-
Dear Gurus I have a scenario as mentioned below please suggest best configuration step by step In Case of additional excise duties J1IH , In case of Capital Goods Credit , SAP system proposes only 50% Credit during the current year. We are also requi