SQL Types
Hi,
I am trying to retrieve the data type of my column in the ResultSetMetaData but i don�t know how.
This is my code:
for(int x=0;x<c;x++){
out.print("INSERT INTO "+tabela+" (");
for(int z=0;z<meta.getColumnCount();z++){
out.print(meta.getColumnName(z+1));
if(z!=meta.getColumnCount()-1)
out.print(",");
out.print(")");
out.print(" VALUES (");
for(int y=0;y<meta.getColumnCount();y++){
out.print(meta.getColumnType(y+1)); //This is what i want to know.
out.print(dados[x][y]);
if(y!=meta.getColumnCount()-1)
out.print(",");
out.print(")");
out.print(";");
out.print("<br>");
}
I tried what you told me and i got this error:
java.lang.NullPointerException
at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:61)
at org.postgresql.Connection.ExecSQL(Connection.java:398)
at org.postgresql.Connection.ExecSQL(Connection.java:381)
at org.postgresql.Connection.getSQLType(Connection.java:1111)
at org.postgresql.Connection.getPGType(Connection.java:1176)
at org.postgresql.Field.getPGType(Field.java:93)
at org.postgresql.jdbc1.ResultSetMetaData.getColumnTypeName(ResultSetMetaData.java:408)
at _testes._sqlincluir__jsp._jspService(C:\InetPub\trf\testes\sqlIncluir.jsp:65)
at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
at com.caucho.jsp.Page.subservice(Page.java:497)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
at com.caucho.server.http.Invocation.service(Invocation.java:315)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:246)
at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:163)
at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
at java.lang.Thread.run(Thread.java:536)
Similar Messages
-
SQL types over PLSQL types while using Oracle Applications adapter in BPEL
Use SQL types over PL/SQL types while using Oracle Applications adapter
in BPEL/ ESB
This document will be focusing on Oracle Applications adapter. However Database adapter is much like OA adapter (even OA adapter uses DB Adapter), so the readers who are interested to explore DB adapters, can relate things with this document and go further as well.
Some Guidelines for writing PL/SQL APIs for OA Adapter
As we know when we create a partner link from the OA adapter wizard it sometimes writes some wrapper script supportive to the OA Adapter WSDL which contains below
* Object type for PL/SQL RECORD
* Nested table of the given type for PL/SQL TABLE. For example, the nested table of NUMBER.
* INTEGER substituted for PL/SQL BOOLEAN
* Wrapper Script for converting above three set of data types . (PLSQL to SQL and SQL to PLSQL conversion functions)
In runtime this wrapper script for converting PL/SQL to SQL and SQL to PL/SQL is an extra overhead.
So the first advice would be to avoid the use of the below as parameters of PLSQL API being called by OA Adapter.
* PL/SQL RECORD
* PL/SQL TABLE. For example, the nested table of NUMBER.
* PL/SQL BOOLEAN
In other way we can say we should try to use only SQL data types in arguments if we are planning to call any PL/SQL API from the OA Adapter.
If the requirement is to use a table or record uses the Object type. In place of BOOLEAN better to use VARCHAR or INTEGER what ever fulfills your requirement. Following this guideline we can reduce a huge number of Line of codes to be run each time the adapter being called.
Generally, Oracle E-Biz standard APIs use PL/SQL record types and table types so when there is a requirement to call these API’s from OA Adapter (this is a common requirement in development), and if we directly browse the API in OA Adapter Configuration Wizard and create the partner link, again a huge number of code is written by the wizard in the wrapper script (a number of extra mapping of fields which are not being used in the interface).
In this case better would be to create an Object type with only the required fields which are being used in that call and use them as parameters for the PLSQL API.Find the complete document
http://www.4shared.com/file/167171882/29525116/Use_SQL_types_over_PLSQL_types.html -
Adding new element to BPEL for use in PL SQL type, has binding errors
Figured I might as well post this here since I haven't gotten a single reply in 3 days anywhere else :/
I have a BPEL service that calls a PL SQL procedure. I have added a new element to the BPEL called quote_cart_line.
All I had to the BPEL to accomplish this was edit 3 files -
Async_Invoke_Import_Model.xsd (Source)
<element name="orig_sys_line_ref" type="integer" minOccurs="1" nillable="true"/>
<element name="quote_cart_line" minOccurs="1" nillable="true" type="integer"/>
</sequence>
.....APPS_NI_MODEL_IMPORT_UTIL_IMPORT_SELECTIONS.xsd (Target)
<element name="ORIG_SYS_LINE_REF" type="decimal" db:type="NUMBER" minOccurs="0" nillable="true"/>
<element name="QUOTE_CART_LINE" type="decimal" db:type="NUMBER" minOccurs="0" nillable="true"/>
</sequence>
.....Transform_NIE_Inputs.xsl (Transforming from Source to Target)
<ns1:orig_sys_line_ref>
<xsl:value-of select="/ns1:Async_Invoke_Import_ModelProcessRequest/ns1:import_line/ns1:orig_sys_line_ref"/>
</ns1:orig_sys_line_ref>
<ns1:quote_cart_line>
<xsl:value-of select="/ns1:Async_Invoke_Import_ModelProcessRequest/ns1:import_line/ns1:quote_cart_line"/>
</ns1:quote_cart_line>
</ns1:import_line>
.....I have done this to two other BPELs and they work fine. (1st BPEL calls the second BPEL passing this new element, which then passes it to this BPEL I am having trouble with, which then should be binding it to a PL SQL type)
So this BPEL calls a PL SQL procedure, binding the elements from the BPEL to a PL SQL type (ni_model_import_line). So I edited the PL SQL type to accept this new parameter:
orig_sys_header_ref NUMBER,
quote_cart_line NUMBER,
CONSTRUCTOR FUNCTION ni_model_import_line(p_part_number IN VARCHAR2,
MEMBER PROCEDURE add_orig_sys_header_ref(p_org_sys_header_ref IN NUMBER),
MEMBER PROCEDURE add_quote_cart_line(p_quote_cart_line IN NUMBER)
MEMBER PROCEDURE add_quote_cart_line(p_quote_cart_line IN NUMBER) IS
BEGIN
quote_cart_line := p_quote_cart_line;
END add_quote_cart_line;
END;
.....I invoke all of this, and the new element gets populated in 3 different BPELs, including this one I explained here. But when it comes time to call the PL SQL I am now getting an error:
<fault>
-<bpelFault>
<faultType>0</faultType>
-<bindingFault xmlns="http://schemas.oracle.com/bpel/extension">
-<part name="summary">
<summary>
Exception occured when binding was invoked.
Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'nie_import_2' failed due to: Interaction processing error.
Error while processing the execution of the APPS.NI_MODEL_IMPORT_UTIL.IMPORT_SELECTIONS API interaction.
An error occurred while processing the interaction for invoking the APPS.NI_MODEL_IMPORT_UTIL.IMPORT_SELECTIONS API. Cause: java.lang.NullPointerException
The invoked JCA adapter raised a resource exception.
Please examine the above error message carefully to determine a resolution.
</summary>
</part>
-<part name="detail">
<detail>null</detail>
</part>
-<part name="code">
<code>null</code>
</part>
</bindingFault>
</bpelFault>
</fault>This doesnt happen if I remove the references to this new element and try again, so it obviously is a problem with the element, but I have no idea what it is. It works fine when going from BPEL to BPEL, but as soon as the process tries to call the PL SQL procedure this happens. It is even more frustrating because I have done this exactly before adding another element, and it worked fine...
Any ideas or tips please?Figured I might as well post this here since I haven't gotten a single reply in 3 days anywhere else :/
I have a BPEL service that calls a PL SQL procedure. I have added a new element to the BPEL called quote_cart_line.
All I had to the BPEL to accomplish this was edit 3 files -
Async_Invoke_Import_Model.xsd (Source)
<element name="orig_sys_line_ref" type="integer" minOccurs="1" nillable="true"/>
<element name="quote_cart_line" minOccurs="1" nillable="true" type="integer"/>
</sequence>
.....APPS_NI_MODEL_IMPORT_UTIL_IMPORT_SELECTIONS.xsd (Target)
<element name="ORIG_SYS_LINE_REF" type="decimal" db:type="NUMBER" minOccurs="0" nillable="true"/>
<element name="QUOTE_CART_LINE" type="decimal" db:type="NUMBER" minOccurs="0" nillable="true"/>
</sequence>
.....Transform_NIE_Inputs.xsl (Transforming from Source to Target)
<ns1:orig_sys_line_ref>
<xsl:value-of select="/ns1:Async_Invoke_Import_ModelProcessRequest/ns1:import_line/ns1:orig_sys_line_ref"/>
</ns1:orig_sys_line_ref>
<ns1:quote_cart_line>
<xsl:value-of select="/ns1:Async_Invoke_Import_ModelProcessRequest/ns1:import_line/ns1:quote_cart_line"/>
</ns1:quote_cart_line>
</ns1:import_line>
.....I have done this to two other BPELs and they work fine. (1st BPEL calls the second BPEL passing this new element, which then passes it to this BPEL I am having trouble with, which then should be binding it to a PL SQL type)
So this BPEL calls a PL SQL procedure, binding the elements from the BPEL to a PL SQL type (ni_model_import_line). So I edited the PL SQL type to accept this new parameter:
orig_sys_header_ref NUMBER,
quote_cart_line NUMBER,
CONSTRUCTOR FUNCTION ni_model_import_line(p_part_number IN VARCHAR2,
MEMBER PROCEDURE add_orig_sys_header_ref(p_org_sys_header_ref IN NUMBER),
MEMBER PROCEDURE add_quote_cart_line(p_quote_cart_line IN NUMBER)
MEMBER PROCEDURE add_quote_cart_line(p_quote_cart_line IN NUMBER) IS
BEGIN
quote_cart_line := p_quote_cart_line;
END add_quote_cart_line;
END;
.....I invoke all of this, and the new element gets populated in 3 different BPELs, including this one I explained here. But when it comes time to call the PL SQL I am now getting an error:
<fault>
-<bpelFault>
<faultType>0</faultType>
-<bindingFault xmlns="http://schemas.oracle.com/bpel/extension">
-<part name="summary">
<summary>
Exception occured when binding was invoked.
Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'nie_import_2' failed due to: Interaction processing error.
Error while processing the execution of the APPS.NI_MODEL_IMPORT_UTIL.IMPORT_SELECTIONS API interaction.
An error occurred while processing the interaction for invoking the APPS.NI_MODEL_IMPORT_UTIL.IMPORT_SELECTIONS API. Cause: java.lang.NullPointerException
The invoked JCA adapter raised a resource exception.
Please examine the above error message carefully to determine a resolution.
</summary>
</part>
-<part name="detail">
<detail>null</detail>
</part>
-<part name="code">
<code>null</code>
</part>
</bindingFault>
</bpelFault>
</fault>This doesnt happen if I remove the references to this new element and try again, so it obviously is a problem with the element, but I have no idea what it is. It works fine when going from BPEL to BPEL, but as soon as the process tries to call the PL SQL procedure this happens. It is even more frustrating because I have done this exactly before adding another element, and it worked fine...
Any ideas or tips please? -
How to give a value in Token when Conc prog method registered as pl/sql typ
Hi
We have a report which will generate invoices for a given Operating Unit at one time.i.e Conc Prog1
We have a customised pl/sql package which submits the above report conc prog for all Operating Units with the required parameters for the report.i.e Conc Prog2
When i saw the conc prog2 somehow values has been entered TOKEN field eventhough the conc prog method is pl/sql.this was done earlier than me who developed this intially.
Now i need to include one parameter to this concprog2.when i try to include a parameter to it the TOKEN filed is grayed out(not updatable/eneterable a value).
So could anyone please tell me how i can add a parameter with token value for pl/sql type method conc progs.
Thanks,
MallaHi parag,
You mean to say i have to write like this :--
if (pageContext.getParameter("apply")!=null)
OAApplicationModule am = pageContext.getApplicationModule(webBean);
OAViewObject accountsViewObject =
(OAViewObject)am.findViewObject("ArBusPurAllVO");
if (accountsViewObject!=null)
OARow row = (OARow) accountsViewObject.getCurrentRow();
if (row.getAttribute("GlIdRev") == null || row.getAttribute("GlIdRev").equals(""))
//call your function here and say row.setaatribbute= revenue_acct_id from your function.
if(s8.equalsIgnoreCase("BILL_TO")) {
try {
Connection conn = pageContext.getApplicationModule(webBean).getOADBTransaction().getJdbcConnection();
String Query = "select SDS_CUST_BILL_INFO(:1,2) from dual";
PreparedStatement stmt = conn.prepareStatement(Query);
stmt.setInt(1, orgid);
ResultSet resultset = stmt.executeQuery();
if(resultset.next()) {
String revenuenum = resultset.getString(1);
row.setaatribbute(revenuenum) ;
} catch(SQLException se) {
se.printStackTrace();
throw new OAException("Error in Staffing Query"+se, OAException.ERROR);
if (row.getAttribute("GlIdRec") == null || row.getAttribute("GlIdRec").equals(""))
//call your function here and say row.setaatribbute=rec_acct_id from your function.
if(s8.equalsIgnoreCase("BILL_TO")) {
try {
Connection conn = pageContext.getApplicationModule(webBean).getOADBTransaction().getJdbcConnection();
String Query = "select SDS_CUST_BILL_INFO(:1,2) from dual";
PreparedStatement stmt = conn.prepareStatement(Query);
stmt.setInt(1, orgid);
ResultSet resultset = stmt.executeQuery();
if(resultset.next()) {
String receivablenum = resultset.getString(1);
row.setaatribbute(receivablenum) ;
} catch(SQLException se) {
se.printStackTrace();
throw new OAException("Error in Staffing Query"+se, OAException.ERROR);
super.processFormRequest(pageContext, webBean);
Am I, correct parag please tell me, if this works i will send u mail again that it is working fine .
my mail id is [email protected] -
DBMS_SQL.PARSE with PL/SQL types
Hi
I need to use DBMS_SQL.PARSE with PL/SQL types defined in a package.
I tried with a type record in a declare ..begin..end script but I got an error ..(on second parameter):
DBMS_SQL.PARSE(cursor_name, XXXXX, DBMS_SQL.NATIVE);
It's possible?
WIth SQL types defined at schema level it's works (es. Objects types) .
If it's not possible, how can I resolve?
StefanoAgain, please post what XXXXX is. In order to use package declared types:
SQL> create or replace
2 package pkg1
3 is
4 type emp_rec
5 is record (
6 empno number,
7 ename varchar2(10)
8 );
9 type emp_rec_tbl
10 is
11 table of emp_rec
12 index by pls_integer;
13 g_emp_rec_tbl pkg1.emp_rec_tbl;
14 end;
15 /
Package created.
SQL> declare
2 v_cur integer;
3 v_sql varchar2(1000);
4 begin
5 v_cur := dbms_sql.open_cursor(2);
6 v_sql := 'begin
7 select empno,
8 ename
9 bulk collect
10 into pkg1.g_emp_rec_tbl
11 from emp
12 where job = ''CLERK'';
13 end;';
14 dbms_sql.parse(
15 v_cur,
16 v_sql,
17 dbms_sql.native
18 );
19 end;
20 /
PL/SQL procedure successfully completed.
SQL>
SY. -
How to use PL/SQL type table in SQL FROM clause
Hi All,
I have to use a PL/SQL type table in our SQL statement as a table?
I am using the syntax (below) but it gives PL/SQL: ORA-00902: invalid datatype
SELECT ... FROM TABLE(CAST( var_pl/sql_table AS pl/sql_table)) tab WHERE tab.a=1;
Plz reply with an example.
Thanks.. RatanYou don't need a cast!!!
select *
from table ( <nested_table> )
where <condition>Anyway, are you sure that tab.a is a number?
Here follows an example with an useful function
CREATE OR REPLACE
type string_table as table of varchar2(4000)
CREATE OR REPLACE
FUNCTION split_string (
string IN varchar2,
delimiter IN varchar2
) RETURN string_table IS
tab string_table;
pre integer;
post integer;
step integer;
i integer;
BEGIN
pre := 1;
step := length(delimiter);
i := 0;
tab := string_table();
loop
tab.extend;
i := i + 1;
post := instr(string,delimiter,pre);
if ( post = 0 ) then
tab(i) := substr(string,pre);
return tab;
end if;
tab(i) := substr(string,pre,post-pre);
pre := post + step;
end loop;
END;
select * from table (split_string('abc,dfg,hij',','))
Query finished, retrieving results...
COLUMN_VALUE
abc
dfg
hij -
Error while calling "sql Type" in forms
Hi all,
I have created a SQL TYPE in user schema and call it through form.While compiling form following error message arise:
Implementation restriction [may be temporary] ADT or schema level collection not supported at client side with non-OCI mode.
My user has dba rights and i m using 9.0.4.
Any idea ???
RegardsAll,
The problem is in Oracle Forms. The PL/SQL engine in Forms is not the same as the PL/SQL Engine in the database. Consequently, there will be features available in the Database that are not available in Forms. I suggest you alter your design so it doesn't use a database TYPE. There are a few Metalink articles that discuss this difference.
Craig.. -
There are no readers registered for the sql type.
SQL Developer 4.0
I added .sql and .ldr as file types via Tools > Preferences > File Types.
When I try to open the export.sql file in SQL Developer using the "Import Data" option I get the message:
There are no readers registered for the sql type.
I can open the file with SQL Server Management Studio and see all of the insert statements that i would expect to see.
When I created the export.sql file using the Export Wizard with "Format: insert" I received a message:
"export.sql was not opened because it exceeds the maximum automatic open size."
Can this limit be changed?The import data dialog is for taking a CSV/XLS/TXT type file.
If you used the Export Wizard, you can now just run that file in the worksheet. -
Java.sql.types and oracletypes
There appear to be difference in the way the constants are mapped in java.sql.types vs oracletypes(). For example date is '91' in oracletypes and '93' in java.sql.types. The DatabaseMetaData.getColumns() function reports data_type as a java.sql.type. Is there any mapping available from one to the other.
ThanksErm,
One way to find out, I reckon.
Good Luck,
Avi. -
Hello,
Please help. I am using weblogic 8.1 and MS SQL Server 2000. Using JDBC. I have am calling a stored procedure which outputs a CURSOR. I haveing problems specifying the right java.sql.Type for this. I tried java.sql.Type.OTHER but it fails. The code is as follows
I am planning to return more cursors from the Stored Procedures.
====
Connection conn = null;
CallableStatement stmt = null;
String sqlProc = "{ call GetDocumentDetails(?,?) }";
try {
conn = this.getConnection();
stmt = conn.prepareCall(sqlProc);
stmt.setInt(1, docId);
stmt.registerOutParameter(2,Types.OTHER);
stmt.execute();
ResultSet rs = (ResultSet) stmt.getObject(2);
while(rs.next()) {
The exception that I get is
java.sql.SQLException: [BEA][SQLServer JDBC Driver]The specified SQL type is not supported by this driver.
at weblogic.jdbc.base.BaseExceptions.createException(Unknown Source)
PLEASE HELP.Hello,
Please help. I am using weblogic 8.1 and MS SQL Server 2000. Using JDBC. I have am calling a stored procedure which outputs a CURSOR. I haveing problems specifying the right java.sql.Type for this. I tried java.sql.Type.OTHER but it fails. The code is as follows
I am planning to return more cursors from the Stored Procedures.
====
Connection conn = null;
CallableStatement stmt = null;
String sqlProc = "{ call GetDocumentDetails(?,?) }";
try {
conn = this.getConnection();
stmt = conn.prepareCall(sqlProc);
stmt.setInt(1, docId);
stmt.registerOutParameter(2,Types.OTHER);
stmt.execute();
ResultSet rs = (ResultSet) stmt.getObject(2);
while(rs.next()) {
The exception that I get is
java.sql.SQLException: [BEA][SQLServer JDBC Driver]The specified SQL type is not supported by this driver.
at weblogic.jdbc.base.BaseExceptions.createException(Unknown Source)
PLEASE HELP. -
Hi,
The possibilities can be of various reasons, with the sql statements,
xml descriptors, data sources, improper drivers anything. To crack down
the solution, kindly let me know the error messages and what exactly are
you trying to accomplish.
Thanks & Regards
Raj
manimaran t wrote:
what may be the cause of this error java.sql.SQLException: invalid sql
type passed to callable statement in iplanet ussing JNDI
Try our New Web Based Forum at http://softwareforum.sun.com
Includes Access to our Product Knowledge Base! -
Hi,
Are SQL Types supported in Oracle Forms 10.1.2.0.2 ?
Today I had a problem with them . I used a SQL type in forms , I compiled it, tested it, everything was fine but once I used a different database other than the one I used for the compilation, I start getting "ORA-06508 PL/SQL: could not find program unit being called" errors for my form's program unit in which I used the SQL type.
Anybody has an idea about this ?
ThanksI meant the user defined sql types. Here is an example
CREATE OR REPLACE
TYPE myType AS OBJECT ( char_Column VARCHAR2(32000) )
CREATE OR REPLACE TYPE myTypeTable AS TABLE OF myType;Then In form
procedure myProc is
vMyTypeTable myTypeTable;
begin
null;--Some code here ..having the above decalarition is enough to reproduce the problem
end; -
Java.sql.Types.??????
I know clob columns in an oracle database are java.sql.Types.CLOB. What are long raw columns defined as java.sql.Types.???
Thanks in advance,
kmwHi ,
Long has no correspondng type in Oracle.sql.Types.So u can access it using the getOBject and setObject.Why do u need to defing the long ?Is it for use i the getter and setter methods of ResultSet or Statements.If so , u have to use streaming and so there is really no need to worry abt the type definition as u are defaulting to an AsciiStream.
Hope it helps. -
Any tricks to use PL/SQL types in object attributes?
I guess this is a bit of a newbie-question, but I haven't been able to find any workarounds elsewhere, so please bear with me... I'm far from new to object orientation, but I'm rather new to Oracle's object features.
I was wondering if there's some trick you can use to keep references to attributes of PL/SQL types even though they are not allowed in object types (as these are "SQL", yes I do think I understand). I was thinking there might be some way you could cast them to some data type that is supported in SQL and then get them back by the reverse process when you need them in the PL/SQL inside the methods?
In the concrete case, I would like to keep a reference to a utl_smtp connection in my object. It doesn't matter that the reference would be meaningless in other sessions etc. (actually I may not even want to store the objects in any persistent table - it's the polymorphism I'm after):
CREATE OR REPLACE TYPE o_test AS OBJECT (
att1 NUMBER,
att2 sys.utl_smtp.connection
- which of course give me:
LINE/COL ERROR
0/0 PL/SQL: Compilation unit analysis terminated
3/12 PLS-00329: schema-level type has illegal reference to
SYS.UTL_SMTP
The problem becomes rather dull since I can't pass the connection record as a parameter to methods either.
The only workaround I could think of was to keep the connection as a global variable in a PL/SQL package and then get it from there inside the methods. Of course this can be refined using an index by table and some object unique id to support multiple objects with their separate connections. But it still seems rather clumbsy - especially given that what I was looking for was the elegance of polymorphism.
Any tricks I don't know of?
I'm working in Oracle 10gR2.
best regards,
Jakob
Edited by: schmidt on Mar 21, 2011 10:52 PMThe UTL_SMTP Connection record is not too complicated, and can be easily translated into SQL object types. Add a package to aid in conversion between SQL and PLSQL, and voila!
create or replace type o_utl_tcp_connection is object (
remote_host VARCHAR2(255),
remote_port INTEGER,
local_host VARCHAR2(255),
local_port INTEGER,
charset VARCHAR2(30),
newline VARCHAR2(2),
tx_timeout INTEGER,
private_sd INTEGER
define typeOf_SQL_BOOLEAN = 'number'
define SQL_BOOLEAN = '&typeOf_SQL_BOOLEAN(1)'
define SQL_TRUE = 1
define SQL_FALSE = 0
create or replace type o_utl_smtp_connection is object (
host VARCHAR2(255), -- remote host name
port INTEGER, -- remote port number
tx_timeout INTEGER, -- Transfer time out (in seconds)
private_tcp_con o_utl_tcp_connection, -- private, for implementation use
private_state INTEGER, -- private, for implementation use
-- Optionally, encapsulate all UTL_SMTP package calls behind object methods
member procedure open(
self IN OUT NOCOPY o_utl_smtp_connection,
host IN VARCHAR2,
port IN INTEGER DEFAULT 25,
tx_timeout IN INTEGER DEFAULT NULL,
wallet_path IN VARCHAR2 DEFAULT NULL,
wallet_password IN VARCHAR2 DEFAULT NULL,
secure_connection_before_smtp IN &typeOf_SQL_BOOLEAN DEFAULT &SQL_FALSE
member procedure writeData(
self IN OUT NOCOPY o_utl_smtp_connection,
data IN VARCHAR2 CHARACTER SET ANY_CS
create or replace type body o_utl_smtp_connection is
member procedure open(
self IN OUT NOCOPY o_utl_smtp_connection,
host IN VARCHAR2,
port IN INTEGER DEFAULT 25,
tx_timeout IN INTEGER DEFAULT NULL,
wallet_path IN VARCHAR2 DEFAULT NULL,
wallet_password IN VARCHAR2 DEFAULT NULL,
secure_connection_before_smtp IN &typeOf_SQL_BOOLEAN DEFAULT &SQL_FALSE
is
begin
self := SMTP_UTILS.toSqlConnection(SYS.UTL_SMTP.Open_Connection(
host
, port
, tx_timeout
, wallet_path
, wallet_password
, nvl(secure_connection_before_smtp = &SQL_TRUE, false)
end;
member procedure writeData(
self IN OUT NOCOPY o_utl_smtp_connection,
data IN VARCHAR2 CHARACTER SET ANY_CS
is
conn SYS.UTL_SMTP.Connection := SMTP_UTILS.toPlSqlConnection(self);
begin
begin
SYS.UTL_SMTP.Write_Data(conn, data);
self := SMTP_UTILS.toSqlConnection(conn);
exception
when others then
self := SMTP_UTILS.toSqlConnection(conn);
raise;
end;
end;
end;
create or replace type o_test is object (
attr1 number,
attr2 o_utl_smtp_connection,
member procedure doSomethingWithConnection
create or replace package SMTP_UTILS
is
function toPLSQLConnection(aConnection in o_utl_smtp_connection)
return SYS.UTL_SMTP.Connection;
function toSQLConnection(aConnection in SYS.UTL_SMTP.Connection)
return o_utl_smtp_connection;
end;
create or replace package body SMTP_UTILS
is
function toPLSQLConnection(aConnection in o_utl_smtp_connection)
return SYS.UTL_SMTP.Connection
is
result SYS.UTL_SMTP.Connection;
begin
result.host := aConnection.host;
result.port := aConnection.port;
result.tx_timeout := aConnection.tx_timeout;
result.private_state := aConnection.private_state;
result.private_tcp_con.remote_host := aConnection.private_tcp_con.remote_host;
result.private_tcp_con.remote_port := aConnection.private_tcp_con.remote_port;
result.private_tcp_con.local_host := aConnection.private_tcp_con.local_host;
result.private_tcp_con.local_port := aConnection.private_tcp_con.local_port;
result.private_tcp_con.charset := aConnection.private_tcp_con.charset;
result.private_tcp_con.newline := aConnection.private_tcp_con.newline;
result.private_tcp_con.tx_timeout := aConnection.private_tcp_con.tx_timeout;
result.private_tcp_con.private_sd := aConnection.private_tcp_con.private_sd;
return result;
end;
function toSQLConnection(aConnection in SYS.UTL_SMTP.Connection)
return o_utl_smtp_connection
is
result o_utl_smtp_connection;
begin
result.host := aConnection.host;
result.port := aConnection.port;
result.tx_timeout := aConnection.tx_timeout;
result.private_state := aConnection.private_state;
result.private_tcp_con.remote_host := aConnection.private_tcp_con.remote_host;
result.private_tcp_con.remote_port := aConnection.private_tcp_con.remote_port;
result.private_tcp_con.local_host := aConnection.private_tcp_con.local_host;
result.private_tcp_con.local_port := aConnection.private_tcp_con.local_port;
result.private_tcp_con.charset := aConnection.private_tcp_con.charset;
result.private_tcp_con.newline := aConnection.private_tcp_con.newline;
result.private_tcp_con.tx_timeout := aConnection.private_tcp_con.tx_timeout;
result.private_tcp_con.private_sd := aConnection.private_tcp_con.private_sd;
return result;
end;
end;
create or replace type body o_test is
member procedure doSomethingWithConnection
is
begin
-- Make SMTP calls thru connection object methods
self.attr2.open();
end;
end;
/Hope it helps.
Gerard
Edited by: gaverill on May 17, 2011 3:02 PM - formatted code -
Can we create a StructDescriptor for a pl/sql Type declared in a Package?
Hi,
I went thru many threads on the forum regarding passing Structs and Arrays from java to pl/sql and back. In one of the threads, Tom Trevor has asked this question, but I do not see any definitive answer there. (if it's there, maybe I didn't get it).
I want to refer to a pl.sql Type (Record) declared inside a package while creating a StructDescriptor. Is this possible?This is only possible, when u define ur custom type globally. The reason being, in JDBC code when u define struct statement, the code with db connection in constructor finds that if the custom type is present in DB , it does not search in specific procedure, so it would only get this , if ur cuustom type is defined globally.
--Mukul -
Passing pl/sql type objects between two database
Hi All!
Is there any way out of passing of pl/sql type objects from one databse to another remote database? What are the options available?
thanks...
Sanjeeb Bose
Kolkata IndiaSanjeeb,
Same answer as your other questions. Since remote object types are not allowed, you need to use scalar types instead.
Regards,
Geoff
Hi All!
Is there any way out of passing of pl/sql type objects from one databse to another remote database? What are the options available?
thanks...
Sanjeeb Bose
Kolkata India
Maybe you are looking for
-
How do I transfer info from my old time capsule to a new one
How do I transfer all data from my old time capsule to a new? (latest model)
-
I have problem with setting my clock. there is an errow:Uncaught exception:Index-1>=2 because of that, i can't set alarm clock or set events in my calander. THANKS (-:
-
Flyback Transformer on imac dv400
Hi, Can anyone advise me whether I can use the external monitor for imac dv400 (Slot loading) if my CRT is already dead due to Flyback Transformer ?I understand the early Imac models able to do so by just unplug the old cables and insert the new one.
-
Please help me with this situation
Consider following scenario : ODS 'A' provides data to infocube 'B' ODS has a setting that update automatically in data targets... What happens now is infopackage say 'IP1' loads 'A'(ODS)...Activation of ODS 'A' fails. I manually activate it. I obser
-
Changing my IP address.
Does anyone know how I can change the IP address on my powerbook G4 and get a new one?