Execute procedure on oracle apex online
Hi All
CREATE OR REPLACE PROCEDURE TEST_PROC
AS
V_FNAME EMPLOYEES.FIRST_NAME%TYPE;
BEGIN
SELECT FIRST_NAME INTO V_FNAME FROM EMPLOYEES
WHERE FIRST_NAME = 'JOHN';
DBMS_OUT.PUT_LINE(V_FNAME);
END;
I have made this procedure on sql worksheet of http://apex.oracle.com/ on my account.
when i gave EXECUTE TEST_PROC; and CALL TEST_PROC; command to exeute this procedure I'm getting following error ORA-00900: invalid SQL statement.
please tell how can i run this procedure.
thanks in advance.
regards
Neeraj
Some basic concepts first. Apex is a suite of PL/SQL procedures and functions and packages and database tables. Apex runs totally inside the database as stored procedural code.
What makes it unique and different is that the procedures are called by a web browser URL. This is received by Apache and passed to a module called mod_psql. This module processes the URL from the web browser, determines what database to connect to and what stored procedure call to make.
Inside the PL/SQL environment there is a set of web packages - and a buffer area that can be used to create dynamic web pages. Apex PL/SQL code executes and creates a dynamic web page/web content in this buffer. The code terminates.
The mod_plsql module in Apache then reads this buffer from the Oracle session and it streams the content to the web browser.
DBMS_OUTPUT is not specifically supported by mod_plsql as it is another buffer area (quite primitive in use and interface). It supports a basic console output display for PL/SQL code - and is typically use by session-based clients like TOAD, SQL*Plus and SQL-Developer.
So if you want a web-enabled PL/SQL procedure to display data on the web browser, your code needs to write to the web buffer in PL/SQL and not the DBMS_OUTPUT buffer. Writing to the web buffer can be done using the HTP.prn() call.
Here's a very basic example of outputting data to a web browser using custom PL/SQL code. Create a Apex page. On this page create a text item called something like P1_FIRSTNAME. This enables the web user to supply a parameter value to your PL/SQL procedure.
Create a dynamic PL/SQL region on the page, that calls your procedure:
begin
--// if the user supplied a firstname, we call the procedure to process the data
if :P1_FIRSTNAME is not null then
MyTestProc( firstName => :P1_FIRSTNAME );
end if;
end;The user procedure that receives and processes the data, and supplied web output, will look something like the following:
create or replace procedure MyTestProc( firstName varchar2 ) is
cnt integer;
begin
htp.prn( 'You have entered the search criteria: '||firstName||'<br> ');
select count(*) into cnt from emp where first_name like firstName;
htp.prn( 'Number of matching employees: '||to_char(cnt)||' row(s)<br> ');
end;
Similar Messages
-
I try to execute procedure on ORACLE(8i) but get err SQLException ..
but for SELECT UPDATE INSERT statements all is OK!!
for SELECT, UPDATE, INSERT I wrote such code:
Statement stmt = conn.createStatement();
String strExec="SELECT ...."
stmt.executeQuery(strExec); (OR stmt.executeUpdate(strExec);)for proceure I wrote
strExec = " my_proc() ";
stmt.execute(strExec);what is wrong here??Try like this,
CallableStatement cstm = con.prepareCall("{ call my_proc }");
cstm.executeUpdate();
Sudha -
How to call statement's execute function to execute procedure in Oracle?
I made a very simple procedure in oracle logged as internal user.
the procedure as the following:
create or replace procedure temptest
as
begin
insert into indextab(idx) values(100);
commit;
end temptest;
in Java program,I use Oracle's jdbc driver to connect database, still connect as internal user.
I can call statement.executeUpdate("insert into indextab(idx) values(100)"). and 100 row was added in database.
then,I delete this row, try to run procedure in java,
but the call of statement.execute("temptest") throw a exception
the error message is:"java.sql.SQLException: ORA-00900: invalid SQL statement"
then, I write the same procedure in sql server.
all things work right.( I use jdbc-odbc bridge connect to sql server database)
who can tell me what's the reason?
I'm so urgent, please help me as soon as fast, thank you very muchInstead of a Statement object, use a CallableStatement. CallableStatement is the JDBC wrapper for a stored proc. JDBC requires that the vendor specific call be wrapped in a {CALL ....}.
So, your code would look like the following:
Connection con = some connection;
CallableStatement cs = con.prepareCall("{CALL temptest}");
cs.execute();
Take a look at the Javadoc. You can set both IN and OUT parameters using a CallableStatement. -
PLS-00306,problem while executing procedure from oracle e_comerce
Hi
I have writen a procedure in oracle.Tere i have a parameter with type varchar2.
While i registered it in e_comerce i choosed the value set as 15characters.
When i am runing the program from my ecomerce application it gives an error as below:
ORACLE error 6550 in FDPSTP
Cause: FDPSTP failed due to ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'PO_OUTPUT'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
there is no error when i am executing my procedure in toad/sql+ but this error comes only in e_comerce application.
PLease tell what is the reason and what can be the solution?Hi,
<p>
The function has the following parameters:<br>
function insertj(jnum j.j#%type, jname j.jname%type, city j.city%type)<br>
where j# is varchar2(5), jname is varchar2(35) and city is varchar2(35)<br>.
I was trying to insert the following values:<br>
j#:='J11', jname:='JobName' and city:='Paris'.<br>
</p>
<p>
The procedure just calls this function with the same parameters. It is very strange because it is hard to see what the problem is. The line 10 is return 0 in the function where I believe the error comes from. It starts in the procedure and then goes in the function body, if I am interpreting this right.
</p>
<p>
Any idea?
</p>
Thanks! -
Error ORA-03113 when execute procedure via OEM
Hi All,
I got error messages
ORA-03113: end-of-file on communication channel
ERROR at line 1:
ORA-03114: not connected to ORACLE
when execute procedure via Oracle Enterprise Manager
Who do you know what 's the problem and how can I resolves ?
Thanks,
MckaSolution Description:
=====================
The ORA-3113 error is a general error reported by Oracle client tools,
which signifies that they cannot communicate with the oracle shadow
process. As it is such a general error more information must be collected
to help determine what has happened.
This short article describes what information to collect for an
ORA-3113 error when the Oracle server is on a Unix platform.
General Issues:
===============
1) Is it only one tool that encounters the error or
do you get an ORA-3113 from any tool doing a similar operation?
If the problem reproduces in SQL*Plus, use this in all tests
below.
2) Check if the problem is just restricted to:
[ ] One particular UNIX user,
[ ] Any UNIX user
or [ ] Any UNIX user EXCEPT as the Oracle user.
3) Check if the problem is just restricted to:
[ ] One particular ORACLE logon
or [ ] Any ORACLE logon that has access to the
relevant tables.
4) If you have a client-server configuration does this occur from:
[ ] Any client
[ ] Just one particular client
or [ ] Just one group of clients ?
If so what do these clients have in common ?
Eg: Software release .
5) Do you have a second server or database version where the
same operation works correctly? -
Executing Procedure in SQL SERVER and Storing the results in Oracle 10g
Hello,
I am trying execute SQL SERVER procedure from Oracle 10g and store the results in a oracle table. When I tried executing the procedure i am getting errors.
I am using Oracle Heteroeneous Services.
Steps I followed.
1. Created ODBC DSN on Oracle Server connecting to SQL SERVER database.
2. Created Listner entry and TNSNAMES entries.
3. Created Database link and able to select the data from the SQL SERVER tables.
Here is the code i tried to execute the procedure.
BEGIN
"META"."extract"@abc;
END;
"META"."extract"@abc;
ERROR at line 2:
ORA-06550: line 2, column 1:
PLS-00201: identifier 'META.extract@ABC' must be declared
ORA-06550: line 2, column 1:
PL/SQL: Statement ignored
Please help me.
Thank You,
Seshadri ThopeHi thopevs,
Can you please tell me the right syntax of calling procedures(on sql server) from oracle?
I am getting following error:
SQL> execute "GetdateSys"@oratosql;
begin "GetdateSys"@oratosql; end;
ORA-06550: line 2, column 7:
PLS-00201: identifier 'GetdateSys@ORATOSQL' must be declared
ORA-06550: line 2, column 7:
PL/SQL: Statement ignored
SQL>
Your help will be highly appreciated.
Thanks & Regards,
M.U.N.A -
Is it possible to execute OS level commands through Oracle APEX?
Hi,
I would like to know if it is possible to execute OS level commands, say executing any command in command prompt using Oracle APEX.
Thanks!Welcome to Oracle Forums!
Please acquaint yourself with the FAQ and forum etiquette if you haven't already done so.
Always state
<ul>
<li>Apex Version</li>
<li>DB Version and edition</li>
<li>Web server used.I.e. EPG, OHS, ApexListner Standalone or with J2EE container</li>
<li>When asking about forms always state tabular form if it is a tabular form</li>
<li>When asking about reports always state Classic / IR</li>
<li>Always post code snippets enclosed in a pair of {code} tags as explained in FAQ</li>
</ul>
I would like to know if it is possible to execute OS level commands, say executing any command in command prompt using Oracle APEX.If by OS you are referring to the client side, then NO.
Cheers, -
Executing sql server procedure from oracle via db link with out parameters
HI
we have successfully created the link between oracle and sql server via DB LINK also able to access table from the
sqlserver via dblink
Can any one tell me how to execute procedure with 1 input and 4 out parameters from pl\sql
is it possible using
dbms_hs_passthroughYou should be able to call it like you would any other procedure:
dbo.procedure_name@dblink(parameter_list); -
Could not execute stored procedure in oracle
hello experts,
Problem: I can not execute stored procedures stored in Oracle data base. Error Message: Portal request failed. Could not execute stored procedure.
My steps:
i connected my locally installed Oracle data base to the VC. I mapped the data base user to my VC user. I tested connection and it is fine. Further I see the db alias in Visual Composer and i can drop stored procedures to my story board. I can define parameters, but when I am executing procedures I get the error message.
Further I installed MS SQL Server lokally and connected to the VC and it is working fine. I can do everything.
Why it is not working for Oracle DB?
DriverName: com.sap.portals.jdbc.oracle.OracleDriver
Connect-URL: jdbc:sap:oracle://ip:port;sid=XE
Any comment is highly appreciated.
anton.Hi,
Also you can follow this link which explains you the procedure to configure BI JDBC system for visual composer.
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6209b52e-0401-0010-6a9f-d40ec3a09424
Regards
Inder
Do reward points if helpful. -
Get CGI env variables in a database procedure using new APEX Listener
I already posted this question in the Apex Listener forum and still no replies after one week. The original post is here:
Get CGI environment from APEX Listener within database procedure
So please forgive me for posting in this forum as well, but there is a lot more activity here.
I'd like to know how I can get the CGI environment from the APEX Listener. For example, if I want to write a procedure that inserts into a table the originating IP Address of the client making the web request, how do I get it?
I am familiar with the Oracle Http Server and mod_plsql, and I know how to call OWA_UTIL.GET_CGI_ENV to get this sort of information. How do I do it using the APEX Listener?
In particular, how do I do this when calling a custom procedure (not in an Apex workspace)? When I try it now, I get an error from owa_util. The cgi env seems to be empty or not initiated (owa.num_cgi_vars is null or zero).
Specific set-up:
I have a web server running the latest JDK, Glassfish, and 1.1.4 Apex Listener. It connects to another server running the latest 11.2 database. Apex is installed and running, but I am not really developing a traditional Apex application in a workspace. I mainly use it like you would use mod_plsql. In other words, I have custom pl/sql packages that are called directly via URL. The requests are forwarded by the listener to the database, and the DB executes the procedure and returns output using htp.p to send text back to the browser. And it works just fine for this purpose. But if I want to call GET_CGI_ENV to get information like the IP Address, web browser making the request, etc. I can't seem to get it with the OWA packages.
Can anyone shed some light on this? If Apex Listener is not designed to do this, is there some kind of workaround I can use to forward this sort of information to the database for each request?I have not tried owa_util.print_cgi_env from SQL Workshop yet, as I have not created an APEX workspace. I have had no need for a workspace because of the way I am using APEX as a method for calling custom packages and stored procedures. In other words, I am using APEX strictly for the mod_plsql functionality. I just use it to forward requests to the database to execute pl/sql code, but I don't develop anything in APEX. My application is a web service with no screens and no direct user interface, which is why I did not need to create APEX forms. The front end is a mobile app that makes calls to the web service.
But I have tried calling owa_util.print_cgi_env in one of my stored procedures and it returns no data, even when calling it from the web front-end.
So I am beginning to believe that if the OWA toolkit works with APEX, then it must only be enabled when invoked within a workspace. Stand-alone procedures can be called via APEX, but apparently doing so does not initiate the CGI env variables. This set-up used to work under the OHS with mod_plsql. The embedded pl/sql gateway also works this way.
Is there a procedure call that APEX is making to set the environment before each SQL Workshop request?
My security model currently blocks access to all packages and procedures except for my custom packages. I am using the APEX Listener configuration to allow only the packages listed by name in a white list. But I thought I allowed all access when I first tried calling the OWA packages. I'll have to try that again. -
Dbms_output package on oracle apex
Hi
CREATE OR REPLACE PROCEDURE TEST_PROC
AS
V_FNAME EMPLOYEES.FIRST_NAME%TYPE;
BEGIN
SELECT FIRST_NAME INTO V_FNAME FROM EMPLOYEES
WHERE FIRST_NAME = 'JOHN';
DBMS_OUT.PUT_LINE(V_FNAME);
END;
begin
TEST_PROC;
end;
when we execute procedure like this how to get the output on result screen using DBMS_OUT.PUT_LINE(V_FNAME); sql worksheet of http://apex.oracle.com/ on my account
because set serveroutput on is not working here.
thanksYou don't use DBMS_OUTPUT in apex.
It has ways you can output html within the screen content if you really want (a google search would show you how), though Apex comes with a debug option so you can see what values things have without having to code your own.
Edit: Oh, and p.s. this is the SQL and PL/SQL forum, not the Application Express forum which is here: Oracle Application Express (APEX)
Edited by: BluShadow on 04-Nov-2011 11:05 -
Need sample source code for calling stored procedure in Oracle
Hi.
I try to call stored procedure in oracle using JCA JDBC.
Anybody have sample source code for that ?
Regards, Arnold.Thank you very much for a very quick reply. It worked, but I have an extended problem for which I would like to have a solution. Thank you very much in advance for your help. The problem is described below.
I have the Procedure defined as below in the SFCS1 package body
Procedure Company_Selection(O_Cursor IN OUT T_Cursor)
BEGIN
Open O_Cursor FOR
SELECT CompanyId, CompanyName
FROM Company
WHERE CompanyProvince IN ('AL','AK');
END Company_Selection;
In the Oracle Forms, I have a datablock based on the above stored procedure. When I execute the form and from the menu if I click on Execute Query the data block gets filled up with data (The datablock is configured to display 10 items as a tabular form).
At this point in time, I want to automate the process of displaying the data, hence I created a button and from there I want to call this stored procedure. So, in the button trigger I have the following statements
DECLARE
A SFCS1.T_Cursor;
BEGIN
SFCS1.Company_Selection(A);
go_Block ('Block36');
The cursor goes to the corresponding block, but does not display any data. Can you tell me how to get the data displayed. In the future versions, I'm planning to put variables in the WHERE clause. -
How to pass a value to a bind variable in a query report in oracle apex
Hi Guys,
I have requirement to send weekly reports via email to some users. The users should receive their own records in the report. The user details is stored in a table. What I am planning to do is to create a report query in oracle apex to generate the report and then run a function/procedure via a scheduler to email the report to respective users. Now my query is ............. is it possible to pass a value (user name) to the report query to pull records of only that user? I know we can have bind variables in the report query but I have no idea how to pass a value for bind variables from a function/procedure.
Can anyone help me on this issue or suggest a better approach?
Thanks,
SanYou need to use dynamic sql
But please keep in mind that since you're using Oracle you may be better off posting this in some Oracle forums
This forum is specifically for SQL Server
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Hi,
I have a requirement to fetch the view data from client instance(which is different server) to another instance lets say Development instance
Requirement:
Need to get the Apps View data from the Desired EBS instance(which is accessible online) using webservices,and display it in the Oracle Apex Development Instance.
Kindly provide your inputs how to achieve this.
Thanks in advance
keertyAre you getting an error? The way you have it set up, you can have an error and it will never be displayed. Put and error control on your front panel and see what it gives you. Also, shared variables in a project can be useful. Look at some examples for that.
-
SQLException while calling a Stored Procedure in Oracle
Hi all,
I am getting this error while calling a Stored Procedure in Oracle...
java.sql.SQLException: ORA-00600: internal error code, arguments: [12259], [], [
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:207)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:540)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1273)
at oracle.jdbc.ttc7.TTC7Protocol.fetch(TTC7Protocol.java:780)
at oracle.jdbc.driver.OracleResultSet.next(OracleResultSet.java:135)
at StoredProcedureDemo.main(StoredProcedureDemo.java:36)
The Program is ...
import java.sql.*;
public class StoredProcedureDemo {
public static void main(String[] args) throws Exception {
Connection con = null;
ResultSet rs = null;
Statement st = null;
CallableStatement cs = null;
int i;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:SHYAM","scott","tiger");
System.out.println("Got Connection ");
st = con.createStatement();
String createProcedure = "create or replace PROCEDURE Get_emp_names (Dept_num IN NUMBER) IS"
+" Emp_name VARCHAR2(10);"
+" CURSOR c1 (Depno NUMBER) IS"
+" SELECT Ename FROM emp WHERE deptno = Depno;"
+" BEGIN"
+" OPEN c1(Dept_num);"
+" LOOP"
+" FETCH c1 INTO Emp_name;"
+" EXIT WHEN C1%NOTFOUND;"
+" END LOOP;"
+" CLOSE c1;"
+" END;";
System.out.println("Stored Procedure is \n"+createProcedure);
i = st.executeUpdate(createProcedure);
System.out.println("After creating the Stored Procedure "+i);
cs = con.prepareCall("{call Get_emp_names(?)}");
System.out.println("After calling the Stored Procedure ");
cs.setInt(1,20);
System.out.println("Before executing the Stored Procedure ");
rs = cs.executeQuery();
System.out.println("The Enames of the given Dept are ....");
while(rs.next()) {
System.out.println("In The while loop ");
System.out.println(rs.getString(1));
catch (Exception e) {
e.printStackTrace();
Stored Procedure is ...
create or replace PROCEDURE Get_emp_names (Dept_num IN NUMBER) IS
Emp_name VARCHAR2(10);
CURSOR c1 (Depno NUMBER) IS
SELECT Ename FROM emp WHERE deptno = Depno;
BEGIN
OPEN c1(Dept_num);
LOOP
FETCH c1 INTO Emp_name;
EXIT WHEN C1%NOTFOUND;
END LOOP;
CLOSE c1;
END;
Stored procedure is working properly on sql*plus(Oracle 8.1.5)) editor. But it is not working from a standalone java application. Can anyone please give me a solution.
thanks and regards
Shyam KrishnaThe first solution is to not do that in java in the first place.
DDL should be in script files which are applied to oracle outside of java.
Other than I believe there are some existing stored procedures in Oracle that take DDL strings and process them. Your user has to have permission of course. You can track them down via the documentation.
Maybe you are looking for
-
I can't install Windows 8.1 pro (downloaded from Microsoft) on MBP 13" retina
I downloaded windows 8.1 pro from the microsoft website (it is an .exe file), but now I cannot install it with bootcamp.
-
Is it possible to keep Contact List and Address Book seperate on iPhone?
I just made the switch today- big time – from Motorola to iPhone, and from PC to iMac, plus a Macbook Air as well for travel. Thanks to iphone and Mac forums I have been able to resolve most newbie issues and have exported my data, files and contacts
-
Macbook pro having serial-ATA issues
I was working on a project in xcode that an error poped saying it can't save the file, after that mac os just hanged, so I restarted it, but it couldn't get pass the apple logo, so I booted the recovery partition and tried the disk utility and it sai
-
I would like to replace my retina display
I would like to replace my retina display because of image retention. Is it possible to replace it?
-
Is the old HP-IB on a ribbon cable compatable with the now standard GPIB?
I have found a HP61001A and associated 61016, 61014 etc test equipment. It uses a ribbon cable to interface. Would anyone know if this is compatable with the now standard GPIB? Could it be used with some form of "connection converter"? Many thanks fo