Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old July 6th, 2004, 05:01 AM
hudo hudo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 97 hudo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 23 m 19 sec
Reputation Power: 5
WHEN-MOUSE-DOUBLECLICK with more than 1 result rows

Hello

I've displayed scott.emp on canvas-tab1. By doubleclicking on a row I'd like to have the result (depending on the condition) on canvas-tab2.
Therefore I use the WHEN-MOUSE-DOUBLECLICK Trigger:

-------------------------------------------------------------
DECLARE
the_button_pressed VARCHAR2(1);
my_current_value_emp VARCHAR(10);

cur_blk VARCHAR2(40) := :SYSTEM.CURSOR_BLOCK;
cur_rec NUMBER;
--top_rec NUMBER;
bk_id BLOCK;

BEGIN

bk_id := FIND_BLOCK( cur_blk);
cur_rec := GET_BLOCK_PROPERTY( bk_id ,CURRENT_RECORD);

my_current_value_emp := :EMP.SAL;

the_button_pressed := :SYSTEM.MOUSE_BUTTON_PRESSED;

GO_BLOCK('EMP1');
CLEAR_BLOCK(NO_VALIDATE);

SELECT empno ,ename ,job ,mgr ,sal ,comm ,deptno
INTO :EMP1.EMPNO, :EMP1.ENAME, :EMP1.JOB ,:EMP1.MGR ,:EMP1.SAL,:EMP1.COMM ,:EMP1.DEPTNO
FROM EMP
WHERE sal = TO_NUMBER(my_current_value_emp);


--END IF;
END;
------------------------------------------------------------

If there is just 1 row as result everything is fine, if there are more result-rows ORA-01422 is raised.
Why is there a problem with more then 1 result-row ??
How can I solve this Problem ??

Reply With Quote
  #2  
Old July 6th, 2004, 07:36 AM
shafique shafique is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Canada
Posts: 305 shafique User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 20 sec
Reputation Power: 5
Your query assuming that only one record should be return because of using = operator in WHERE clause, make the following modification in your query then try it.

SELECT empno ,ename ,job ,mgr ,sal ,comm ,deptno
INTO :EMP1.EMPNO, :EMP1.ENAME, :EMP1.JOB ,:EMP1.MGR ,:EMP1.SAL,:EMP1.COMM ,:EMP1.DEPTNO
FROM EMP
WHERE sal IN TO_NUMBER(my_current_value_emp);




Regards,

Reply With Quote
  #3  
Old July 6th, 2004, 07:57 AM
shafique shafique is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Canada
Posts: 305 shafique User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 20 sec
Reputation Power: 5
I assume that your query is right. What is the format of your blocks? Form or tabular. canvas-tab2 must be defined as tabular so it can have place holder to store more than one records.

Reply With Quote
  #4  
Old July 6th, 2004, 07:58 AM
hudo hudo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 97 hudo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 23 m 19 sec
Reputation Power: 5
First it has to be:

WHERE sal IN (TO_NUMBER(my_current_value_emp));

But this does not work. Sorry.

Any other suggestions ?

Reply With Quote
  #5  
Old July 6th, 2004, 08:03 AM
hudo hudo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 97 hudo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 23 m 19 sec
Reputation Power: 5
Someone suggested to change the default-where clause:

DECLARE
the_button_pressed VARCHAR2(1);
my_current_value_dept VARCHAR(2);
my_current_value_emp VARCHAR(10);

cur_blk VARCHAR2(40) := :SYSTEM.CURSOR_BLOCK;
cur_rec NUMBER;
--top_rec NUMBER;
bk_id BLOCK;

L_STR_EMP VARCHAR2(2000) :=' WHERE 1=1';
my_current_value_emp := :EMP.SAL;

the_button_pressed := :SYSTEM.MOUSE_BUTTON_PRESSED;

L_STR_EMP := L_STR_EMP ||' AND SAL >= '||TO_NUMBER(my_current_value_emp);

GO_BLOCK('EMP1');
CLEAR_BLOCK(NO_VALIDATE);
SET_BLOCK_PROPERTY('EMP1', DEFAULT_WHERE, L_STR_EMP);
EXECUTE_QUERY;

END;

This works, but maybe there exists some other solutions ??

Thanks for your attention

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > WHEN-MOUSE-DOUBLECLICK with more than 1 result rows


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

IBM developerWorks




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway