Forms Data-Block based on stored procedures - REF CURSOR feature NOT FUNCTIONING
This topic is related to another topic in this forum titled "FORMS HOW TO SET QUERY SOURCE ARGUMENTS??" I posted my message there as well. I am posting as a NEW TOPIC so that it catches the attention of Oracle Support.
I built a data form based on a stored procedure and REF CURSOR IN OUT parameter.
My procedure takes a IN parameter to fill in the criteria for the OPEN <cursor_variable> select ... where ... statement.
In the Value setting of the Query source Arguments , I set the VALUE to ":BLOCK_NAME.ITEM_NAME" at design time to supply the input value to the procedure. this works to the extent of making available the form item value to the stored procedure parameter. I verified this by doing an insert into some debug table , of the incoming parameter value inside my stored procedure.
The cursor gets opened properly into the REF cursor variable. I verified this by fetching a record into a local variable and inserting the value into a debug table again in the stored procedure.
(I took care to close and re-open the REF cursor variable again - so that the front-end can continue to fetch it from the first record. )
***** PROBLEM **************
But the front end forms runtime is giving me a FRM-40301 - query returned no records even though the REF cursor is returned properly opened.
Did anybody else face the same problem ??
Please post what you found.
Thanks,
Shankaran
null
This topic is discussed at length in another thread "How Set Value For Query DataSource Arguments?"
But I am posting the findings here as well.
THIS TOPIC IS CLOSED.
My Bad. The problem Cause : I did not include all columns in the
cursor rowtype in the Data-block. In the wizard for the data block , I selected ONLY the columns that I needed. But I was doing a Select * from <my_table> in my open cursor <Cursor-Variable> .... The <Cursor Variable>
itself was declared <my_table>%rowtype
FIX : The Data Block structure (columns included as items) should match the cursor record Structure. One may or may not
display all the columns in the LAYOUT though.
But I don't understand why it gives such a misleading message like FRM-40301 Query retrieved no records. Oracle Team fix it.
Hope this helps people who face the same problem.
Thanks,
Similar Messages
-
Forms9i, data block based on stored procedures, refresh on update ?
Hi,
I am using
Forms [32 Bit] Version 9.0.2.9.0 (Production)
Oracle9i Enterprise Edition Release 9.2.0.5.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.5.0 - Production
Oracle Toolkit Version 9.0.4.0.23 (Production)
PL/SQL Version 9.0.1.3.1 (Production)
Oracle Procedure Builder V9.0.2.0.7 Build #1022 - Production
PL/SQL Editor (c) WinMain Software (www.winmain.com), v1.0 (Production)
Oracle Query Builder 9.0.2.0.0 - Production
Oracle Virtual Graphics System Version 9.0.1.5.0 (Production)
Oracle Tools GUI Utilities Version 9.0.4.0.9 (Production)
Oracle Multimedia Version 9.0.4.0.9 (Production)
Oracle Tools Integration Version 9.0.2.0.0 (Production)
Oracle Tools Common Area Version 9.0.1.0.0
Oracle CORE 9.0.1.2.0 ProductionI have a module based on stored procedures. I have defined query, lock and update procedure. All of them are working as they should, I mean that when looking at the input and output from these procedures I don't see anything blatantly wrong.
Now, when I update a table field in the form and call the update stored procedure, this procedure takes the updated values in considerations, updates some more fields, and remove some records.
It is working as it should, except for two details :
1- I don't see the values updated by the procedure in the Form;
2- even though some records were removed from the table by the procedure, I still see all my records.
Is there a way to display the returned table?
And, is there any documentation about data block based on stored procedures, what are the required signatures and limitations of those stored procedures, what a lock procedure is supposed to do (mine does 'null;' ...), how to map a collection type defined in Oracle to a Form data block ? Any link will be appreciated, I have found half a dozen page vaguely detailing this on Google, but nothing that can compare to a usual Oracle manual. Maybe I have missed something.
Thank you for your help.
adsmYes, I was hoping to use these procedures to map the collection type returned to the database to the block data. I guess I was wrong. Except for the initial query and reading some other information from the database, I don't have to use these procedures as I do not write anything to it.
Thank you for your help, I will go on from there.
So, it means that I will have to iterate through my collection inside Forms and manipulate my data row by row. Or, is there a way to pass an Oracle collection type between the database and the Forms client and have it displayed without having to iterate through the rows and mapping each field?
adsm -
Data block based on stored procedure with input arguments
Hi,
I am able to create a data block based on stored procedure.
but I want that procedure to take input arguments as well and I am facing the issue while setting the value for that input arguments from another block item.
Please somebody help, How to set the value for input argument from another control block- item?.(Note :Data block is based on the stored procedure)
Thanks in Advance,
Anandan MuthukannanI did exactly the same way you mentioned.
But while building the form, The call to the procedure in 'QUERY-PROCEDURE' trigger has been modified like this way
procedure_name(qp_data,':BLOCK.ITEM');
so in procedure i am getting the value as ':BLOCK.ITEM' not the expected value. -
Data Blocks Based on Stored Procedures
Is it possible to to create a data block based on a stored procedure, and create a dynamic list as a drop down box?
I have a form that runs successfully that has a data block based on a stored procedure. I add my trigger to create and populate the record group. Then in the Property Palette, when I change ITEM TYPE from TEXT ITEM to LIST ITEM, I receive the following runtime error:
FRM-40350: Query caused no records to be retrived.
Note: the tlist/list item runs successfully on a data block based on a table.1) go to the block property to remove the same item column, then re-add the item; Since the property may remember the old text type;
make sure the record value for the list tiem from stored procedure is among the list elements!
Last sort is to do:
2) you may re-create your gui based on the table by setting the list type this time, then set the block property to be based on the stored procedure. -
Trying to develop a form having a block based
on stored procedure. My form works fine if
the stored procedure having REF CURSOR as one
of the argument but if I am using dynamic SQL
in my procedure I can not use Strong REF CURSOR, so I had to use Pl/Sql Table as one of the parameter in the proceudre.
In that case when I run my form and Execute the query it just comes out of the form without displaying anything and also it doesn't throw any error.
Don't know what I am doing wrong.
Pl. Help...
nullI drilled down the proble further and identified that i can
recreatr the problem in any 7.3.4 database ....
But in 8.0.5 it's working fine .....
Is developer 6.0 is going to support Oracle 7.3.4
it'll be highly appreciated if any one from Oracle development
team can give me a response
Thanks in advance...
Lebon Mathew (guest) wrote:
: Problem : If a block value is refered in
: a LOv - record group query
: the form cannot adjust the out put .. and
: is not generating.....
: Record group query which works :
: select security_role, sec_role_desc, database_role
: from security_role
: where wnd_appln = 'XXXXXXXXX'
: order by security_role, database_role
: Record group query which is not working :
: select security_role, sec_role_desc, database_role
: from security_role
: where wnd_appln = :APP_ROLES_BK.wnd_appln
: order by security_role, database_role
: Error Generated :
: FRM-30064: Unable to parse statement icrgg/icrggc: hicrg.
: Record Group SECURITY_ROLE_LOV
: Form: EMPLOYEE
: FRM-30085: Unable to adjust form for output.
: Table structure :
: CREATE TABLE security_role
: security_role VARCHAR2(15) NOT NULL,
: sec_role_desc VARCHAR2(20) NOT NULL,
: open_nsr VARCHAR2(1),
: open_pkt VARCHAR2(1),
: chg_wk_grp VARCHAR2(10),
: asgn_anlst VARCHAR2(10),
: updt_oth_wkgp_pkt VARCHAR2(1),
: admin_tasks VARCHAR2(1),
: create_po VARCHAR2(1),
: billing_changes VARCHAR2(1),
: invoice_changes VARCHAR2(1),
: change_owner VARCHAR2(1),
: wnd_appln VARCHAR2(15),
: database_role VARCHAR2(20)
: PCTFREE 10
: PCTUSED 40
: INITRANS 1
: MAXTRANS 255
: TABLESPACE wa0dat0t01
: STORAGE (
: INITIAL 32768
: NEXT 8192
: PCTINCREASE 0
: MINEXTENTS 1
: MAXEXTENTS 121
: w@w Lebon Mathew
: WellsFargo - Telecom Applications
: (415)-477 6445
null -
Is BC4J a viabl option for database with stored procedure (ref cursor) API?
I'm about to begin a Web application development project. As foundation, we have a (Oracle) database of certain complexity that have a data access API developed with PL/SQL packages.
This API is designed to get data through stored procedures/functions that return REF CURSOR.
Personally I have been investigating about Oracle ADF/JSF, and a number of others J2EE technologies, and at this moment I am doubting if ADF BC are a viable option to my development team.
I think this because I have noticed that one of the great drawback in ADF BC is the lack of simplicity to get data through stored procedures/functions that returns REF CURSORS.
I have been looking for documentation and the only thing that I have found are two examples:
1.- One that really do not work (fails in get data from ref cursor): ADF BC StoredProcedure Sample application.
2.- And other published by Steve Muench in
http://radio.weblogs.com/0118231/stories/2003/03/03/gettingAViewObjectsResultRowsFromARefCursor.html. This sample works fine.
But, the problem with the approach of this last article is the amount (and complexity) of the code necessary to make so basic and recurrent operation as is "obtain data through a stored procedure (ref cursor)".
Below it is the code that I have constructed to call a function that returns a ref cursor (based on steve's article).
If this is the only way to make this (historically so basic and simple) task, then it is obvious that BC is not a viable technology to my (or I am in a mistake?), since we have about 50 stored procedures/functions to access the underlying data; that stored procedures/functions are key to development of the new application (and, still more, currently are used to anothers apps ).
By all this, I would like consult to Oracle's people:
1.- I really must reject BC as technology to implement this project ?
2.- It is possible to access stored procedures in a simpler way using BC?
3.- If the answer to 2 is NOT: in near future, the BC team has plans to give more support to the simple access to stored procedures?
4.- If the answer to 3 is NOT: what another technology you recommend to construct my data access/business tier and still be able to using the others characteristics of ADF?
Thank you very much for your guidelines.
Regards, RL.
** And the code!!!
** ### I am forced to do this for each call to a procedure???? ###
package myrefcursor.model;
import java.math.BigDecimal;
import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Types;
import oracle.jbo.JboException;
import oracle.jbo.domain.NullValue;
import oracle.jbo.domain.Number;
import oracle.jbo.server.DBTransaction;
import oracle.jbo.server.ViewObjectImpl;
import oracle.jbo.server.ViewRowImpl;
import oracle.jbo.server.ViewRowSetImpl;
import oracle.jdbc.driver.OracleCallableStatement;
import oracle.jdbc.driver.OracleTypes;
public class TraePolizasViewImpl extends ViewObjectImpl {
private static final String SQL = "begin ? := PKG_PRUEBA.trae_polizas(?);end;";
private static final String COUNTSQL = "begin ? := PKG_PRUEBA.count_trae_polizas(?);end;";
public TraePolizasViewImpl() {
protected void executeQueryForCollection(Object qc,Object[] params,int numUserParams) {
BigDecimal rut_contratante = null;
Object[] theUserParam = null;
System.out.println(params);
System.out.println(params[0]);
if (params != null)
theUserParam = (Object[]) params[0];
//if (theUserParam != null && theUserParam.length > 0 )
if (! (theUserParam[1] instanceof NullValue) )
rut_contratante = (BigDecimal)theUserParam[1];
storeNewResultSet(qc ,retrieveRefCursor(qc, rut_contratante));
super.executeQueryForCollection(qc, params, numUserParams);
protected void create() {
getViewDef().setQuery(null);
getViewDef().setSelectClause(null);
setQuery(null);
protected ViewRowImpl createRowFromResultSet(Object qc, ResultSet rs) {
rs = getResultSet(qc);
ViewRowImpl r = createNewRowForCollection(qc);
try {
populateAttributeForRow(r,0, nullOrNewNumber(rs.getBigDecimal(1)));
populateAttributeForRow(r,1, rs.getString(2));
catch (SQLException s) {
throw new JboException(s);
return r;
protected boolean hasNextForCollection(Object qc) {
ResultSet rs = getResultSet(qc);
boolean nextOne = false;
try {
nextOne = rs.next();
if (!nextOne) {
setFetchCompleteForCollection(qc, true);
rs.close();
catch (SQLException s) {
throw new JboException(s);
return nextOne;
protected void releaseUserDataForCollection(Object qc, Object rs) {
ResultSet userDataRS = getResultSet(qc);
if (userDataRS != null) {
try { userDataRS.close(); }
catch (SQLException s) { ; }
super.releaseUserDataForCollection(qc, rs);
public long getQueryHitCount(ViewRowSetImpl viewRowSet) {
return viewRowSet.getRowCount();
private ResultSet retrieveRefCursor(Object qc, BigDecimal rut_contratante) {
CallableStatement st = null;
try {
st = getDBTransaction().createCallableStatement(SQL, DBTransaction.DEFAULT);
st.registerOutParameter(1,OracleTypes.CURSOR);
if (rut_contratante == null)
st.setNull(2, Types.NUMERIC);
else
st.setBigDecimal(2, rut_contratante);
st.execute();
ResultSet rs = ((OracleCallableStatement)st).getCursor(1);
rs.setFetchSize(getFetchSize());
return rs ;
catch (SQLException s) {
throw new JboException(s);
finally {try {st.close();} catch (SQLException s) {;}}
private void storeNewResultSet(Object qc, ResultSet rs) {
ResultSet existingRs = getResultSet(qc);
if (existingRs != null) {
try {existingRs.close();} catch (SQLException s) {;}
setUserDataForCollection(qc,rs);
hasNextForCollection(qc); // Prime the pump with the first row.
private ResultSet getResultSet(Object qc) {
return (ResultSet)getUserDataForCollection(qc);
private static Number nullOrNewNumber(BigDecimal b) {
try {
return b != null ? new Number(b) : null;
catch (SQLException s) { ; }
return null;
public BigDecimal getprutcontratante() {
return (BigDecimal)getNamedWhereClauseParam("prutcontratante");
public void setprutcontratante(BigDecimal value) {
setNamedWhereClauseParam("prutcontratante", value);
}no?
-
Block based on Stored Procedures & Locking_Mode
Hello,
I'm creating a block in Forms 6.0.8 based on Stored Procedures. I'm using the example given in Metalink doc 52778.1. Updates to data work fine if locking_mode = 'Immediate'. If I set locking_mode to 'Delayed' and run the form, when I try to update and commit something, then the IF condition in lock-procedure (grp_lock) always returns TRUE and I run into the exception trapped there. It appears that Forms is passing NEW values in p_grp_data if locking_mode is Delayed and this is causing the problem. Is there any thing I could do in the form or procedure (preferably in the procedure) to solve this problem ? I'm trying to write procedures that will work with both Immediate and Delayed locking_modes
thanks in advance..
-- Table and package source:
-- GRP
create sequence grp_s
create table grp
id number constraint grp_pk primary key,
name varchar2(10) not null constraint grp_uk unique,
description varchar2(30) not null,
active varchar2(1) default 'Y'
create or replace trigger grp_bri before insert on grp for each row
begin
select grp_s.nextval
into :new.id
from dual ;
end ;
CREATE OR REPLACE PACKAGE grp_pkg AS
TYPE grpidrec IS RECORD( id grp.id%TYPE ) ;
TYPE grprec IS RECORD ( id grp.id%type, name grp.name%type, description grp.description%type, active grp.active%type ) ;
TYPE grp_cursor IS REF CURSOR RETURN grp%rowtype ;
TYPE grp_tab IS TABLE OF grp%rowtype INDEX BY BINARY_INTEGER ;
TYPE grp_id_tab IS TABLE OF grpidrec INDEX BY BINARY_INTEGER ;
PROCEDURE grp_refcur( p_grp_data IN OUT grp_cursor,
p_group_name IN grp.name%type ) ; -- use if a ref cursor is required
PROCEDURE grp_query( p_grp_data IN OUT grp_tab, p_group_name IN grp.name%TYPE ) ;
PROCEDURE grp_insert( p_grp_data IN grp_tab ) ;
PROCEDURE grp_update( p_grp_data IN grp_tab ) ;
PROCEDURE grp_delete( p_grp_data IN grp_id_tab ) ;
PROCEDURE grp_lock( p_grp_data IN grp_tab ) ;
END grp_pkg ;
sho err
create or replace package body grp_pkg as
-- ================================================================================
PROCEDURE grp_refcur( p_grp_data IN OUT grp_cursor, p_group_name IN grp.name%type ) AS
begin
open p_grp_data FOR select id, name, description, active
from grp
where name = nvl( p_group_name, name ) ;
end ;
-- ================================================================================
PROCEDURE grp_query( p_grp_data IN OUT grp_tab, p_group_name IN grp.name%TYPE ) AS
i number ;
CURSOR grp_select IS
SELECT id, name, description, active
FROM grp
WHERE name = nvl( p_group_name, name ) ;
begin
OPEN grp_select ;
i := 1 ;
LOOP
FETCH grp_select INTO p_grp_data(i).id, p_grp_data(i).name, p_grp_data(i).description, p_grp_data(i).active ;
EXIT WHEN grp_select%NOTFOUND ;
i := i + 1 ;
END LOOP ;
end ;
-- ================================================================================
PROCEDURE grp_insert( p_grp_data IN grp_tab ) AS
i NUMBER ;
begin
FOR i in p_grp_data.FIRST .. p_grp_data.LAST
LOOP
INSERT INTO grp( name, description, active )
VALUES ( p_grp_data(i).name, p_grp_data(i).description, p_grp_data(i).active ) ;
END LOOP ;
end ;
-- ================================================================================
PROCEDURE grp_update( p_grp_data in grp_tab ) AS
i binary_integer ;
rec_modified exception ;
BEGIN
FOR i in p_grp_data.first .. p_grp_data.last LOOP
UPDATE grp
SET name = p_grp_data(i).name,
description = p_grp_data(i).description,
active = p_grp_data(i).active
WHERE id = p_grp_data(i).id ;
if sql%rowcount = 0 then
raise rec_modified ;
else
-- success
null ;
end if ;
END LOOP ;
exception
when rec_modified then
raise_application_error(-20006, 'Record already modified' ) ;
when others then
raise_application_error(-20007, 'Other error : ' || sqlerrm ) ;
END ;
-- ================================================================================
PROCEDURE grp_delete( p_grp_data IN grp_id_tab ) AS
i BINARY_INTEGER ;
begin
FOR i IN p_grp_data.FIRST .. p_grp_data.LAST LOOP
DELETE FROM grp
WHERE name = p_grp_data(i).id ;
END LOOP ;
end grp_delete ;
-- ================================================================================
PROCEDURE grp_lock( p_grp_data IN grp_tab ) AS
i BINARY_INTEGER ;
grec grprec ;
err varchar2(255) ;
errcd number ;
rec_modified exception ;
begin
FOR i in p_grp_data.FIRST .. p_grp_data.LAST LOOP
begin
SELECT id, name, description, active
INTO grec
FROM grp
WHERE id = p_grp_data(i).id
FOR UPDATE OF description NOWAIT ;
-- this part returns true
-- if locking_mode = 'Delayed'
-- Forms is passing NEW values in p_grp_data if mode is Delayed
-- and OLD values if mode is Immediate
if ( grec.name != p_grp_data(i).name
OR grec.description != p_grp_data(i).description
OR grec.active != p_grp_data(i).active ) THEN
raise rec_modified ;
end if ;
exception
when no_data_found then
raise_application_error( -20007, 'Record deleted by another user' ) ;
when rec_modified then
raise_application_error(-20006, 'Record modified by another user' ) ;
when others then
raise_application_error(-20009, 'Others' ) ;
end ;
END LOOP ;
end ;
-- ================================================================================
end grp_pkg ;
show error package body grp_pkgYes, I was hoping to use these procedures to map the collection type returned to the database to the block data. I guess I was wrong. Except for the initial query and reading some other information from the database, I don't have to use these procedures as I do not write anything to it.
Thank you for your help, I will go on from there.
So, it means that I will have to iterate through my collection inside Forms and manipulate my data row by row. Or, is there a way to pass an Oracle collection type between the database and the Forms client and have it displayed without having to iterate through the rows and mapping each field?
adsm -
Troubleshooting blocks based on stored procedures
Hello,
I'm creating a form block that is based on a stored procedure. I've followed the steps in note 66887.1 "Basing a Block on a Stored Procedure - Sample Code", but am still having problems. Currently, the stored procedure runs successfully when I call it from SQL*Developer, but I receive a "FRM-40301: Query caused no records to be retrieved. Re-enter" when I run it from the form.
I'm not sure how to troubleshoot this problem. I tried using the Forms Debugger, but that didn't seem to provide any visibility to what Forms was doing. Can anyone suggest a way to troubleshoot problems like this?
Thanks,
CindyHi Tony
Did youuse a REF CURSOR or table of records??I'm using a REF CURSOR.
Here's the signature of the procedure I'm specifying as the "Query Data Source Name":
PROCEDURE do_query(p_combined IN varchar2,
p_legal IN varchar2,
p_maiden IN varchar2,
p_preferred IN varchar2,
p_indrfn IN varchar2,
p_birthdate IN varchar2,
p_sex IN number,
p_unit IN number,
p_writingsys1 IN varchar2,
p_writingsys2 IN varchar2,
results IN OUT name_query_cur)
Here's the definition of the name_query_cur ref cursor type:
TYPE return_rec IS RECORD(
indrfn cms_name.naindrfn%TYPE,
legal varchar2(485),
maiden varchar2(485),
preferred varchar2(485),
birthdate varchar2(8),
unit cms_unit.ununit%TYPE,
sex cms_individual.insex%TYPE,
baptized cms_individual.inbaptized%TYPE,
priesthood cms_individual.inpriesthood%TYPE,
unitcountry cms_individual.inunitcountry%TYPE,
secured cms_individual.insecured%TYPE,
phsecured cms_individual.inphsecured%TYPE,
privilege cms_individual.inprivilege%TYPE,
confidential cms_individual.inconfidential%TYPE,
recordstatus cms_individual.inrecordstatus%TYPE
TYPE name_query_cur IS REF CURSOR RETURN return_rec;
Do you have all the columns listed in the Query Data Source Columns? In "Query Data Source Columns", I have listed all the columns of the ref cursor. So, I have the following columns specified there:
indrfn
legal
maiden
preferred
birthdate
unit
sex
baptized
priesthood
unitcountry
secured
phsecured
privilege
confidential
recordstatus
And did you set the Query Data Source Arguments??Yes, I set this to match the arguments to the do_query routine. I gave each argument the exact same name as it had in the do_query routine. So, this is currently set as:
p_combined IN varchar2 value=:control.combined
p_legal IN varchar2 value= :member_lov.legal
p_maiden IN varchar2 value= :member_lov.maiden
p_preferred IN varchar2 value= :member_lov.preferred
p_indrfn IN varchar2 value= :member_lov.indrfn
p_birthdate IN varchar2 value= :member_lov.birthdate
p_sex IN number value= :member_lov.sex
p_unit IN number value= :member_lov.unit
p_writingsys1 IN varchar2 value= 'Latn'
p_writingsys2 IN varchar2 value= left this blank
results IN OUT name_query_cur value=left this blank
The blocks based on the ref cursor should have all the items which arethere in the ref cursor type. If the number of items does not match the
individual items in the ref cursor type when you execute query you'll get FRM-40350 Query caused no records to be retrieved.
The items in the block exactly match the ref cursor. They are the exact same names, types, and in the exact same order as the ref cursor columns.
Make sure you have listed all the columns, and make sure your REF Cursor returns rows in SQL*Plus.The ref cursor returns rows in SQL*Plus, just not in Forms.
Can you see anything I've missed or done wrong? -
Block based on stored procedure
I need to create a matrix-like form. I think one option is to base the block on a stored procedure. The idea is to create a PL/SQL Table based on a PL/SQL record of (x)number of colums. My problem is to access each column without using the (.)notation as i use loops to populate these columns. Also once i've manage to create the table, how can i use it to populate the block?? Do i have to use REF Cursors?? I know that REF cursors point to the result set of a query. Can i use them to point to a PL/SQL table as well and if so HOW??
I've already had a look at the demo but it uses a REF Cursor with a query to populate the block...not a PL/SQL table
Please help...i'm going bananas with this!!!!!
Nicola MereuThe Stored Prodedures that can be used to populate a block can either return a refcursor as you've noted - or a PL/SQL table of records.
It sounds like that is the type you need to use.
Note 66887.1 on metalink is a good place to start -
Enter Query Mode with Block Based on Stored Procedure
How can I get the ENTER QUERY mode to work when the data block is based on a stored procedure?
Thank you for your review.
Because the package is long, I stripped most of it out, but left the basics. After I stripped out the code, I ran the new code under a new user. Under the new user I built I new form, tested it, and I still cannot use the ENTER QUERY mode to retrieve the correct record. Query always returns the first record. I have included table structure and 3 test records.
CREATE TABLE FR_Charge
( FR_Charge_ID NUMBER(8),
FR_Charge_Code VARCHAR2(8) CONSTRAINT FR_Charge_Code_nn NOT NULL,
FR_Charge_Code_DESC VARCHAR2(35),
FR_Charge_Code_CMT VARCHAR2(50),
CONSTRAINT FR_Charge_pk PRIMARY KEY (FR_Charge_ID)
CREATE SEQUENCE FR_Charge_SEQ;
INSERT INTO FR_Charge
VALUES(FR_Charge_SEQ.NEXTVAL,'0.0WS','E-Mail Notification', NULL);
INSERT INTO FR_Charge
VALUES(FR_Charge_SEQ.NEXTVAL,'0.1', 'Shipping', NULL);
INSERT INTO FR_Charge
VALUES(FR_Charge_SEQ.NEXTVAL,'0.12', 'Shipping Charges', NULL);
--Package follows
CREATE OR REPLACE PACKAGE DataCard_Pkg
AUTHID CURRENT_USER
AS
-- The following records defines the data structure needed by the FR_Card.
TYPE FR_Charge_Record IS RECORD
( FR_Charge_ID FR_Charge.FR_Charge_ID%TYPE,
FR_Charge_Code FR_Charge.FR_Charge_Code%TYPE,
FR_Charge_Code_DESC FR_Charge.FR_Charge_Code_DESC%TYPE,
FR_Charge_Code_CMT FR_Charge.FR_Charge_Code_CMT%TYPE
-- REF CURSOR definition used by the query procedure.
TYPE FR_Charge_REFCUR IS REF CURSOR RETURN FR_Charge_Record;
-- INDEX OF TABLES used for the DML Operation procedures.
TYPE FR_Charge_Table IS TABLE OF FR_Charge_Record
INDEX BY BINARY_INTEGER;
--Define Procedure Specifications
PROCEDURE FR_Charge_Query (DMLResultSet IN OUT FR_Charge_REFCUR);
PROCEDURE FR_Charge_Lock (DMLResultSet IN OUT FR_Charge_Table);
PROCEDURE FR_Charge_Insert (DMLResultSet IN OUT FR_Charge_Table);
PROCEDURE FR_Charge_Update (DMLResultSet IN OUT FR_Charge_Table);
PROCEDURE FR_Charge_Delete (DMLResultSet IN OUT FR_Charge_Table);
END DataCard_Pkg;
CREATE OR REPLACE PACKAGE BODY DataCard_Pkg
AS
PROCEDURE FR_Charge_Query (DMLResultSet IN OUT FR_Charge_REFCUR)
IS
BEGIN
OPEN DMLResultSet FOR
SELECT FR_CHARGE.FR_Charge_ID,
FR_CHARGE.FR_Charge_Code,
FR_CHARGE.FR_Charge_Code_DESC,
FR_CHARGE.FR_Charge_Code_CMT
FROM FR_Charge;
END FR_Charge_Query;
PROCEDURE FR_Charge_Lock (DMLResultSet IN OUT FR_Charge_Table)
AS
x_index NUMBER := 1;
x_count NUMBER := DMLResultSet.COUNT;
x_dummy_var VARCHAR2(1);
BEGIN
FOR x_index IN 1..x_count LOOP
SELECT 'X'
INTO x_dummy_var
FROM FR_Charge
WHERE FR_Charge_ID = DMLResultSet(x_index).FR_Charge_ID
FOR UPDATE NOWAIT;
END LOOP;
END FR_Charge_Lock;
PROCEDURE FR_Charge_Insert (DMLResultSet IN OUT FR_Charge_Table)
AS
x_index NUMBER := 1;
x_count NUMBER := DMLResultSet.COUNT;
BEGIN
FOR x_index IN 1..x_count LOOP
INSERT INTO FR_Charge
( FR_Charge_ID,
FR_Charge_Code,
FR_Charge_Code_DESC,
FR_Charge_Code_CMT
VALUES
( FR_Charge_SEQ.NEXTVAL,
UPPER(DMLResultSet(x_index).FR_Charge_Code),
DMLResultSet(x_index).FR_Charge_Code_DESC,
DMLResultSet(x_index).FR_Charge_Code_CMT
END LOOP;
END FR_Charge_Insert;
PROCEDURE FR_Charge_Update (DMLResultSet IN OUT FR_Charge_Table)
AS
x_index NUMBER := 1;
x_count NUMBER := DMLResultSet.Count;
BEGIN
FOR x_index IN 1..x_count LOOP
UPDATE FR_Charge
SET FR_Charge_Code = UPPER(DMLResultSet(x_index).FR_Charge_Code),
FR_Charge_Code_DESC = DMLResultSet(x_index).FR_Charge_Code_DESC,
FR_Charge_Code_CMT = DMLResultSet(x_index).FR_Charge_Code_CMT
WHERE FR_Charge_ID = DMLResultSet(x_index).FR_Charge_ID;
END LOOP;
END FR_Charge_Update;
PROCEDURE FR_Charge_Delete (DMLResultSet IN OUT FR_Charge_Table)
AS
x_index NUMBER := 1;
x_count NUMBER := DMLResultSet.Count;
BEGIN
FOR x_index IN 1..x_count LOOP
DELETE FROM FR_Charge
WHERE FR_Charge_ID = DMLResultSet(x_index).FR_Charge_ID;
END LOOP;
END FR_Charge_Delete;
END DataCard_Pkg; -
Master-Detail with 2 blocks based in stored procedure doesn't work.
Hi. I'm Oscar and I'm new for here.
I have a problem that i can't find the correct answer to solve it.
Well. I've created a form with 2 blocks. Both of them have the Query Data Source Type Property to "Procedure", and both procedures on database returns one ref cursor of a record type each one.
BLOCK BL_COMPETICIONES --> query data source: p_get_competiciones (p_Cursor is cursor of record (CODIGO NUMBER,
NOMBRE VARCHAR2(50),
SETCRICKETSN VARCHAR2(1),
SET01SN VARCHAR2(1),
FECHAINICIO DATE,
FECHAFIN DATE).
On triggers (on-lock, on-insert, on-delete and on-update) I have the call to the corresponding stored procedure to lock, insert, delete or update.
Well, when i've only this block in form, the form works correctly.
But when I added a second block (which is suppossed to be a detailed data from the first one), and after I've assigned the query procedure and created the relation between both blocks, then run the form and try to execute query on first block, returning records correctly, but then, when execution goes to the program unit "query_master_details", the sentence "execute query" doesn't do anything (and the cursor is in the detailed block), so detailed block continues to be without records.
I don't know how to solve this. Someone can help me, please?. Thanks.
Edited by: user5067020 on 09-abr-2009 16:38It could be that there is something screwy with LV, but given that it uses standard interfaces for comm with the DBMS, I would not expect that. A much more realistic possibility is that the toolkit is mucking things up. (A fairly common occurrence.)
Try bypassing the toolbox -- which you don't really need anyway -- an talk directly to the ActiveX or .net interface.
Also, what DBMS? What drivers are you using?
Mike...
Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion
"... after all, He's not a tame lion..."
Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps -
Blocks based on stored procedure in Forms6
I've successfully based a form on stored procedures. It's a master/detail form, so each block has its own procedure to query.
It works fine until a procedure return no rows in pl/sql table parameter. When this happens, the PLSQL_TABLE.POPULATE_BLOCK built-in, used automatically by forms to populate the block, fails.
How can I deal with queries that returns no rows?
Marco Nicolazzo
NIVA Informatica snc<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by marco.n ():
I've successfully based a form on stored procedures. It's a master/detail form, so each block has its own procedure to query.
It works fine until a procedure return no rows in pl/sql table parameter. When this happens, the PLSQL_TABLE.POPULATE_BLOCK built-in, used automatically by forms to populate the block, fails.
How can I deal with queries that returns no rows?
Marco Nicolazzo
NIVA Informatica snc<HR></BLOCKQUOTE>
I've found a workaround.
I raise an application error in the package on server-side where there's no
data to query with RAISE_APPLICATION_ERROR(-20XXX,'ERROR DESCRIPTION').
Then I use ON-ERROR trigger on the block to ignore the error.
And so it's worked.
Different solutions are welcome!
Marco Nicolazzo
NIVA Informatica snc
null -
Block based on Stored Procedure - Update Changed columns only
If I were to base a block on stored procedures that includes an Update procedure but only update SOME of the updateable columns, what happens?
Does the Form send to server ONLY
1) The rows that were updated
2) The columns that updated
3) All columns in the row being updated regardless of whether they were updated
Is the correct answer 1) + 2) or 1) + 3)
Please help.
ThanksHello,
<p>There is another example here</p>
Francois -
Stored procedure - ref cursor - no rows
Hello,
I am stumped. Hopefully another pair of eyes will see what mine cannot. I am calling a stored procedure that accepts a single output parameter [the proc has been dumbed down to limit variables of my problem] that is a ref cursor. When I make the call I get now data. I have used both adapter and datareaders. If I call the proc from another proc I can loop through the results. I am including the code of my c# function and the stored proc.
The version number of my Oracle.DataAccess.dll is 10.1.0.303.
** Stored Proc ***********************
TYPE refcursor is ref cursor ;
procedure P_CUSTOMER_INFO_GET_SLIM( thecur out refcursor )
is
begin
open thecur for
select *
from customer_info
where rownum < 21;
end P_CUSTOMER_INFO_GET_SLIM;
** C# Func ***************************
private DataSet _FetchCustomerData2(string CustNbr, string ShipToSuffix)
string sc = "PKG_CUSTOMER_CONTACT.P_CUSTOMER_INFO_GET_SLIM";
OracleConnection con = new OracleConnection(_Database.GetConnection().ConnectionString);
OracleCommand cmd = new OracleCommand(sc, con);
OracleDataAdapter da = new OracleDataAdapter(cmd);
DataSet ds = new DataSet();
// must pass strings with data
if (CustNbr.Length==0 || ShipToSuffix.Length==0)
return null;
try
// we are calling a stored proc so set it
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("thecur", OracleDbType.RefCursor, DBNull.Value, ParameterDirection.Output);
da.Fill(ds, "Customer"); // no data ?????????????????
// Close and Dispose OracleConnection object
con.Close();
con.Dispose();
return ds;Hey all,
I ended up declaring a variable in the proc as refcursor and opening it. Then I assigned the out parameter ref cursor to the variable. That took care of it. See below.
Thanks,
Mike
procedure P_CUSTOMER_INFO_GET(
CustomerNumber in varchar2
,ShipToSuffix in varchar2
,thecur out refcursor
is
-- variable declarations
mycur refcursor;
begin
open mycur for
select CORP_CODE
,CUST_NUMBER
,CUST_SHIP_TO_SFFX
,CUST_BILL_TO_SUFF
,CUST_AR_OFF_CODE
,CUST_NAME
,CUST_SHIP_BILL_IND
,CUST_SHIP_VIA_CODE
,CUST_CLASS_CODE
,CUST_TYPE_CODE
,CUST_PRICE_CODE
,DISC_MKUP_CODE
,TRADE_DISC_CODE
,CUST_N_D_ACCT_NO
,CUST_PRY_PRICE_AGR
,CUST_ADDR_1
,CUST_ADDR_2
,CUST_ADDR_3
,CUST_CITY
,CUST_STATE
,CUST_ZIP
,CUST_COUNTRY_CODE
,CUST_FAX_NO
,CUST_FAX_NO_EXP
,CUST_PHONE_NO
,CUST_PHONE_NO_EXP
,CUST_CRDT_LIM_CODE
,CUST_CREDIT_STATUS
,CUST_CRED_CARD_NO
,CUST_CC_EXP_DATE
,CUST_DUNNING_FLAG
,CUST_ID
,CUST_SP_FILE_IND
,CUST_ST_TAX_CODE
,LAST_MAINT_DATE
from customer_info
where CUST_NUMBER = CustomerNumber
and CUST_SHIP_TO_SFFX = ShipToSuffix;
-- send the cursor back
thecur := mycur; -
STORED PROCEDURE/REF CURSOR: How to output entire buffer
I wrote a Stored Procedure wherein I use a Cursor to extract multiple
rows and columns. I then write them into the buffer
(dmbs_output.put_line). But when I try to capture the entire result
into an OUT variable, I only get the last buffered line.
So how do I output the entire buffer- all rows and columns? In other words (maybe), how do I use dbms_output.get_lines() to assign value to an OUT variable?
Alternatively, using REF CURSOR as OUT variable, I added the following to "CREATE OR REPLACE PROCEDURE ... ()":
cursor_out_test OUT cursor_test
But when I tried:
DEFINE CURSOR TYPE cursor_test IS REF CURSOR RETURN table%ROWTYPE;
...or...
DECLARE TYPE cursor_test IS REF CURSOR RETURN table%ROWTYPE;
I still got syntax errors.
In one line, what I am trying to do is break the result array at the database level rather than at the application level.
Cheers, Bill
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/sqloperations.htm#LNPLS00605I did the following:
OPEN CURSOR x
LOOP
FETCH CURSOR x INTO col1, col2
(EXIT WHEN...)
variable_line := col1 || col2
END LOOP
CLOSE CURSOR
But after closing this cursor, variable_line contains only the last buffered line. I want all the looped lines (without using associative arrays, nested tables etc). So I guess I am just looking for some way to append data lines- adding chr(10) doesn't work either.
Cheers, Bill
Maybe you are looking for
-
I just upgraded OSX to Mountain Lion and Pages to 4.2, and because OSX is syncing with my iCloud account, when I go to save a new file in Pages it defaults to try to save to my iCloud account rather than giving me the folder structure on my hard-driv
-
Please help
-
Can't decide Macbook Pro 15 or Retina
Hello! This is my first post here so excuse me if I'm doing anything wrong! I'm going to buy my first Mac but I can't decide if I should buy a Macbook Pro 15 or a Retina. I'm in college and I'm going to use it for FinalCut, Photoshop, Logic Pro and s
-
My blackberry keeps sending and receiving data
and it is draining my battery!!!! My phone is just sitting beside me, not receiving any emails or texts and it isn't loading an internet page, so I don't know what it is doing. My battery is dying before 11:00 AM which shouldn't happen.
-
Invoke Web Service in 9i database using UTL_HTTP
I am trying to explore Oracle's UTL_HTTP package to invoke external web service without having to use java stored procedure. I downloaded a demo scripts from OTN web site (http://www.oracle.com/technology/tech/webservices/htdocs/samples/dbwebservice/