PL/SQL Record Type to XMLType
Hi,
I wanted to convert a pl/sql record type automatically with just one command using xmltype.createXML but I am wondering if anyone out there has used it this way or whether it is possible. I can't find any examples anywhere, and I didn't really want to do the hard work of doing it one element at a time using xmlelement & xmlattributes :-).....
e.g.,
l_record emp%rowtype;
l_xml xmltype;
begin
for l_record in (select * from emp)
loop
l_xml := xmltype.convertXML (l_record) ; --> is this possible?? I can do it on a cursor but it doesn't seem to like it if its a record type
end loop;
Thanks in anticipation.
M
Edited by: user12097147 on 3/11/2009 16:48
You cannot pass just any record structure to a procedure and expects it to determine its structure and contents and give you XML in return.
Also when you call XMLTYPE(), you are essentially instantiating an object - and calling the constructor method of that class. There are a number of constructors that have different parameter signatures.
If you want XML from a table, then you should be using XML functions.. in the following fashion (there's a number of approaches you can use, depending on your requirements) :
SQL> select xmlElement( "Employee", xmlForest(e.empno, e.ename,e.job) ) as XML from emp e order by e.empno;
XML
<Employee><EMPNO>7369</EMPNO><ENAME>SMITH</ENAME><JOB>CLERK</JOB></Employee>
<Employee><EMPNO>7499</EMPNO><ENAME>ALLEN</ENAME><JOB>SALESMAN</JOB></Employee>
<Employee><EMPNO>7521</EMPNO><ENAME>WARD</ENAME><JOB>SALESMAN</JOB></Employee>
<Employee><EMPNO>7566</EMPNO><ENAME>JONES</ENAME><JOB>MANAGER</JOB></Employee>
<Employee><EMPNO>7654</EMPNO><ENAME>MARTIN</ENAME><JOB>SALESMAN</JOB></Employee>
<Employee><EMPNO>7698</EMPNO><ENAME>BLAKE</ENAME><JOB>MANAGER</JOB></Employee>
<Employee><EMPNO>7782</EMPNO><ENAME>CLARK</ENAME><JOB>MANAGER</JOB></Employee>
<Employee><EMPNO>7788</EMPNO><ENAME>SCOTT</ENAME><JOB>ANALYST</JOB></Employee>
<Employee><EMPNO>7839</EMPNO><ENAME>KING</ENAME><JOB>PRESIDENT</JOB></Employee>
<Employee><EMPNO>7844</EMPNO><ENAME>TURNER</ENAME><JOB>SALESMAN</JOB></Employee>
<Employee><EMPNO>7876</EMPNO><ENAME>ADAMS</ENAME><JOB>CLERK</JOB></Employee>
<Employee><EMPNO>7900</EMPNO><ENAME>JAMES</ENAME><JOB>CLERK</JOB></Employee>
<Employee><EMPNO>7902</EMPNO><ENAME>FORD</ENAME><JOB>ANALYST</JOB></Employee>
<Employee><EMPNO>7934</EMPNO><ENAME>MILLER</ENAME><JOB>CLERK</JOB></Employee>
14 rows selected.
Similar Messages
-
Dbms_xmlgen using pl-sql record type
Hi
I want to pass pl-sql record type and want to generate xml. Can dbms_xmlgen access pl-sql record type instead of query?
OR please let me know any other package to pass pl-sql record type and generate XML.
Thanks in advanceCan dbms_xmlgen access pl-sql record type instead of query?Don't think so, but can't you pass the individual record components:
SQL> declare
type rec is record
a int,
b varchar2 (30)
r rec;
ctx int;
x xmltype;
begin
r.a := 1;
r.b := 'Michael';
ctx := dbms_xmlgen.newcontext ('select :x id, :y name from dual');
dbms_xmlgen.setbindvalue (ctx, 'x', r.a);
dbms_xmlgen.setbindvalue (ctx, 'y', r.b);
x := dbms_xmlgen.getxmltype (ctx);
dbms_output.put_line (x.getstringval ());
dbms_xmlgen.closecontext (ctx);
end;
<ROWSET>
<ROW>
<ID>1</ID>
<NAME>Michael</NAME>
</ROW>
</ROWSET>
PL/SQL procedure successfully completed.? -
Can you confirm for me please? - jdbc to pl/sql record types
Hi, I was hoping somebody could confirm the following please? I've been researching this in the Oracle JDBC docs and the Internet, but would feel more comfortable if somebody would confirm my findings.
I have a 10g database pl/sql procedure that takes a pl/sql record type as both IN and OUT parameter. I'm not allowed to modify this legacy procedure, though I may create new supporting code.
My research shows there is no inherit support in JDBC for Oracle pl/sql record types as per the Oracle JDBC docs.
As a solution, if the procedure only returned a record type, my understanding is I could create a ref cursor in pl/sql, as well as a wrapper procedure that calls my original procedure, and returns the record type through the ref cursor. This could then be used by my JDBC code as JDBC supports ref cursors as a return type.
However in my case, as the record type is both an IN and OUT parameter of my procedure, my research so far says JDBC support for ref cursors does not allow the writing of value to the ref cursor to be submitted back to the database. Is this correct?
If this limitation exists, as such the better (and only?) solution is to create a shadow pl/sql procedure that takes all the record elements as separate IN OUT parameters and then create a private record based on the record type and pass it to the original procedure.
Is my research here correct? Any help appreciated.
Thanks & regards,
CM.Chris,
As far as I know, PL/SQL record types are not supported in JDBC.
I believe you may be able to use TopLink.
I think Kuassi Mensah may have some examples in his book Oracle Database Programming.
Alternatively, you could use an Oracle object instead of a PL/SQL record.
This would be similar to what you are suggesting except that instead of a ref cursor, you would transfer the PL/SQL record to an Oracle object.
Good Luck,
Avi. -
Any way to encode/decode PL/SQL record types ?
Hello everyone,
I came to XDK because I was looking for an easy way or working around a JDBC driver limitation. Namely that it does not access PL/SQL record types. I thought the best way was to encode my package's public types into XML streams and wrap up each public routine into a set of routines receiving and exporting data in XML.
I installed XDK 9i/PL/SQL yesterday and tried it on my 8.1.6 db. So far so good.
However, I did not see anything that does not access directly the database. The only preocupation of XSU is to access directly the DB for a variety of select, insert...
Am I wrong ?
I'm looking for a routine that takes an XML varchar, a DTD varchar and some description of my type (to map tags to fields) and parses the whole thing...
Is there anything I could use to do that ???
Thanks in advance...
AlainMarwim wrote:
You code should be instrumented. Whenever you need to debug/trace you switch it on and get a log fileor log table; it maybe a database parameter or simply a package variable, which you can set at runtime.
This will allow you to debug a production environment where you should never be allowed to change the code or to use adebugger.And very valuable advice this is...
Debugging needs to be part and parcel of a code unit (like a PL/SQL package), where you can execute it (in production or anywhere else) and tell it "+go forth, execute, and debug thyself+". -
Return rows from pl-sql record type
We have a requirement to create function which returns cursor to java application. This cursor will have data from pl-sql record type.
Tried with pipelined function. I have written code below.
CREATE or replace PACKAGE test_pkg IS
TYPE tp_rec IS RECORD(tt_id INTEGER,tt_text VARCHAR2(40));
TYPE obj_tp_recs IS TABLE OF tp_rec;
TYPE obj_tp_recs1 IS TABLE OF tp_rec;
FUNCTION test_func RETURN tp_rec;
function type_out return obj_tp_recs1 PIPELINED;
PROCEDURE test_type (result out sys_refcursor);
END;
CREATE OR REPLACE PACKAGE BODY OMS.test_pkg IS
FUNCTION test_func RETURN tp_rec
AS
currec tp_rec;
BEGIN
currec.tt_id := 1;
currec.tt_text := 'test1';
END;
FUNCTION type_out RETURN obj_tp_recs1 PIPELINED
AS
currec1 test_pkg.tp_rec;
begin
currec1 := test_pkg.test_func;
PIPE ROW(currec1);
dbms_output.put_line(currec1.tt_id);
end;
PROCEDURE test_type (result out sys_refcursor)
AS
BEGIN
OPEN RESULT
FOR SELECT * FROM TABLE(test_pkg.type_out());
END;
END;
SQL> VARIABLE x REFCURSOR
SQL> exec test_pkg.test_type(:x);
PL/SQL procedure successfully completed.
SQL> print xThis code returns no data found exeception from function. How to achieve result 1 and test1 from above code?
Thanks in advanceSQL> VARIABLE x REFCURSOR
SQL> exec test_pkg.test_type(:x);
PL/SQL procedure successfully completed.
SQL> print x
ERROR:
ORA-06503: PL/SQL: Function returned without value
ORA-06512: at "SCOTT.TEST_PKG", line 8
ORA-06512: at "SCOTT.TEST_PKG", line 14
no rows selectedIf you look at test_func body it is missing return statement. Now:
SQL> CREATE OR REPLACE PACKAGE BODY test_pkg IS
2 FUNCTION test_func RETURN tp_rec
3 AS
4 currec tp_rec;
5 BEGIN
6 currec.tt_id := 1;
7 currec.tt_text := 'test1';
8 RETURN currec;
9 END;
10
11 FUNCTION type_out RETURN obj_tp_recs1 PIPELINED
12 AS
13 currec1 test_pkg.tp_rec;
14 begin
15 currec1 := test_pkg.test_func;
16 PIPE ROW(currec1);
17 dbms_output.put_line(currec1.tt_id);
18 end;
19
20 PROCEDURE test_type (result out sys_refcursor)
21 AS
22 BEGIN
23 OPEN RESULT
24 FOR SELECT * FROM TABLE(test_pkg.type_out());
25
26 END;
27 END;
28 /
Package body created.
SQL> exec test_pkg.test_type(:x);
PL/SQL procedure successfully completed.
SQL> print x
TT_ID TT_TEXT
1 test1
SQL> SY. -
PL/SQL Record Type and Toplink
Can i call PL/SQL procedure having a parameter of record type in toplink. If yes, how it is possible?
Hi,
Record defines a representation of a database row as field=>value pairs.Whenever a query is exceuted the rows in the result set can be accessed thru RECORD interface.Can you be more elaborate on the question.
Are you trying to access the result set obtained after executing the Stored Proc using Record interface or you want to pass the Record as input parameter to Stored proc? -
We have a procedure in a package,this procedure makes use of a Record Type.
In BPEL, whiile creating the partner link, when we are trying to access this procedure we get the following error.
"WSDLException:faultCode=OTHER_ERROR:Database type is either not supported or is not implemented.
Parameter L_ECO_REC is of type SAN_REC_TYPE which is either not supported or not an implemented data type.
Check to ensure that the type of the parameter is one of the supported datatypes or that there is a collection or user defined type definition representing this type defined in the database.contact oracle support if error is not fixable."
Also please find below the package specification and body:
CREATE OR REPLACE package eco_pack is
TYPE San_Rec_Type IS RECORD
( Eco_Name VARCHAR2(10)
, Change_Notice_Prefix VARCHAR2(10)
, Change_Notice_Number NUMBER
, Organization_Code VARCHAR2(3)
PROCEDURE sandeep(l_eco_rec IN eco_pack.San_Rec_Type);
end;
CREATE OR REPLACE package body eco_pack is
PROCEDURE createeco(l_eco_rec IN eco_pack.San_Rec_Type) AS
BEGIN
INSERT
INTO ag_log
VALUES(1, 'ECO name is' || l_eco_rec.eco_name, 1);
COMMIT;
END;
end;
Does BPEl support PL/SQL Record Type, if so how ?
Thanks,
Shivram
.PL/SQL types like RECORD, BOOLEAN and TABLE are not supported in the DB adapter with the current BPEL PM release (as the error message indicates). You can use JPublisher manually to generate an OBJECT type that corresponds with the RECORD. JPublisher will also create a wrapper and conversion APIs to convert between the two. You would then call the wrapper API which takes the OBJECT and then calls the underlying PL/SQL that takes the RECORD.
With the 10.1.2 Phase 2 release of BPEL PM, the DB adapter does all of this for you from within the design time wizard. JPublisher is invoked silently under the covers, the SQL that gets generated is automatically loaded into the database schema. That will create the OBJECT type, wrapper and conversion APIs. An XSD is generated for the wrapper API. Your partner link will invoke the wrapper, not the original API.
Note also that support for BOOLEAN and TABLE was also added. JPublisher generates wrapper APIs that substitute appropriate types for these parameters (e.g. INTEGER for BOOLEAN, Nested Table for TABLE). -
Unable to INSERT PL/SQL record with EXECUTE IMMEDIATE
Hi All,
I am selecting data from a source table and after some modification inserting into a target table. Source and target table name are available at run time. You can say only source table structure is fixed.
I have crated a pl/sql table of type source record and inserting record by record in target table using execute immediate. But I am not able to write
EXECUTE IMMEDIATE string USING pl_sql_table(index); and getting error as
PLS-00457: expressions have to be of SQL types
Please see the part of code below. Is it possible to use FORALL with dynamic sql like
FORALL pl_sql_table.FIRST .. pl_sql_table.COUNT
EXECUTE IMMEDIATE .... pl_sql_table(j); -- Like this.
Please suggest why I am not able to write record here. I also want to replace 'INSERT in a loop' with a single INSERT statement out of the loop, to upload whole pl_sql table into target table in one go.
Thanks,
Ravi
DECLARE
TYPE rec_tab_CMP IS RECORD
model_id NUMBER(38),
absolute_rank NUMBER(5)
v_rec_tab_CMP rec_tab_CMP;
TYPE t_rec_tab_CMP IS TABLE OF v_rec_tab_CMP%TYPE INDEX BY BINARY_INTEGER;
v_records_CMP t_rec_tab_CMP;
rc SYS_REFCURSOR;
v_old_table_name VARCHAR2(30); -- passed from parameter
v_new_table_name VARCHAR2(30); -- passed from parameter
dyn_str VARCHAR2(500);
v_columns_str VARCHAR2(200) := ' model_id, absolute_rank ';
BEGIN
EXECUTE IMMEDIATE 'CREATE TABLE '|| v_new_table_name || ' AS SELECT * FROM ' || v_old_table_name ||' WHERE 1 = 2 ' ;
OPEN rc FOR 'SELECT '|| v_columns_str ||' FROM '|| v_old_table_name;
FETCH rc BULK COLLECT INTO v_records_CMP;
FOR j IN 1..v_records_CMP.COUNT
LOOP
v_records_CMP(j).model_id := 1; -- Do someting here, This thing can be performed in SQL stmt directly.
dyn_str := 'INSERT INTO '|| v_new_table_name ||' ( '|| v_columns_str || ' ) VALUES (:1, :2) ';
EXECUTE IMMEDIATE dyn_str USING v_records_CMP(j).model_id ,
v_records_CMP(j).absolute_rank ;
-- Here in place of two columns I want to use one record like
-- EXECUTE IMMEDIATE dyn_str USING v_records_CMP(j);
-- But it is giving me error like
-- EXECUTE IMMEDIATE dyn_str USING v_records_st(j);
-- PLS-00457: expressions have to be of SQL types
END LOOP;
CLOSE rc;
END;
/You cannot bind PL/SQL record types to dynamic SQL.
Possibly you could work around this by declaring the INDEX-BY table of records at package specification level, e.g.
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
SQL> CREATE PACKAGE package_name
2 AS
3 TYPE tt_emp IS TABLE OF emp%ROWTYPE;
4 t_emp tt_emp;
5 END package_name;
6 /
Package created.
SQL> CREATE TABLE new_emp
2 AS
3 SELECT *
4 FROM emp
5 WHERE 1 = 0;
Table created.
SQL> DECLARE
2 v_table_name user_tables.table_name%TYPE := 'NEW_EMP';
3 BEGIN
4 SELECT *
5 BULK COLLECT INTO package_name.t_emp
6 FROM emp;
7
8 EXECUTE IMMEDIATE
9 'BEGIN ' ||
10 ' FORALL i IN 1 ..package_name.t_emp.COUNT ' ||
11 ' INSERT INTO ' || v_table_name ||
12 ' VALUES package_name.t_emp (i); ' ||
13 'END;';
14 END;
15 /
PL/SQL procedure successfully completed.
SQL> SELECT empno, ename
2 FROM new_emp;
EMPNO ENAME
7369 SMITH
7499 ALLEN
7521 WARD
7566 JONES
7654 MARTIN
7698 BLAKE
7782 CLARK
7788 SCOTT
7839 KING
7844 TURNER
7876 ADAMS
7900 JAMES
7902 FORD
7934 MILLER
14 rows selected.
SQL> -
How create a record type and a pl/sql table of that record type in database
Hi
I want to create a record type and then I want to create a PL/SQL table in the oracle 9i database.
I have done it in PL/SQL block.
But when I am trying to do it in database it is throwing me some error.
Could you please tell me how can I do that?
Regardsuser576726 wrote:
Hi
I want to create a record type and then I want to create a PL/SQL table in the oracle 9i database.
I have done it in PL/SQL block.
But when I am trying to do it in database it is throwing me some error.
Could you please tell me how can I do that?
RegardsRECORD type is supported only in PL/SQL for SQL you need to use OBJECT type. -
Calling oracle API having parameter as record type throughPL/SQL WebService
Hi All,
I dont know whether this is the right forum to put this query, but as i am using a pl/sql web service , putting the query on this forum.
My requirement is to call oracle API which in turh creates a single Invoice(using Ar_Invoice_Api_Pub.create_single_invoice )
But the issue is this API in turn has some of the input parameters as Record type and table type, my concern is how to pass this data(record type or table type) as parameter thorugh java code .. If i use Collection or Hashmap will it work , I dont think so , some intermediate conversion will require.
Subsequently the other requirement is fetch this record/table type data and return it to the java code
Please correct me if i am wrong and suggest a proper solution if anybody is aware off or tried such things before.
Thanks in advance.
Regards,
Anant.Hi,I'm new comer of this world,
I've a pl/sql like this:
package MY_WS_API is
type record_set is ref cursor;
PROCEDURE Get_User_Info(p_user_id VARCHAR2,
p_rep_id VARCHAR2,
p_flag out number,
p_msg out varchar2,
p_recordset out record_set);
end MY_WS_API;
when I using jdeveloper trying to publish it as a webservice, in the step 4 of the wizzard poping me choose the program unit to expose, the PROCEDURE Get_User_Info is not available and told me "Ref cursor Type is not supported due to a jdbc limitation and Ref Cursor Types are only supported for use of return type".
THE QUESTION is:
1.the cursor I used is of return type,I'm not very understanding the "why not" message upon.
2.in such case , need I trans the return cursor into Object[] if have to?
3.any other limitation for generating WS from PL/SQL using jdeveloper?
Thanks! -
How to pass parameter in sql developer for debubing record type
DECLARE
IB_BP_BANK_ACCOUNT_BUF PL/SQL RECORD; ---record type
IP_BP_ID NUMBER;
IOP_ACC_SEQ_NO NUMBER;
OP_ERROR VARCHAR2(200);
BEGIN
IB_BP_BANK_ACCOUNT_BUF := NULL;
IP_BP_ID := NULL;
IOP_ACC_SEQ_NO := NULL;
ORAGTW11.MAINTAIN_BP_BANK(
IB_BP_BANK_ACCOUNT_BUF => IB_BP_BANK_ACCOUNT_BUF,
IP_BP_ID => IP_BP_ID,
IOP_ACC_SEQ_NO => IOP_ACC_SEQ_NO,
OP_ERROR => OP_ERROR
/* Legacy output:
DBMS_OUTPUT.PUT_LINE('IOP_ACC_SEQ_NO = ' || IOP_ACC_SEQ_NO);
:IOP_ACC_SEQ_NO := IOP_ACC_SEQ_NO;
/* Legacy output:
DBMS_OUTPUT.PUT_LINE('OP_ERROR = ' || OP_ERROR);
:OP_ERROR := OP_ERROR;
END;Something like this:
Assuming you have a procedure like this:
CREATE OR REPLACE PROCEDURE abc (p_emp emp%ROWTYPE)
IS
BEGIN
DBMS_OUTPUT.put_line (p_emp.empno);
END;
Then you have to call it from a PL/SQL Block in this way i.e.:
DECLARE
v_emp emp%ROWTYPE;
BEGIN
SELECT *
INTO v_emp
FROM emp
WHERE ROWNUM<=1;
abc(v_emp);
END;
Regards.
Al -
Record type variables in the SQL database trace file
Hi,
I turned on the trace with binds and waits in a ebusiness form and captured the database SQL trace file. It lists the values for the generic datatypes for the call, but does not list the values of record type variables. Is there a way to identify the values of record type variables? The below section lists the procedure call and the values passed. Thanks in advance.
RPC CALL:PROCEDURE APPS.HZ_PARTY_SEARCH.FIND_PARTY_DETAILS(P_INIT_MSG_LIST IN VARCHAR2, P_RULE_ID IN NUMBER, P_PARTY_SEARCH_REC IN PARTY_SEARCH_REC_TYPE, P_PARTY_SITE_LIST IN PARTY_SITE_LIST, P_CONTACT_LIST IN CONTACT_LIST, P_CONTACT_POINT_LIST IN CONTACT_POINT_LIST
, P_RESTRICT_SQL IN VARCHAR2, P_MATCH_TYPE IN VARCHAR2, P_SEARCH_MERGED IN VARCHAR2, X_SEARCH_CTX_ID OUT NUMBER, X_NUM_MATCHES OUT NUMBER, X_RETURN_STATUS OUT VARCHAR2, X_MSG_COUNT OUT NUMBER, X_MSG_DATA OUT VARCHAR2);
RPC BINDS:
bind 0: dty=1 bfp=2ae5927c13c8 flg=08 avl=01 mxl=01 val="T"
bind 1: dty=6 bfp=2ae5927c13f0 flg=00 avl=02 mxl=22 val=8
bind 2: dty=118 bfp=2ae593432e48 flg=00 avl=00 mxl=00 val=00
bind 3: dty=251 bfp=2ae5929ac0b8 flg=00 avl=1944 mxl=00 val=00
bind 4: dty=251 bfp=2ae592d85548 flg=00 avl=5336 mxl=00 val=00
bind 5: dty=251 bfp=2ae592d84d58 flg=00 avl=4984 mxl=00 val=00
bind 6: dty=1 bfp=2ae5927c1550 flg=08 avl=125 mxl=2000 val="exists (select 'x' from hz_parties where party_id =stage.party_id and party_type = 'ORGANIZATION') and party_id <>1002277174"
bind 7: dty=1 bfp=2ae5927c1d50 flg=0a avl=00 mxl=00 val=""
bind 8: dty=1 bfp=2ae5927c1d80 flg=08 avl=01 mxl=01 val="I"
bind 9: dty=6 bfp=2ae5927c1da8 flg=02 avl=00 mxl=22 val=00
bind 10: dty=6 bfp=2ae5927c1de0 flg=02 avl=00 mxl=22 val=00
bind 11: dty=1 bfp=2ae5927c1e28 flg=0a avl=00 mxl=01 val=""
bind 12: dty=6 bfp=2ae5927c1e50 flg=02 avl=00 mxl=22 val=00
bind 13: dty=1 bfp=2ae5927c1e98 flg=0a avl=00 mxl=2000 val=""Hello,
From the sounds of it, when you are adding a child the application is not maintaining the Company's reference to it. For instance, in a 1:M and M:1 relationship, the application seems to be setting only the M:1 part (child to parent) which will cause the database to be updated, but both sides need to be set to keep the cache in synch with the database.
Setting the cache type to be none is not a good idea - it prevents any caching, which will hurt performance and object identity. What instead is recommended is disabling the shared cache using the
toplink.cache.shared.<ENTITY>=false property. This still might not help though if the Company's reference to the child hasn't been set as mentioned above if you are reading Company from the same context you are adding the child.
The Cache is described for TopLink Essentials in the blog at:
http://weblogs.java.net/blog/guruwons/archive/2006/09/understanding_t.html
Best Regards,
Chris -
Still no way to access a PL/SQL package record type ?
Sorry if this is a recurrent question...
Is there still no way to set/retrieve input/output parameters of a PL/SQL package procedure/function through JDBC that is of type RECORD ??????
I'm not considering wrapping up through objects or strings. Rather new versions of JDBC driver.
How about SQLJ (don't know anything about that one. Does it call stored procedures ?
Would it support package stored procedure ?
And RECORD types ?
Just out of curiosity as i'm setting off to breaking up all my types into individual arguments. What a pain !!!!!!!!!
Thx.Thanks for the suggestion.
We were arriving to a similar conclusion...
There is however one BIG reason of being disapointed :
- I did not know that (since I'm only Oracling since January) but objects do not accept attributes the type of which would be defined by refering the type of an existing column :
Such as :
CREATE TYPE type_customer AS OBJECT (
cust_id CUSTOMERS.CUSTOMER_ID%TYPE,
I have no idea why RECORDs can do it but object can't.
To summarize it all we can use RECORDs but they are not seen through JDBC drivers and we can use OBJECTS but they don't map to column types... Unfortunate !
Now to answer your question, at the moment I'm thinking of rewriting the routines rather than wrapping them up. Only around ten of them... So that the tool you mention is not needed.
Just have to proofOfConcept it but that's the latest options we are considering...
Thanks for the pointer I look it up right away...
Alain
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by SQLJ Development ([email protected]):
You could define a Customer Object type and create PL/SQL wrapper procedures/functions that take these as arguments and call your original PL/SQL SP. Unfortunately, right now you would have to do that by hand (JPublisher only gives you a Java representation of the Customer object type) - if there were a tool to generate the Object type and the PL/SQL wrappers, would you expect to use that?
For an example of doing this (albeit in a pedestrian way) see: http://technet.oracle.com/docs/products/oracle8i/doc_library/817_doc/ java.817/a81357/sampcod8.htm#1042848 <HR></BLOCKQUOTE>
null -
PL/SQL Passing record type between two procedures
I have a package and package body as following
My problem is I forgot the syntax to pass the record type between the two procedure.?????
CREATE OR REPLACE PACKAGE Standby_Schedules_Disp
AS
PROCEDURE Get_schedule (test1 OUT VARCHAR2);
PROCEDURE get_test (my_test REF my_sched); DOESN'T WORK?????
END Standby_Schedules_Disp;
CREATE OR REPLACE PACKAGE BODY Standby_Schedules_Disp
AS
PROCEDURE Get_schedule (test1 OUT VARCHAR2)
AS
temp NUMBER;
TYPE my_sched IS RECORD ( my_name VARCHAR2(30) := NULL,
my_age NUMBER := 0);
who_I_am my_sched;
Get_test(my_sched);
BEGIN
test1 := 'aaaaa';
who_i_am.my_name := 'Matthew';
END get_schedule;
PROCEDURE get_test (my_test REF my_sched) DOESN'T WORK?????
AS
BEGIN
END;
END Standby_Schedules_Disp;
/Youv'e declared the my_sched type within the scope of the Get_schedule procedure - it's not visible to the get_test procedure. You have declare the type in the package body if it's only used internally within the package or in the package spec if it can be referenced outside the package:
CREATE OR REPLACE PACKAGE [BODY] Standby_Schedules_Disp
AS
TYPE my_sched IS RECORD (
my_name VARCHAR2(30) := NULL,
my_age NUMBER := 0);I don't understand what you are trying to do with the REF keyword in this context. Having declared the type, you can use it as normal in a parameter spec:
PROCEDURE get_test (my_test IN [OUT] my_sched);You're also trying to call get_test within the declaration section of a program, which you can't do, and get_test also contains no executable code, which is not allowed in PL/SQL. -
Pl/Sql for creating Multiple record type file
Hi all,
I have a scenario where I need to create a flat file that contains two different record types in the same file. Basically, a way of getting both the header record and the corresponding detail records. Following are the details:
Table A (Header Records)
"REC_TYPE" "M_ID" "DATE" "*C_ID*"
1 123 090807 *222*
1 345 090907 *333*
Table B (Detail Records)
"REC_TYPE" "A_NO" "LINE_NO" "*C_ID*"
2 7564 1 *222*
2 4535 2 *222*
2 4656 1 *333*
2 6576 2 *333*
In the output file, the resultset should be as:
222, 123, 090807 (Header Record)
*222, 7564, 1* (Detail Record)
*222, 4535, 2* (Detail Record)
333, 345, 090907 (Header Record)
*333, 4656, 1 (Detail Record)*
*333, 6576, 2 (Detail Record)*
Any input is greatly appreciated.
Thank you!NOT TESTED ! Don't remember when I used loops for the last time. I won't have database access until september (on vacation).
declare
type header_t is record
c_id ... ,
type detail_t is record
c_id ... ,
header_r header_t;
detail_r detail_t;
cursor c_h is select c_id, ...
from ...
order by 1; -- header cursor
cursor c_d is select c_id, ...
from ...
order by 1; -- detail cursor
end_line varchar2(2) := chr(13) || chr(10); -- chr(10) to be used for non Windows
a_separator varchar2(1) := ',';
a_buffer varchar2(32767);
l_buffer constant number := 32767;
f_handle utl_file.file_type;
procedure buffer_put(p_line in varchar2) is
begin
if length(a_buffer) + length(p_line) < l_buffer then
a_buffer := a_buffer || p_line;
else
utl_file.put(f_handle,a_buffer);
a_buffer := p_line;
end if;
end;
function build_header_record(p_record in header_t) return varchar2 is
retval varchar2(4000) := '';
begin
retval := retval || to_char(p_record.c_id) || a_separator;
retval := retval || ... || a_separator;
retval := retval || ... || end_line;
return retval;
end;
function build_detail_record(p_record in detail_t) return varchar2 is
retval varchar2(4000) := '';
begin
retval := retval || to_char(p_record.c_id) || a_separator;
retval := retval || ... || a_separator;
retval := retval || ... || end_line;
return retval;
end;
begin
f_handle := utl_file.fopen ('THE_DIRECTORY','the_file.ext','w',l_buffer);
open c_h;
open c_d;
loop
fetch c_h into header_r;
exit when c_h%notfound;
buffer_put(build_header_record(header_r));
if c_h%rowcount > 1 and (header_r.c_id = detail_r.c_id) then
buffer_put(build_detail_record(detail_r));
end if;
loop
fetch c_d into detail_r;
exit when c_d%notfound or (detail_r.c_id != header_r.c_id);
buffer_put(build_detail_record(detail_r));
end loop;
end loop;
if length(a_buffer) > 0 then
utl_file.put(f_handle,a_buffer);
end if;
utl_file.fflush(f_handle);
utl_file.fclose(f_handle);
end;Regards
Etbin
utl_file.fclose(f_handle); instead of utl_file.fclose;
Edited by: Etbin on 11.8.2009 8:54
Maybe you are looking for
-
How to call webservices deployed in Oracle edentity server from BPEL .
my application requires to call a web service which is deployed on the OES server. This web service will accept user name and password as paremeter and rerurn true if the user is a valid user .
-
The test encountered an error while signing in to Outlook Web App. HTTP code: 200
Infrastructure: Exchange 2010 SP3 RU2 environment on 17 servers worldwide with CAS, MB, HUB and UM roles. Server 2008 R2 VM's on Hyper-V 2008 R2. Trying to run the following command to test OWA connectivity on a server in the same Active Directory do
-
Exporting a single table from an acrobat created form
I created a 5 page document InDesign (CS5.5), On one page I created a table that is 4 columns x 25 rows (with the first row being a header), using the table feature. I then exported to pdf and finalized the form in Acrobat 9.2 Pro. After running the
-
How can I customize my terminal?[SOLVED]
I'm using xterm and /bin/zsh, but it looks ugly. It's a white background with a black text. On debian, I use to right click and hit preferences and went from there. But when I right click it just highlights the shell. How can I customize background c
-
IMPORT PHOTO IN IPHOTO V9.4.2 OS 10.8.2 DOENS'T WORK
Import photo in this configuration doesn't work at all. New photo import seems to be there but you have a road sign instead of picture (see image below). Is it a bug or have you a way to fix it (i have tried all the 4 restauration utility and it does