Extension of %ROWTYPE variable
Hi all,
Really scratching my head with this one and I'm sure there's a very simple solution.
Reading values into a record which is based upon a system view called v$logmnr_contents
input_rec v$logmnr_contents%ROWTYPE;
I want an output_rec which is based upon this definition but has and extra column called IDX as the first column,
this would be of type NUMBER.
First question, is there a way to use the definition v$logmnr_contents but add this extra column?
Along the lines of...
Declare
v_idx number;
output_rec v_idx, v$logmnr_contents%ROWTYPE;
Also how would I copy input_rec to output_rec without specifying the individual fields in the record?
Hope somone has a solution.
Regards
Dave
PS - This is Oracle 9i if that makes any difference.
Thanks for all the replies.
I've included the procedure below in case anyone else in the future needs to know how to do this.
Thanks
Dave
CREATE OR REPLACE PROCEDURE "LOGMNR"."LOGMNR_DATA"
(p_dict_filename VARCHAR2, p_arc_filename VARCHAR2)
AS
BEGIN
DECLARE
CURSOR
c_logmnr_contents IS
SELECT
logmnr_sequence.nextval as IDX,
V.*
FROM
V$LOGMNR_CONTENTS V
WHERE
v.sql_redo <> ' ' AND
v.operation IN ('INSERT','UPDATE','DELETE'); -- Cursor based upon view v$logmnr_contents but with a sequence used as the first column.
output_rec c_logmnr_contents%ROWTYPE; -- output_rec is mapped to the cursor return definition and is used to update the table.
v_idx NUMBER := 0; -- Records read from View/Cursor
BEGIN
BEGIN
dbms_output.put_line('Truncating materialised data');
EXECUTE IMMEDIATE 'TRUNCATE TABLE logmnr.logmnr_contents'; -- Clean out the table which holds the materialised data.
COMMIT;
END;
DBMS_LOGMNR.ADD_LOGFILE(LogFileName => p_arc_filename,
Options =>dbms_logmnr.NEW);
DBMS_LOGMNR.START_LOGMNR(DictFileName =>p_dict_filename,
options => DBMS_LOGMNR.COMMITTED_DATA_ONLY);
OPEN c_logmnr_contents;
LOOP
FETCH c_logmnr_contents INTO output_rec;
EXIT WHEN c_logmnr_contents%NOTFOUND;
v_idx := v_idx + 1;
INSERT INTO logmnr_contents VALUES output_rec;
END LOOP;
CLOSE c_logmnr_contents;
END;
COMMIT;
DBMS_LOGMNR.END_LOGMNR;
END;
Similar Messages
-
Access fields in a Rowtype variable
Hello!
Is it possible to access dynamically to the fields of a rowtype variable?
For example, I have the following code :
CURSOR cursorName IS
SELECT field1, field2,field3, ..., fieldN FROM myTable;
myVar cursorName%ROWTYPE;
myString := myVar.field1 || ';' || myVar.field2 || ... || myVar.fieldN;
Is it possible tu use a collection such as :
For each field IN myVar
myString := myString || field;
Next
Many thanks for your answers!If the class you specify in the .NET adapter has public properties or fields then it should let you do "Get Property". Make sure the fields are really public and that you have the right class specified for the objects you are accessing.
Basically, if you are storing the objects in a teststand object array, then the elements of the teststand object array are already the same as the elements of the dotnet array. You can just loop based on the number of items in the array and make calls by specifying Locals.myarray[Locals.i] as the class object (for example) when you specify the .NET step inside the loop. Be sure to uncheck the "Create object" checkbox as you want to use the object you are specifying by expression rather than creating a new one.
Hope this helps,
-Doug -
INSERT using a %ROWTYPE variable
In PL/SQL I need to "copy" a row in a table, changing the sequence number in a key and changing a couple of other columns. Most of the 20 or so columns are unchanged. I declare a variable using %ROWTYPE, to hold the entire row, and do a SELECT into it. Then I change the 3 columns, and want to do an INSERT, using the %ROWTYPE variable. But it seems that INSERT does not let me do this - I have to specify all the columns individually. This is tedious, and also means I have to know all the columns, which is bad for maintenance (new columns added in the future). Is there a way to INSERT the entire row? Whay does Oracle not allow this?
Dave E. at McGill Univ.Oracle will allow this....but in Oracle9i and after. Right now you cannot do this in Oracle8i or less.
Gio
null -
Select values from table%ROWTYPE variable into a cursor
I have a stored procedure which has an OUT parameter of table1%ROWTYPE.
In future we might have to add more OUT parameters of table2%ROWTYPE etc. But at any point of time only one will have values.
So instead of having table%ROWTYPE as OUT parameter, can I send these single row ( with variable values) in a cursor, so that declaration part atleast will not change.
Is it possible to select values from table%ROWTYPE variable into a cursor.
cursorOUT IS
SELECT * FROM varREC;
where varREC is table.ROWTYPE variable.
Or which is the better solution in this situation.
Thanks.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. -
Hi all,
IS there any way to compare two %ROWTYPE variables ?
thanksAs far as I know there is not a way to compare them directly but I think the best forum for this is:
Forums Home » Oracle Technology Network (OTN) » Products » Database » SQL and PL/SQL
Discussion of Oracle SQL and PL/SQL issues
PL/SQL
Joel Pérez
http://otn.oracle.com/experts -
Active Content Extension w/ URL Variables
Hi,
I am using the Flash Active Content extension and I need my
.swf to get a variable dynamically from my URL - how do I do
this?I am using the Flash Active Content extension - for more
info:
http://www.adobe.com/go/7c29e252
This extension is a workaround so the user does not have to
click in the flash area to activate it for use, due to the IE
Active Content Update. It uses an external .js file to embed the
.swf file.
What I am asking is if my URL variable changes from
"www.website.com/index.php?myURL=red" to
"www.website.com/index.php?myURL=blue", how do I get the PHP to get
that information? -
PLS-00201 error when declaring ROWTYPE variable
Hi,
I want to declare the rec_ variable like this:
PROCEDURE Insert___ (
objid_ OUT VARCHAR2,
objversion_ OUT VARCHAR2,
new_ IN OUT VARCHAR2,
attr_ IN OUT VARCHAR2 )
IS
rec_ OBUS.ORDER_TAB%ROWTYPE;
where ORDER_TAB belongs to the OBUS schema, a different schema from where the present procedure is being created.
When compiling, I get the following error:
"PLS-00201: identifier 'OBUS.ORDER_TAB' must be declared"
Why do I get this? Can't I refer to a different schema in the declaration area of the procedure?
Thanks.
Leandro.Thank you both. It compiled ok after granting the select privilege.
However, I was able to execute a "select * from obus.order_tab" from a SQLPlus session, no matter if I had granted or not the SELECT privilege for that table.
It seems the behaviour is different in a SQL session from a declaration in a procedure. Am I right? What could be the reason for this?
Thanks.
Leandro. -
Declare custom type as %ROWTYPE variable in package
I am creating a bunch of custom RECORD types in a package specification like so:
CREATE OR REPLACE PACKAGE mypackage AS
TYPE t1 IS RECORD (a number, b number);
...For consistency, I'd like to create a custom package type that uses a table %ROWTYPE, something like this:
TYPE t2 IS RECORD (table%ROWTYPE);Is that possible in any way?
TomHi Tom.
You should read this: http://docs.oracle.com/cd/B10500_01/appdev.920/a96624/05_colls.htm
"The attribute %ROWTYPE lets you declare a record that represents a row in a database table. However, you cannot specify the datatypes of fields in the record or declare fields of your own. The datatype RECORD lifts those restrictions and lets you define your own records."
If you want to create a nested table of that records you can do this:
DECLARE
TYPE RecTab IS TABLE OF dept%ROWTYPE;
dept_recs RecTab;
...If you just need a record this may help you.
DECLARE
dept_rec dept%ROWTYPE;
...Hope this helps.
Regards. -
How to fetch %ROWTYPE OUT param of a stored procedure from Java program?
I have a stored procedure that has IN / OUT parameter as table_name%ROWTYPE.
From a java program how can I access this ROWTYPE variable?
I tried all possible documentation and none of the explains whether or not this is supported.
My use case expect exactly 1 record from the procedure and we would prefer not to use REF CURSOR.
Is there a way to achieve this? If so, can someone help me with it by posting the sample code to achieve this?
I tried all the possible OracleTypes to register the OutParameter and they all fail.
Looks like there isn't any equivalent of %ROWTYPE in OracleTypes either.
If you need, I can post my sample procedure that uses %ROWTYPE as OUT parameter.
I really appreciate your help in this regard.
- KarthikHi,
If "returning only 1 record" the showstopper for not using Ref Cursor, you might want to reconsider because as you probably know, the ref cursor is only a pointer and requires additional step to retrieve the data.
Kuassi -
ORA 04067 %rowtype and "PUBLIC". does not exist
Hi I have an error ORA-04067 for %rowtype in oracle 10g while running a form in turn it is calling a package. But the same thing is running fine with oracle 8i.
Is there any code changes we need to made to upgrade to oracle 10g. Is that not backward compatable to cursors. procedure is using rowtype variables.
can any one tell me the problem while migrating to oracle 10g from oracle 6i.
Basically I am getting two errors I am not sure whether these two are realted or not.
The error is Error code - 4067 and the Error - ORA 04067: not executed, Stored procedure "PUBLIC". does not exist.
We have applied a patch to solve "PUBLIC" issue but form is still not working.
procedure GetInventory
(p_inventory_rec in out INVENTORY%ROWTYPE,
p_lock BOOLEAN,
p_found out boolean,
p_locked out boolean) is
I will really appreciate your help.
Thanks
SandyPerhaps this link can give you some basic idea - i guess ->
db function throws ORA-04067 Procedure does not exist error in forms
Regards.
Satyaki De. -
Getting Output filename and extension same as the incoming filename and extension
I need to create a SFTP send port where I should get the output file name and extension same as that of the incoming filename
I had set the filename in the send port as "%SourceFileName%" but this did not work.
I have also assigned the input filename (without extension) in a variable in orchestartion. Is there any way i could get the output filename and extension same as that of the incoming message?
Any help would be much appreciatedHi,
The %SourceFileName% macro maps to the context property BTS.ReceiveFileName that travels with your message in the context. So in order for this macro to work in a send port the message that is going out needs to have this BTS.ReceiveFileName property on
the context. You probably creating a new message in your orchestration and sending that out. The new message does not have the property on its context which makes it fail. Use a message assignment shape in your orchestration to set the context property for
the message going out:
MyMessage(BTS.ReceiveFileName) = OrigMessage(BTS.ReceiveFileName);
Then %SourceFileName% macro will work at send port.
Rachit
Please mark as answer or vote as helpful if my reply does -
Using ROWTYPE to create undoable record
Does anyone have any insight on how I would perform the following in forms:
Define a %ROWTYPE record
On Each Navigation to a new Record
Store all the record's values in %ROWTYPE variable
An UNDO button on the form would then revert all the values in the current record to the values stored in the %ROWTYPE variable.
I am new to this, I can't even seem to figure out how to define the %ROWTYPE variable, much less populate and revert the form's contents.
Thanks for your help.
MS
null1. Put a trigger on the table that populates the pk with the sequence
2. Change your procedure "PROMOTE" into a function that returns the new id
3. In your function code, use the "returning ... into" clause of an insert statement to get the new id:
create or replace function promote(
p_early_proj_id in number)
return number
is
l_new_id number;
begin
insert into late_project (a,b,c) values (...) returning id into l_new_id;
return l_new_id;
end promote;4. Call your function from a PL/SQL process like this:
:P8_NEW_LATE_PROJ_ID := PROMOTE(p_early_proj_id) ;This technique will also allow you to call this function from technologies other than APEX, instead of burning part of the logic into the APEX code itself.
Tyler -
Multiple use of a shared variable - buffers?
Hi all,
I have an application on a RT target that measured data (around 60 variables stored in a big cluster) in a TCL, sends it via RT-FIFO
(a modified U8-Array buffer that contains the data converted into string and then flattened to U8-Array) to the NTCL which then
writes the data to a file and sends it via TCP/IP to the user interface on a PC.
This is slow. I know that strings should be avoided on RT and especially extensive formatting of variables into strings. I want to
switch over to shared variables now and write files on the PC only.
Problem: I need the data on the RT target as well for control purposes (PID regulation of a cooling system). Can I read the same shared
variable twice, once in the control sub-vi and once on the PC? How does that affect the buffeing of the shared varaible. Does each
"subscriber" gets its own read buffer?
Or should I use a global variable (this will again be a 60 element cluster) on the RT for communication between the read-data-vi, the
control-vi and the send-shared-variable-to-host PC-vi. As I've read, big global variables should be avoided as well on RT-systems.
Or can I use a queue instead of the global variable for the data-cluster?
Cheers,
OlafHey,
Transfering data from a TCL to a NPL (Normal Priority Loop) via RT FIFOs and then via TCP/IP to a Host System has a better performance then a shared variable.
So using shared variables instead of your actual architecture wont result in a better performance. I would suggest to optimize your code.
According to the shared variables behaviour: yes, you can read it at your Host and the RT System at the same time without loosing data when configured as RT FIFO.
Christian -
X-file with db function returning a rowtype to forms. Positional binding?
How to explain this ...
First things first:
Forms [32 bits] Versión 11.1.2.1.0 (Producción)
Oracle Database 11g Release 11.2.0.3.0 - 64bit Production
Now the db testcase:
I've got two schemas, quite similar, SCHEMA_A and SCHEMA_B
Imagine the same table: mytable (colx varchar2, coly varchar2, colz varchar2) in both schemas,
BUT in SCHEMA_B the order of the cols is not the same. In schema B it is
mytable (colx, colz, coly).
(Yeah, I know, I know, but leave it for the sake of the x-file)
Let's suppose the table has only one row, and that I have a db function in both schemas such as this:
function get_myrow return mytable%rowtype is
l_row mytable%rowtype;
begin
select * into l_row from mytable;
return l_row;
end;
Here, the forms testcase:
I make a form, where I show the value in an item
For example:
:item := get_myrow().coly
And now, the x-file:
If I compile the form in the builder, connected as SCHEMA_A, when I run it in SCHEMA_B, the item shows colz value!!
It is as if forms is doing some kind of positional binding in the fmx. Instead of asking for coly column to the record type variable, it shows "the second value" of the record type.
Now, I will have to find this disordered tables and reorder them (dbms_redefinition? hints are welcome).
Any thougts? Bug as feature?About the "select * is problematic" , I agree 99% of the times. But this time, as I'm storing the values in the rowtype variable, is the way to ensure that the estructure and the values fit.
You said:
What happens when your table changes (such as a new column) but your function hasn't been updated? Your Function will produce an error because it can't handle the additional column.
And it's just the opposite. My function will recompile itself, as the rowtype is perfectly capable of storing the values in the new rowtype.
In fact, it's the MLBrown function the one that would produce an error if I change columns in the table, and that's the best case scenario, as the function could be lucky and work storing the values in the wrong places, leaving the bug hidden.
Anyway, I understand this "select *" issue is arguable, so forget about the select * , I'll take it out of this thread with a more simple testcase:
create table mytable (
colx varchar2(10),
coly varchar2(10),
colz varchar2(10));
Consider this "select free" version of the function:
function get_myrow return mytable%rowtype is
l_row mytable%rowtype;
begin
l_row.colx := 'a';
l_row.coly := 'b';
l_row.colz := 'c';
return l_row;
end;
Forget also about schema_a and schema_b, I can reproduce it with just one schema!!!
Now I build a form with just a button. When- button-pressed:
message (get_myrow.coly);
I compile and run it, and I get a b value. ok.
Now I drop the table and recreate but like this:
create table mytable (
colx varchar2(10),
colz varchar2(10),
coly varchar2(10));
Now run the form (without compiling) and see how the message shown is c !!!
The result is different, depending on how whas the rowtype structure when I compiled the fmb.
Are you indeed telling that is acceptable an escenary where I ask for get_myrow().coly value and I get colz value instead?
How's that possible? Because somebody shortcutted in the fmx compiling process, and converted my call for named coly value to a call to "the second column of the record variable".
I'm not asking for a numbered position , I'm asking for coly value, not for "the second column of the rowtype variable the day I compiled the form". Had I want a possitional binding, I'd use a frikkin varray. -
I want the variable AudioFilesNumber to contain the number of files with extension = "CLASS"
the variable does get incremented, but displays on each row.
Is there a way to accumulate the count while readingrecords, then print the total whileprinting records.
StringVar array AudioFiles := ["CLASS","au","mp3","wav","wmf"];
WHILEreadingRECORDS;
NumberVar AudioFilesNumber ;
if {SRMFILE.EXTENSION} = AudioFiles[1] then
AudioFilesNumber := AudioFilesNumber +1;
AudioFilesNumber
Sample output
HOSTNAME FILENAME EXTENSION Nb class files Class files
WPPMD625 vci_7_5_20_en_usa_s.class CLASS 1.00 1
WPPMD625 vci_7_5_20_en_usa.class CLASS 2.00 2
WPPMD625 resource_s.class CLASS 3.00 3
WPPMD625 navresources_s.class CLASS 4.00 4
WPPMD625 stop_iws.class CLASS 5.00 5
WPPMD625 restart_iws.class CLASS 6.00 6
WPPMD625 iws.class CLASS 7.00 7
WPPMD625 UserSaveYesButtonListener.class CLASS 8.00 8Please re-post if this is still an issue or purchase a case and have a dedicated support engineer work with you directly:
http://store.businessobjects.com/store/bobjamer/DisplayProductByTypePage&parentCategoryID=&categoryID=11522300?resid=-Z5tUwoHAiwAAA8@NLgAAAAS&rests=1254701640551
Maybe you are looking for
-
Error while installing Tuxedo 9.1 on Windows vista home premium .
Hi all, I'm trying to install Tuxedo 9.1 on my laptop within Windows vista premium I get this message "This application has unexpectedly quit. Invocation of this Java application has caused an Invocation TargetException. This application will now exi
-
How can I get my phone to switch back to a Canadian network after being in the USA?
I've spent the past week in the states and my phone automatically switches over to AT&T, and usually won't switch back to BELL until i'm well over the Canadian border. This time, though, my phone keeps saying it doesn't have service and won't connect
-
Which is better, Netgear N900 or Airport Extreme?
Which is better, Netgear N900 or Airport Extreme?
-
Open items date and clearing date
Hi, Could any one tell me what are the field names in BSEG table for the "open items date" and "clearing date"? thank u Kaki
-
Hi guys, I have following nested table and I need to perform an update to the BRIDGE_GEOM nested table. Can somebody help me? CREATE TABLE BRIDGE BRIDGE_GEOM MDSYS.SDO_GEOMETRY, MSLINK NUMBER(10) NOT NULL, CREATE INDEX BRIDGE_RTREE_X ON BRIDGE (BRIDG