Home » Developer & Programmer » Forms » URGENT
URGENT [message #146414] Thu, 10 November 2005 04:59 Go to next message
indraneelkumar
Messages: 24
Registered: September 2005
Location: bangalore
Junior Member

Hi

If we want to select a value from a table in PL/SQL we are using the following statement

SELECT SALARY 
  INTO <VARIABLE> FROM EMPLOYEE 
 WHERE EMPNO=123;


Here the table name is decided at design time
If we want to decide the table name at run time we will use

EXECUTE IMMEDIATE 'SELECT SALARY FROM '||<TABLE>||'WHERE EMPNO=123' INTO <VARAIBLE>;


I want similar statement in Forms 6i.

Generally in Forms we use the following block in a trigger to get the value from a table

DECLARE
A NUMBER;
BEGIN
SELECT SAL INTO A FROM EMP;
END;


Here "EMP" is decided at design time.
I want to send the table name at runtime.

Example of my requirement

DECLARE
A NUMBER:=0;
B NUMBER;
BEGIN
FOR I IN 1..9 LOOP
SELECT SAL INTO B FROM EMP||I WHERE <CONDITION>;
A:=A+B;
END LOOP;
END;


Here table names are "EMP1","EMP2",...."EMP9"
I don't want to call back end procedure.
Means i don't want to write back end procedure using EXECUTE IMMEDIATE and call it to front end;
Is it possible only in front end?.
I saw "EXEC SQL" but it is not working.

Thanks in advance.
INDRA.

[mod-edit: applied basic formatting and proper case]

[Updated on: Fri, 11 November 2005 00:43] by Moderator

Report message to a moderator

Re: URGENT [message #146426 is a reply to message #146414] Thu, 10 November 2005 06:28 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
Some remarks:
  1. Modify your topic title to something significant
  2. urgent plz? Who's that? All messages are urgent and treated likewise.
  3. Remove the CAPS LOCK: STOP SHOUTING. Use proper case.
  4. Use code tags where needed.
  5. READ THE STICKY ON TOP OF THE MESSAGE LIST AND FOLLOW THE GUIDELINES (note the stress on this last remark)

First modify your topic, then we'll talk.

One tip: FORMS_DDL

Another tip: poor design, very poor design...

MHE

[edit: you can edit your message, if you don't I will Wink]

[Updated on: Thu, 10 November 2005 06:29]

Report message to a moderator

Re: URGENT [message #146551 is a reply to message #146426] Fri, 11 November 2005 00:48 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
Indra, have you considered using a REF CURSOR yet?

I always tend to do as much as possible on the server side, especially when retrieving/manipulating data is involved. That way, I can keep my Forms as lightweight as possible. EXECUTE IMMEDIATE wouldn't be my option here. I'd use a function returning a REF CURSOR and use that REF CURSOR to retrieve my data. Or, I'd consider a pipelined function returning a table type and use that withing my select. It worked in Reports so it should also work in Forms...

Just my 2 cents.

MHE
Re: URGENT [message #146572 is a reply to message #146551] Fri, 11 November 2005 02:42 Go to previous messageGo to next message
indraneelkumar
Messages: 24
Registered: September 2005
Location: bangalore
Junior Member

thanks for u r valuable suggesion.

because i am new user and english is difficult some what difficult
for me that's why i posted my request like that.

sorry for that one.

once again thanks for u r suggesion.
bye
indra
Re: URGENT [message #146575 is a reply to message #146572] Fri, 11 November 2005 03:00 Go to previous message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
No prob Wink

Let us know whether the REF CURSOR suggestion worked out for you. I'd really put the data retrieval on the DB side.

MHE
Previous Topic: REGARDING FUNCTION KEYS F7 AND F8
Next Topic: Ora Rpts, show text message if no data found
Goto Forum:
  


Current Time: Fri Sep 20 03:31:48 CDT 2024