disconnected rowset select CachedRowSet of a statement within the stored procedure?
Hello everyone
I'm using CachedRowSet returned from a parameterized select statement and it works very well.
If I put the same select statement in a simple read only then stored procedure I get this exception: "a result set has been generated for the update.
I'm not trying to update all lines in my code.
I tried to make the CachedRowSet to be read-only, but this does not help, same error.
Question 1: a stored procedure returns a single result set can be called to fill a CachedRowSet read-only? (in a similar way to a method of CallableStatement prepareCall with input/output settings).
Question 2: in general is something to be encouraged for future development or are they deprecated or replaced with something else or better using CachedRowSet, FilteredRowSet (disconnected) and WebRowSet, JDBCRowSet (connected)?
Thank you very much in advance
It work? (be sure that your stored procedure done * nothing * before running this query)
PreparedStatement p = conn.prepareStatement ("{call dbo.p_testCachedJDBCRowSet (?)}" ");
p.setInt (1, 10);
CRS CachedRowSetImpl = new CachedRowSetImpl();
CRS. Populate (p.ExecuteQuery ());
Tags: Java
Similar Questions
-
Select problem with a statement in the stored procedure oracle
Hi guys,.
I am new to oracle. I have a simple sql stored procedure that needs to be converted to oracle. The procedure is,
CREATE PROCEDURE my_procedure
Char (4) @my_var = null
AS
Select * from my_table where my_variable = @my_var
I converted this SP as oracle and the convert SP is,
create or replace
My_procedure PROCEDURE
(
v_my_var in CHAR DEFAULT NULL
)
AS
BEGIN
SELECT * FROM my_table WHERE my_variable = v_my_var;
END;
But the SP above returns an error (Error (13.3): PLS-00428: an INTO clause in the following SELECT statement) when compiling.
So I used the slider to get the results and send back them. Updated the SP is,
create or replace
My_procedure PROCEDURE
(
v_my_var in CHAR NULL by DEFAULT,
cv_1 ON SYS_REFCURSOR
)
AS
BEGIN
OPEN cv_1 to SELECT * FROM my_table WHERE my_variable = v_my_var;
END;
Now, the SP is compiled successfully and return the result set correctly. My doubt is,
What is the right way to solve the problem that I mentioned above? Is there another way to get the select query result without using a cursor?
Please advice. Thank you for your help in advance.
RAMDepends on where you are calling from SP.
I assume you are using a windows client, as you referred to SQL Server.
The .NET Oracle provider, allowing return of pl/sql types and as you return only all columns in a single line, you could change your procedure to something like this:create or replace procedure my_procedure(v_my_var in char default null ,cv_1 OUT my_Table%rowtype) as rt my_table%rowtype; begin SELECT * into rt FROM my_table WHERE my_var = v_my_var; cv_1 := rt; END my_Procedure; /
-
Sequence within the stored procedure
Hi guys,.
Hoping you can help me here too. I have a stored procedure that takes a prepared external table/list and insert it into my database where it is required.
What I can't work out is how to add a fill to an ID column in this table with the next value in the sequence.
This is the procedure
And it's the line of code, I think I should add somewhere in the process, I'm not sure howCREATE OR REPLACE PROCEDURE BM120.GrowthRates_Update IS CURSOR c1 IS SELECT * FROM growthrates; BEGIN FOR gr IN c1 LOOP UPDATE forecast fc SET fc.change_sd = gr.change_sd, fc.change_sn = gr.change_sn, fc.change_wd = gr.change_wd, fc.change_wn = gr.change_wn, fc.last_modified_by = gr.last_modified_by WHERE fc.lmp = gr.lmp AND fc.dt = gr.dt AND fc.event = gr.event; IF SQL%ROWCOUNT <= 0 THEN INSERT INTO forecast (lmp, dt, event, change_sd, change_sn, change_wd, change_wn, committed, last_modified, last_modified_by) VALUES (gr.lmp, gr.dt, gr.event, gr.change_sd, gr.change_sn, gr.change_wd, gr.change_wn, gr.committed, gr.last_modified, gr.last_modified_by); INSERT INTO system_log (dt, detail) VALUES (sysdate, 'GROWTHRATES, Details for ' || gr.lmp || ' INSERTED'); END IF; INSERT INTO system_log (dt, detail) VALUES (sysdate, 'GROWTHRATES, ' || gr.lmp || ', ' || gr.dt || ', ' || gr.event || ', ' || gr.change_sd || ', ' || gr.change_sn || ', ' || gr.change_wd || ', ' || gr.change_wn || ', ' ); COMMIT; END LOOP; END; /
any ideas?SELECT 'GR'||TRIM(TO_CHAR(GROWTHRATES_SEQ.NEXTVAL,'00000')) INTO IO_ID FROM DUAL;
This code?
CREATE OR REPLACE PROCEDURE bm120.growthrates_update IS CURSOR c1 IS SELECT * FROM growthrates; io_id VARCHAR2 (32000); BEGIN FOR gr IN c1 LOOP SELECT 'GR' || TRIM (TO_CHAR (growthrates_seq.NEXTVAL, '00000')) INTO io_id FROM DUAL; UPDATE forecast fc SET fc.change_sd = gr.change_sd, fc.change_sn = gr.change_sn, fc.change_wd = gr.change_wd, fc.change_wn = gr.change_wn, fc.last_modified_by = gr.last_modified_by, fc.ID = io_id WHERE fc.lmp = gr.lmp AND fc.dt = gr.dt AND fc.event = gr.event; IF SQL%ROWCOUNT <= 0 THEN INSERT INTO forecast (lmp, dt, event, change_sd, change_sn, change_wd, change_wn, COMMITTED, last_modified, last_modified_by, ID ) VALUES (gr.lmp, gr.dt, gr.event, gr.change_sd, gr.change_sn, gr.change_wd, gr.change_wn, gr.COMMITTED, gr.last_modified, gr.last_modified_by, io_id ); INSERT INTO system_log (dt, detail ) VALUES (SYSDATE, 'GROWTHRATES, Details for ' || gr.lmp || ' INSERTED' ); END IF; INSERT INTO system_log (dt, detail ) VALUES (SYSDATE, 'GROWTHRATES, ' || gr.lmp || ', ' || gr.dt || ', ' || gr.event || ', ' || gr.change_sd || ', ' || gr.change_sn || ', ' || gr.change_wd || ', ' || gr.change_wn || ', ' ); COMMIT; END LOOP; END;
* 009 *.
Published by: 009 on March 31, 2010 21:19
-
By using the parameter as a column in a select statement inside the stored procedure.
I'm doing a variation of what follows. Can someone tell me how to use the parameter passed in the IN clause correctly? Thank you
Deleted table.drop table test1; drop table test2; CREATE TABLE TEST1 ( COL1 NUMBER ); CREATE TABLE TEST2 ( COL2 NUMBER ); insert into test1 values (1); insert into test2 values (1); commit; create or replace procedure test_sp (col_name varchar2) as var1 number; begin select col1 into var1 from test1 where col1 in (select col_name from test2); end; exec test_sp ('COL2');
Deleted table.
Table created.
Table created.
1 line of creation.
1 line of creation.
Validation complete.
Created procedure.
BEGIN test_sp ("COL2"); END;
Error on line 29
ORA-01722: invalid number
ORA-06512: on-site ".» TEST_SP', line 7
ORA-06512: at line 1You must use dynamic sql statements:
SQL> drop table test1; Table dropped. SQL> drop table test2; Table dropped. SQL> CREATE TABLE TEST1 2 ( 3 COL1 NUMBER 4 ); Table created. SQL> CREATE TABLE TEST2 2 ( 3 COL2 NUMBER 4 ); Table created. SQL> insert into test1 values (1); 1 row created. SQL> insert into test2 values (1); 1 row created. SQL> commit; Commit complete. SQL> create or replace procedure test_sp (col_name varchar2) 2 as 3 var1 number; 4 begin 5 execute immediate 'select col1 from test1 where col1 in (select ' || col_name || ' from test2)' into var1; 6 end; 7 / Procedure created. SQL> exec test_sp ('COL2'); PL/SQL procedure successfully completed. SQL>
SY.
-
selection of lines by using the stored procedure
All the
At the risk of asking something obvious, I would like to know if it is possible to wrap a selection within a stored procedure.
Create the abc as procedure
Start
date of b;
Select sysdate into double b;
end;
/
Question: I have a select complex which should be called from JAVA. I don't want to create a VIEW since at the request of the view, indeed I will do so: SELECT * FROM (my original query) which leads to performance.
I would like to be able to:
exec has;
This should give me the result of
SELECT
x, z, c
Of
one
;
How can I make this possible a stored procedure?
Thank you
Well, yes there are ways to do it, but first of all, you are mistaken in thinking that select * from
, would lead to a performance overhead. The optimizer based on CSSTidy will optimize the request to provide results without worrying so there is no noticeable performance difference. Java, you probably want to use a ref cursor and get java to retrieve the results back.
Example of refcursor function (demonstrated SQL * more I don't have Java)...
SQL > create or replace function test RETURN as sys_refcursor
cur_o 2 sys_refcursor;
3. start
4. open cur_o to select empno, ename from emp;
5 return cur_o;
6 end;
7.The function is created.
SQL > var r refcursor;
SQL > exec: r: = test();PL/SQL procedure successfully completed.
SQL > print r;
EMPNO, ENAME
---------- ----------
7369 SMITH
7499 ALLEN
7521 WARD
7566 JONES
7654 MARTIN
7698 BLAKE
7782 CLARK
7788 SCOTT
KING 7839
7844 TURNER
7876 ADAMS
JAMES 7900
7902 FORD
7934 MILLER14 selected lines.
-
2 refcursors within the same procedure using
Hello
Can we use 2 refcursors within the same procedure. This may seem strange. But I have a script to do so - one to dynamically check for some validations and another to return a result set.Yes, pass by the example below.
CREATE OR REPLACE PACKAGE CURSPKG AS
TYPE T_CURSOR IS REF CURSOR;
PROCEDURE (EMPCURSOR ON T_CURSOR OPEN_TWO_CURSORS,
DEPTCURSOR ON T_CURSOR);
END CURSPKG;
/
CREATE OR REPLACE PACKAGE BODY CURSPKG AS
PROCEDURE (EMPCURSOR ON T_CURSOR OPEN_TWO_CURSORS,
DEPTCURSOR ON T_CURSOR)
IS
V_CURSOR1 T_CURSOR;
V_CURSOR2 T_CURSOR;
BEGIN
V_CURSOR1 OPEN FOR SELECT * FROM EMP;
V_CURSOR2 OPEN FOR SELECT * FROM THE DEPARTMENT;
EMPCURSOR: = V_CURSOR1;
DEPTCURSOR: = V_CURSOR2;
END OPEN_TWO_CURSORS;
END CURSPKG;
/I hope that it would be useful.
-
Run the statement in a stored procedure with Out parameters and
Hi all
I have a stored procedure that calls a select statement. Here it is...
CREATE OR REPLACE PROCEDURE BLABLA_VIEW_PROCEDURE
* (BLABLA_KEY IN NUMBER, *)
XML_OUTPUT ON VARCHAR)
AS
BEGIN
SELECT SYS. XMLTYPE.getStringVal (OBJECT_VALUE) in XML_OUTPUT FROM BLABLA_VIEW WHERE extractValue (OBJECT_VALUE, ' / BLABLA_TYPE/BLABLA_KEY ') = 2876;
END;
Is to have both IN and OUT parameters as described above. I am able to compile and run the procedure.
The problem I want to share with everyone is...
I want to run the stored procedure together with a single EXEC command.
I tried different ways using the EXEC command but of no use.
Could someone help me?
Thanks in advance.
Published by: user10763276 on June 3, 2010 15:47Please visit the following...
sudhakar@ORCL>CREATE OR REPLACE PROCEDURE BLABLA_VIEW_PROCEDURE 2 (BLABLA_KEY IN NUMBER, 3 XML_OUTPUT OUT VARCHAR) 4 AS 5 BEGIN 6 XML_OUTPUT := BLABLA_KEY || ' and whatever else...'; 7 END; 8 / Procedure created. sudhakar@ORCL> sudhakar@ORCL>var XML_OUTPPUT varchar2(100); sudhakar@ORCL>exec BLABLA_VIEW_PROCEDURE (9151, :XML_OUTPPUT); PL/SQL procedure successfully completed. sudhakar@ORCL>print XML_OUTPPUT; XML_OUTPPUT -------------------------------------------------------------------------------- 9151 and whatever else... sudhakar@ORCL>
Post tells you...
var OUTPUT VARCHAR exec BLABLA_VIEW_PROCEDURE (9151, :OUTPUT); print OUTPUT
VARCHAR is not a valid TYPe to declare. Use VARCHAR2 (nnn) where nnn is a number.
VR,
Sudhakar B. -
Problem with States within the composition on the subpages only
I use a composition to create and menu/fly on boxes of content. So far, it it show I want. The problem is when I go to another page in the site, the styles do not stick to the menu/composition States.
It is very obvious if you go to this link:
Fly over the AREAS of PRACTICE and then click on INJURY. Once on the page of the injury, you can see that the applied styles do not stick on the 'normal' State of the menu.
It is meaningless since it's the same master page, that I use for the home page and States and the styles are there.
I appreciate the help that anyone may be able to offer!
Thank you!
Hmm, if you wish you can send me your .muse file in a private message and I'll have a look in a bit. If you do, please DO NOT send any personal login or password. Just the .muse file is all that is necessary.
-
Need help with update statement to be used in the stored procedure
I have the following update statement and I get "ORA-06512. Someone of you can help me.
----
UPDATE MO X SET X.MOMODEL = (SELECT Y.MOMODEL FROM MO Y WHERE Y.MOID = A_TEMP_INT3)
WHERE X.MOID in (UPDATE MO X SET X.MOMODEL = (SELECT Y.MOMODEL FROM MO Y WHERE Y.MOID = A_TEMP_INT3)
WHERE X.MOID in (A_TEMP_INT1, (select assocchild from mo_association
Connect prior assocchild = assocparent
Start with assocparent = A_TEMP_INT1)); (by selecting assocchild in mo_association
Connect prior assocchild = assocparent
Start with assocparent = A_TEMP_INT1));
----
Note: A_TEMP_INT1 and A_TEMP_INT3 are the values of cursor and is assigned to numeric values in the code.
Thanks for all the help in advance.
Kind regards
REDAWHERE X.MOID IN (SELECT ASSOCCHILD FROM MO_ASSOCIATION CONNECT BY PRIOR ASSOCCHILD = ASSOCPARENT START WITH ASSOCPARENT = A_TEMP_INT1 UNION SELECT A_TEMP_INT1 FROM DUAL );
Should work.
VR,
Sudhakar B. -
Call a package within a stored procedure
Hi people,
I created a package that works very well (well compiled).
Now, if I run my package via a command in the oracle command line:
run package_name.procedure_of_package ("arguments");
in this way, it works perfectly.
Inside of another procedure (procedure2) I do the same thing,
but it gives the error:
There is no function with the name of procedure_of_package in this scope.
I implemented on the owner of shema and I'm also running on the owner of the schema.
Thank you very much
PipocaHello
What do you do?...
If you want to call the "procedure1' according to the number of records in the table 'table_a', then you can do:
CREATE OR REPLACE PROCEDURE procedure2 AS v_teste number; BEGIN SELECT count(*) INTO v_teste FROM table_a; IF v_teste = 0 THEN package1.procedure1('AAA', 'BBB'); ELSE package1.procedure1('111', '222'); END IF; END;
-
by using the stored procedure in sql statement?
I have the following sample tables:
project id project name
====== ===============
1 project one
2 two project
3 three of the project
employee_id fname lname
=========== ============= =====
Amy 100a
Better B 200
Carrie 300 C
project number
=========== ===========
1,200 people
2 300
of 3 100
There's a getFullname (empployee_id) of the procedure in place that combines the fname lname full name
what I need to accomplish is the following.
project is created by employee
==============================
project a is created by better b
two project is created by carrie C
three project is created by amy A
but the rule is: you need to call the getFullName (employee_id) procedure to perform the above task and do not use join tables to get the employee full nameI suspect that you want something along the lines of
SELECT 'Project ' || p.project_name || ' was created by ' || get_full_name( pe.employee_id ) FROM project p, project_employee pe WHERE p.project_id = pe.project_id
If you need other attributes in the employee table, you can join at the table of the employees as well.
Justin
-
Cannot run RUN IMMEDIATELY statement in a stored procedure.
Hi people,
I use oracle 10g. In which I tried a procedure with the follwing code and am thrown with the error that says:
Procedure has been created, but the error occurs during the execution of it.why can I get this error even if I have the DBA privilege.? authorization is trolling for me?. Help me with your suggestions.thanks in advance.SQL> create or replace procedure ptable(ptab varchar2) is 2 lstmt varchar(200); 3 begin 4 lstmt:='CREATE TABLE '||ptab||'(a int,b varchar2(30)) '; 5 execute immediate lstmt; 6 end; 7 / Procedure created. SQL> exec ptable('hos'); BEGIN ptable('hos'); END; * ERROR at line 1: ORA-01031: insufficient privileges ORA-06512: at "VIDYA.PTABLE", line 5 ORA-06512: at line 1
Regarding
VIDSCheck if you have the permission to CREATE ANY TABLE , if not, are looking for it.
* 009 *.
-
call a packed stored procedure from within another stored procedure
I have a stored procedure (STROKEQC) on a scheme that is not in a package. I want to be able to call a procedure stored that IS inside a package on the same scheme of STROKEQC. When I try the syntax below, I get an error "no function with name 'PARTICIPANTSPECIFICEDITS' exists in this area." That the procedure exists.
Is not the way to do inside a stored procedure?/*Generate admin field data*/ execute immediate QCPROCEDURES.PARTICIPANTSPECIFICEDITS('ALL'); execute immediate QCPROCEDURES.GENERATE_SURGYEAR_ERRFLAG;
Thank you!
EvaHi, Eva,.
You need not EXECUTE IMMEDIATE to call a stored procedure (including a procedure in a package) on the other. Just use the name and the arguments (if any):
QCPROCEDURES.PARTICIPANTSPECIFICEDITS('ALL'); QCPROCEDURES.GENERATE_SURGYEAR_ERRFLAG;
I guess qcprocedures is the package name, and participantspecificedits and generate_surgyear_errflag are procedures in this package.
In case you're wondering, the error was probably because you do not have a variable called participantspecificedits. If you had a dynamic code in a string called variable x, then "EXECUTE IMMEDIATE x"; would be the way to run it.
-
Select the query within the PL/SQL block.
Hello Experts,
I'm just a beginner with PL/SQL.
If I write a select query of client like fire against a database and SQL dev, it gives me result.
For example: select * from employee;
Now suppose that when I use the same query within a PL/SQL block:
Declare
Start
Select * from employee;
end;
/
It gives error during execution, by mentioning that an INTO should etc...
I have my doubts here:
1. is it impossible to use a simple select statement within a PL/SQL block (If yes why?)
I know it's a very basic question, I tried to search it on the forum but could not find the thread, please redirect me to the link if it is already the answer.Please read this first. may ask why?
http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28370/TOC.htm
-
How can I fix the State of the media - media disconnected?
I have a laptop that is running Windows XP, and I'm having problems connecting to the Internet and my router. I have another laptop running Windows 7, which connects well, including mobile phones and game consoles that can still connect to the router. I type in "ipconfig" in the command prompt and the message media disconnected rises. The same message appears in Windows 7 but the laptop connects to the router and the Internet fine.
I tried to update, deactivation and activation of the network card, uninstall the network adapter and then put it back, and I don't always get no Internet connection.You have ideas or suggests this can solve my problem?Have you tried to reset the link speed / Duplex mode on 10 Mbit/s/full duplex? I got the same error for months while he was trying to resurrect my pc and could not figure out until I read somewhere that most of the older NIC is only supported this setting one sometimes will not work if the parameter is 'auto negotiation'.
Click Start, right-click on 'my computer' and select Properties. Click on the "hardware" tab and select "Device Manager". Click on the sign '+' next to maps network to expand and right-click the NETWORK adapter, select a property in the Advanced tab, scroll down to link speed/duplex mode, click it. Set the value in the box on the right side of the page, click on OK, to see if it solved your problem.
It will be useful.
Maybe you are looking for
-
Retrieve the backup Time Machine to iPhoto with El Capitan
I had issues with my hard drive and decided I do a backup of my computer using Time Machine, install a new hard drive and reinstall my OS X. Once I had installed my new hard drive, I used my old one (via a 2.5 USB eSATA cable) to install from the rec
-
Mail page is pulled up in the upper left side of the page...
-
Installation of Windows XP on Satellite P200D-106
Hello! some application that I use Don t support windows vista so I decided to install xp and I understand that I don't have drivers for xp. Is - any way to get it?
-
Phone is not charging, flashing notification.
Good so since I installed 2.1 my battery was acting weird. This morning, I plugged my phone charge about 25%, it is then loaded to approximately 37%. When I think about a good 10 minutes later, it came down to 22%. I have then looked back later, it h
-
Why apear internet gateways in network connections
In Windows XP, I click on network connections and internet gateway is sometimes there and sometimes not. Why is this? Thanks for any help. Jack