Using ODBC through a stored procedure
Is it possible to access an ODBC data source (ie. Access) through a PL/SQL stored procedure? Any syntax would be greatly helpful.
Thanks,
Jeff
I've never seen anyone do this, and I cannot envision a way that makes it possible. You'd have to have an ODBC driver for access living on the database machine.
That said, you might take a look at the Transparent Gateways and/or Generic Connectivity products Oracle puts out. They let you link non-Oracle tables from Oracle. I'm not sure that Access is one of the databases we can link to, however.
Justin Cave
ODBC Development
Similar Messages
-
Issue with sending mail through java stored procedure in Oracle
Hello
I am using Oracle 9i DB. I created a java stored procedure to send mail using the code given below. The java class works fine standalone. When its run from Java, mail is sent as desired. But when the java stored procedure is called from pl/sql "Must issue a STARTTLS command first" error is thrown. Please let me know if am missing something. Tried the same code in 11.2.0.2 DB and got the same error
Error:
javax.mail.MessagingException: 530 5.7.0 Must issue a STARTTLS command first. va6sm31201010igc.6
Code for creating java stored procedure: (T1 is the table created for debugging)
==================================================
create or replace and compile java source named "MailUtil1" AS
import java.util.Enumeration;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class MailUtil1 {
public static void sendMailwithSTARTTLS(String host, //smtp.projectp.com
String from, //sender mail id
String fromPwd,//sender mail pwd
String port,//587
String to,//recepient email ids
String cc,
String subject,
String messageBody) {
try{
Properties props = System.getProperties();
props.put("mail.smtp.starttls.enable", "True"); // added this line
props.put("mail.smtp.host", host);
props.put("mail.smtp.user", from);
props.put("mail.smtp.password", fromPwd);
props.put("mail.smtp.port", port);
props.put("mail.smtp.auth", "true");
#sql { insert into t1 (c1) values ('1'||:host)};
Session session = Session.getDefaultInstance(props, null);
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
#sql { insert into t1 (c1) values ('2')};
InternetAddress[] toAddress = new InternetAddress[1];
// To get the array of addresses
for( int i=0; i < toAddress.length; i++ ) { // changed from a while loop
toAddress[i] = new InternetAddress(to);
//System.out.println(Message.RecipientType.TO);
for( int i=0; i < toAddress.length; i++) { // changed from a while loop
message.addRecipient(Message.RecipientType.TO, toAddress);
if (cc!=null) {
InternetAddress [] ccAddress = new InternetAddress[1];
for(int j=0;j<ccAddress.length;j++){
ccAddress[j] = new InternetAddress(cc);
for (int j=0;j<ccAddress.length;j++){
message.addRecipient(Message.RecipientType.CC, ccAddress[j]);
message.setSubject(subject);
message.setText(messageBody);
message.saveChanges();
#sql { insert into t1 (c1) values ('3')};
Enumeration en = message.getAllHeaderLines();
String token;
while(en.hasMoreElements()){
token ="E:"+en.nextElement().toString();
#sql { insert into t1 (c1) values (:token)};
token ="ConTyp:"+message.getContentType();
#sql { insert into t1 (c1) values (:token)};
token = "Encod:"+message.getEncoding();
#sql { insert into t1 (c1) values (:token)};
token = "Con:"+message.getContent();
#sql { insert into t1 (c1) values (:token)};
Transport transport = session.getTransport("smtp");
#sql { insert into t1 (c1) values ('3.1')};
transport.connect(host, from, fromPwd);
#sql { insert into t1 (c1) values ('3.2')};
transport.sendMessage(message, message.getAllRecipients());
#sql { insert into t1 (c1) values ('3.3')};
transport.close();
#sql { insert into t1 (c1) values ('4')};
catch(Exception e){
e.printStackTrace();
String ex= e.toString();
try{
#sql { insert into t1 (c1) values (:ex)};
catch(Exception e1)
Edited by: user12050615 on Jan 16, 2012 12:18 AMHello,
Thanks for the reply. Actually I have seen that post before creating this thread. I thought that I could make use of java mail to work around this problem. I created a java class that succesfully sends mail to SSL host. I tried to call this java class from pl-sql through java stored procedure. That did not work
So, is this not supported in Oracle ? Please note that I have tested this in both 9i and 11g , in both the versions I got the error. You can refer to the code in the above post.
Thanks
Srikanth
Edited by: user12050615 on Jan 16, 2012 12:17 AM -
Java App connection to an Oracle Database through Oracle Stored Procedure
My team's access to its Databases (Oracle only) is restricted to access through Oracle Stored Procedures that are part of the Oracle Database. So, in my Java App I need to call the Stored Procedure that will give me the access to the table that I need, declare the right parameters and execute the command. The Stored Procedure will then hand me the data I need.
I am finding support on the web for creating Stored Procedures in Java, but that is not what I need.
Can anyone post here a class that addresses this, or point me to a link that will shed some light on it?
Thanks
user606303user606303 wrote:
Sorry this code is unformatted - I can't see how to format it.Use \ tags
I am looking for Java code that will do what this .NET code below does (connects to a database and writes data to the table through an Oracle stored procedure that is part of the Oracle Database.)
So learn Java, learn JDBC and translate the requirements; don't attempt to translate the code as the platforms are too different.
From a quick glance it looks like a JDBC CallableStatement can do the job. -
Creating Sap Crystal Report Through Oracle Stored Procedure Packages
Hi,
1.How we can create crystal report through oracle stored
procedure packages pls tell me the steps through adding command then
tell me the syntax what should i write in command to call the stored
procedure packages or if have some other option then also tell.
2.can
we link stored procedure column to other table column that used in
report.Hi Ganesh,
As this error comes when you are trying to insert non-numeric value into a numeric column in db it seems that your field might be numeric and you are trying to send it as a string in database.
Please check your Store Proc carefully..
Reference Thread: Oracle/PLSQL: ORA-01722
--Dhana -
Using Copy statement in Stored procedure
The following statement works in sqlplus session:
copy from comment/password@servername append amcomment_temp using
select * from amcomment
where commentid in(1,2,3,4)
I want to use this in a stored procedure. There is a long datatype in this table. The
procedure will not compile. Have tried execute immediate and compiler rejects this statement also.'COPY' is a SQL*Plus command, not PL/SQL. This is why the PL/SQL compiler throws it out.
-
How to use order by in stored procedure base block?
How to use order by in stored procedure base block? I need to change order by dynamically
Use SET_BLOCK_PROPERTY('BLOCK_NAME',ORDER_BY,'COLUMN_NAME1, COLUMN_NAME2');
-
Using VIEW inside a stored procedure
Hi,
So I have a View designed in one file that validates someone who is authorized.
Then I have a stored procedure to display authorized stationeries created before a given date. Its takes a parameter @CreatedOn.
How can I use VIEW in my stored procedure so I can display all the authorized which are set 1 before a given date?
My VIEW:
ALTER VIEW vw_AuthorizedStationeries AS
SELECT Authorized
FROM dbo.Stationeries
WHERE Authorized = 1
And my stored procedure:
CREATE PROCEDURE usp_stationeries (@CreatedOn datetime)ASBEGINSELECTFROMENDGO
Thanks!Try something like below, You need to replace CreatedDate column with appropriate date column in your table.
1. Alter the view to get the required date:
ALTER VIEW vw_AuthorizedStationeries AS
SELECT Authorized, CreatedDate
FROM dbo.Stationeries
WHERE Authorized = 1
2. Alter SP:
CREATE PROCEDURE usp_stationeries (@CreatedOn datetime)
AS
BEGIN
SELECT Authorized
FROM vw_AuthorizedStationeries
WHERE CreatedDate <= @CreatedOn
END
GO
OR
You can pull required information directly from your table:
CREATE PROCEDURE usp_stationeries (@CreatedOn datetime)
AS
BEGIN
SELECT Authorized
FROM dbo.Stationeries
WHERE CreatedDate <= @CreatedOn and Authorized = 1
END
GO
If this post answers your query, please click "Mark As Answer" or "Vote as Helpful". -
Using temporary tables in stored procedures
Suppose that I have created a temporary table in a stored procedure using an "EXECUTE IMMEDIATE" statement. When I compile the procedure, that table is not created yet, so the compiler says that the table does not exist.
What is the way of using temporary tables in stored procedures?It's a good practice to avoid using DDL statements being executed from stored procedures. "Truncate Table" via dynamic SQL from stored procedure is a different story and is useful in DSS environments.
But if you insist on "creating" tables using Dynamic SQL from Stored Procedures then you must also embed your DML statements in Dynamic SQL to avoid compilation errors.
Example:
Create or Replace Procedure Proc_TestDynamicSQL is
Begin
Execute Immediate 'Create table myTable as select * from user_tables' ;
Execute Immediate 'Update myTable set table_name = ''Test'' ' ; --two single quotes before and after the string "Test"
End;
In this case, Oracle wouldn't care about the table references during compilation. -
Can rs.last() be used after calling the stored procedure?
Can rs.last() be used after calling the stored procedure? If yes what should be the CURSOR types?
Can rs.last() be used after calling the stored
procedure? If yes what should be the CURSOR types?That would depend on the driver/database.
And as I said in your other post it is far more efficient to count records by just returning a count rather than a complete collection regardless of how you get to the end. -
Host command through java stored procedure
Hi All,
Im trying to execute the winword command to open a MSWord document, print & exit the document, through dos prompt, from client pc to the default printer, through java stored procedure oracle pl/sql forms.
How can achieve this? Kindly help.
rgs
paulIf you have configured webutil without any problems then i presume you have configured jacob.jar file too for Client_ole2 to function properly you need to have jacob.jar and jacob.dll files.
There are so many topics in this forum for Client_Ole2. Just simply search. :)
Message was edited by:
Mudabbir -
Use database inside a stored procedure
Hi guys, a stupid question: I'm working with several database and sometimes I'm afraid to run an alter or a create something in the wrong database, bear in mind that several database have the same tables. Sometime happens to run a query oin the db A
instead in the db B. So, the question: If I create a procedure like this,
create procedure creatingPillar as
use USA
begin
IF EXISTS (SELECT * FROM sys.objects WHERE object_id =
OBJECT_ID(N'pillarretail') AND type in (N'U'))
DROP TABLE PillarRetail
create table PillarRetail (anid int , ancore varchar(20), period dec(18,6), settlem datetime2,
settlementper int, asf dec(18,6),astlf dec (18,6), tot dec (18,6) )
insert into PillarRetail select anid, ancore, Period, settlem, settlementper,
asf, astlf, tot from createsemipillar2011
insert into PillarRetail select select anid, ancore, Period, settlem, settlementper,
asf, astlf, tot createsemipillar
end
but I'm wondering if is useless to put the use USA in the stored procedure by the moment that I'm creating the procedure in USA. I mean, having the SP in the USA db even if I run the procedure from another db it should run in USA. Just a stupid question
I know but I got this doubt...
ThanksYou may try as below:
create proc as below: (This will create the proc in USA database.
use USA
Go
create procedure dbo.creatingPillar as
begin
IF EXISTS (SELECT * FROM sys.objects WHERE object_id =
OBJECT_ID(N'pillarretail') AND type in (N'U'))
DROP TABLE PillarRetail
create table PillarRetail (anid int , ancore varchar(20), period dec(18,6), settlem datetime2,
settlementper int, asf dec(18,6),astlf dec (18,6), tot dec (18,6) )
insert into PillarRetail select anid, ancore, Period, settlem, settlementper,
asf, astlf, tot from createsemipillar2011
insert into PillarRetail select select anid, ancore, Period, settlem, settlementper,
asf, astlf, tot createsemipillar
end
Then you can call as below:
Exec USA.dbo.creatingPillar -
How to use optional prompts with stored procedure universe?
Hi Experts,
Iu2019m working on stored procedure universe in BO XI 3.0 SP2 FP2.5 with oracle at back end. My requirement is that I have to pass 5 optional prompts in the report and we have to pass these prompts through open document link. Please tell if this can be worked out on stored procedure universe?
Thanks in advance.Hi,
Try with OpenDoc syntax as follows.
http://<servername>:<port>/OpenDocument/opendoc/<plat
formSpecific>?iDocID=****&sIDType=CUID&sType=wid/rpt&lsM/lsS/lsRPROMPTNAME=[V1],[V2]&sDocName=reportname&sRefresh=Y/N
where
server name: cms server name
port: portno
<platformspecific>=: for java -> openDocument.jsp
for .net -> opendocument.aspx
idocid,sDocName & cuid -> we can get report properties ( goto info view -> select report -> right click -> properties i.e. doc id, cuid and report name)
sType -> type of report i.e webi or deski ...
lsS -> to pass single prompt value
lsM -> to pass multiplle values to prompt
lsR -> range of values ....
Note: Here prompt name should be same as the one which we used in the report. Use + if there is blank space.
Cheers,
Suresh Aluri. -
ODBC failure with stored procedure
Procedure runs without error when started from term window. Procedure will run from access using pass through query (module) iff one of the queries is commented out. If the query is present, I receive an ODBC failure on the record insert. It acts like a timing problem but I can't find the place to set it.
ANY help appreciated.I'm assuming that your error is:
Newmars ea-fa ENTER SQLExecDirectW
HSTMT 09DD2910
WCHAR * 0x0012BA00 [ -3] "BEGIN MARS_BIGSUM_PROCEDURE; END;\ 0"
SDWORD -3
Newmars ea-fa EXIT SQLExecDirectW with return code -1 (SQL_ERROR)
HSTMT 09DD2910
WCHAR * 0x0012BA00 [ -3] "BEGIN MARS_BIGSUM_PROCEDURE; END;\ 0"
SDWORD -3
DIAG [S1T00] [Oracle][ODBC][Ora]ORA-01013: user requested cancel of current operation
ORA-06512: at "HQADM.MARS_BIGSUM_PROCEDURE", line 87
ORA-06512: at line 1
(1013)
although I'm not sure whether the earlier error
Newmars ea-fa EXIT SQLExecDirectW with return code -1 (SQL_ERROR)
HSTMT 09DD17D0
WCHAR * 0x1B0741C8 [ -3] "SELECT Config, nValue FROM MSysConf\ 0"
SDWORD -3
DIAG [S0002] [Oracle][ODBC][Ora]ORA-00942: table or view does not exist
(942)
is important.
For the timeout error, the most likely problem is that Access is putting a timeout on the call, and requesting that the driver cancel the query if it takes too long. Ideally, you'd be able to adjust the timeout parameter in Access, but I'm not aware of a way to do that. You can disable query timeout at the DSN level, though, there's a checkbox in the configuration screen for the DSN. This will disable query timeout for every application that uses the DSN, though.
For the table not found error, that's indicating that there's no table named MSysConf in whatever schema you're connected to.
Justin -
Runtime.Exec() fails -- Through java stored procedure in Oracle8i
HI,
I HAVE A JAVA STORED PROCEDURE WHICH EXECUTES
A HOST COMMAND USING Runtime.Exec().
BUT IT IS NOT WORKING.
RIGHTS FOR THE USER HAVE BEEN GIVEN USING
Dbms_grant_persmission(). The database in on
SUN SOLARIS. THE EXITVALUE OF THE RUNTIME.EXEC COMMAND IS 255(SEGMENTATION
ERROR - CORE DUMPED).
PLEASE LET ME KNOW WHERE THE PROBLEM LIES. THE FUNCTION IS WORKING WELL IF THE DATABASE IS ON NT PLATFORM BUT FAILS TO WORK WHEN I STORED THE PROCEDURE IN A DATABASE RUNNING ON SUN SOLARIS AND TRIED TO EXECUTE A SOLARIS COMMAND THROUGH THE PROCEDURE.
Thanks for ur interest!
with best regards,
MathanI have similar problem on HP-UX, I would appreciate if you
somehow were able to solve it.
Thanks
Rahul Shah -
How to use materialized view in stored procedure
in my stored procedure I use couple of queries (see the script below). I want to create materialized views to replace these queries. Is it possible to achieve and how to achieve it in my case? thanks in advance
set serveroutput on
DECLARE
v_cur_tid NUMBER(5):=0;
v_cur_cs_attendance NUMBER(5):=0;
v_cur_c_tot_enrolments NUMBER(5):=0;
v_most_enrolments NUMBER(5):=0;
v_least_enrolments NUMBER(5):=0;
v_most_pop_cid NUMBER(5):=0;
v_least_pop_cid NUMBER(5):=0;
CURSOR class_cursor IS
select
id,
name,
max_attendees
from
class
where
id in (select distinct(event_id) from trainer_schedule where event_type='c' and is_active='y')
order by id;
BEGIN
DBMS_OUTPUT.PUT_LINE('==================================================================================================================================');
--print the report header
DBMS_OUTPUT.PUT_LINE('Summary Report No.3: Training Class Active Schedules Summary Report');
FOR r_class IN class_cursor LOOP
--print the header or subsection
select sum(enrolments) into v_cur_c_tot_enrolments from class_schedule where class_id = r_class.id;
IF v_most_enrolments < v_cur_c_tot_enrolments OR v_most_enrolments = 0
THEN v_most_enrolments := v_cur_c_tot_enrolments; v_most_pop_cid := r_class.id;
END IF;
IF v_least_enrolments > v_cur_c_tot_enrolments OR v_least_enrolments = 0
THEN v_least_enrolments := v_cur_c_tot_enrolments; v_least_pop_cid := r_class.id;
END IF;
DBMS_OUTPUT.PUT_LINE('******************************************************************************************');
DBMS_OUTPUT.PUT_LINE('CLASS_ID: ' || r_class.id ||' '|| 'CLASS_NAME: ' || r_class.name ||' '||'CAPACITY: ' || r_class.max_attendees ||' '||'TOTAL_ENROLMENTS: ' || v_cur_c_tot_enrolments);
DBMS_OUTPUT.PUT_LINE(rpad('____________', 12) || lpad('____________', 12) || lpad('____________________', 20) || lpad('____________________', 20) || lpad('____________',12) || lpad('____________',12));
DBMS_OUTPUT.PUT_LINE(rpad('SCHEDULE_ID', 12) || lpad('TRAINER_ID',12) || lpad('START_TIME', 20) || lpad('END_TIME',20) || lpad('ENROLMENTS',12) || lpad('ATTENDANCE',12));
DBMS_OUTPUT.PUT_LINE(rpad('____________', 12) || lpad('____________',12) || lpad('____________________', 20) || lpad('____________________', 20) || lpad('____________',12) || lpad('____________',12));
FOR r_cs IN (select id,to_char(start_time,'DD-MM-YYYY HH24:Mi') as start_time, to_char(end_time,'DD-MM-YYYY HH24:Mi') as end_time, enrolments from class_schedule where class_id = r_class.id order by id)
LOOP
select trainer_id into v_cur_tid from trainer_schedule where event_type='c' and event_id = r_cs.id;
select count(training_session.id) into v_cur_cs_attendance
from training_session, class_schedule
where training_session.attended = 'y' and
training_session.type='c'and
to_char(training_session.start_time,'DD-MM-YYYY HH24:Mi') = to_char(class_schedule.start_time,'DD-MM-YYYY HH24:Mi') and
class_schedule.id = r_cs.id;
DBMS_OUTPUT.PUT_LINE(rpad(r_cs.id, 12) || lpad(v_cur_tid,12) || lpad(r_cs.start_time, 20) || lpad(r_cs.end_time,20) || lpad(r_cs.enrolments,12) || lpad(v_cur_cs_attendance,12));
END LOOP;
END LOOP;
DBMS_OUTPUT.PUT_LINE('******************************************************************************************');
DBMS_OUTPUT.PUT_LINE('******************************************************************************************');
DBMS_OUTPUT.PUT_LINE('MOST_POPULAR_CLASS: '||v_most_pop_cid||' TOTAL_ENROLMENTS_TO_DATE: '||v_most_enrolments);
DBMS_OUTPUT.PUT_LINE('LEAST_POPULAR_CLASS: '||v_least_pop_cid||' TOTAL_ENROLMENTS_TO_DATE: '||v_least_enrolments);
DBMS_OUTPUT.PUT_LINE('==================================================================================================================================');
END;
/Hi,
you could use Dynamic SQL /Execute immediate to run DDL from a stored procedure.
http://download-uk.oracle.com/docs/cd/B10501_01/appdev.920/a96624/11_dynam.htm
Could you please tell why do you want to create a materialized view in stored procedure ?
How frequently you will runt this procedure . It would is better to create a MV once and use it.
thanks
Maybe you are looking for
-
Error while creating Virutual Cube
Hi all, I am trying to create a virtual cube for FI-GL module. i took a copy of the standard function module 'RS_BCT_FIGL_DATA_GET_VC1'in se37 transaction. And changed the default info cube name in 'import' parameter of the function module. when I
-
How do I install adobe as a printer?
I need to print a .pdf from word. I bought the Adobe pack, why is it not showing as a printer choice?
-
Since the latest version of Adobe Flash Player wouldn't install after deleting the version I had that did work, should I try to install an older version? I just checked in the control panel and my add/remove programs and listed is Adobe Flash Player
-
SCEP 2012 and VDI offline servicing
I've seen this question being asked before in another thread (Best practice to run Microsoft Endpoint Protection client in VDI environment) however the answer doesn't provide enough information (for me at least) We are planning to use a Citrix XenDes
-
I've seen postings about photoshop CS4's conflicts with Spaces, but not recently and not about CS4 as a whole. The main issue I experience is that when I try to permanently assign, for example, illustrator to Space 2(in the system preferences, spaces