Home » Developer & Programmer » Forms » PL/SQL assigning SELECT statement to variable (merged)
PL/SQL assigning SELECT statement to variable (merged) [message #418433] Sat, 15 August 2009 04:38 Go to next message
siddiqui88
Messages: 18
Registered: July 2009
Location: Pakistan
Junior Member
can i do this. but its not work plzz its urgent.


DECLARE
PlateExists VARCHAR2(20);
PlateExists := (SELECT COUNT(*) FROM MyTable WHERE KiteID = 'A1025')
BEGIN
IF PlateExists = 0 THEN
INSERT INTO MyTable values('A1025', '0', 304);
END IF;
--other code here
COMMIT;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
END;


plzz tel me how can i assigning select statement to a variable and how can i use it in the body plzz reply
Re: PL/SQL assigning SELECT statement to variable [message #418436 is a reply to message #418433] Sat, 15 August 2009 04:42 Go to previous messageGo to next message
delna.sexy
Messages: 941
Registered: December 2008
Location: Surat, The Diamond City
Senior Member
Use SELECT INTO statement in BEGIN section.

regards,
Delna
Re: PL/SQL assigning SELECT statement to variable [message #418437 is a reply to message #418433] Sat, 15 August 2009 04:59 Go to previous messageGo to next message
siddiqui88
Messages: 18
Registered: July 2009
Location: Pakistan
Junior Member
how if

declare
v1 varchar2(200);
v1:= select * from emp;
begin
select v1 into :emp.empno, ....
end;

is it ok
or its work
Re: PL/SQL assigning SELECT statement to variable [message #418438 is a reply to message #418433] Sat, 15 August 2009 05:03 Go to previous messageGo to next message
delna.sexy
Messages: 941
Registered: December 2008
Location: Surat, The Diamond City
Senior Member
Are you asking? Or just informing?
And if it works, then fine. No worries.

But, I think, it wont work.

regards,
Delna
Re: PL/SQL assigning SELECT statement to variable [message #418439 is a reply to message #418433] Sat, 15 August 2009 05:06 Go to previous messageGo to next message
siddiqui88
Messages: 18
Registered: July 2009
Location: Pakistan
Junior Member
thanks 4 reply
Re: PL/SQL assigning SELECT statement to variable [message #418440 is a reply to message #418433] Sat, 15 August 2009 05:14 Go to previous messageGo to next message
delna.sexy
Messages: 941
Registered: December 2008
Location: Surat, The Diamond City
Senior Member
While posting your question next time, don't forget to format it properly.

In your current problem, do as follow

DECLARE
   <variable declaration>;
BEGIN
   SELECT <column_name> INTO <variable name> FROM <table_name>;
   ...
END;


regards,
Delna
Re: PL/SQL assigning SELECT statement to variable [message #418441 is a reply to message #418433] Sat, 15 August 2009 05:47 Go to previous messageGo to next message
siddiqui88
Messages: 18
Registered: July 2009
Location: Pakistan
Junior Member
this is the code on when_button_press plzz help me to solve this problem.

declare
v1 varchar2(200):= 'select :main.empno_op from emp';

CURSOR CHK IS
SELECT EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO FROM EMP WHERE 'EMPNO'||v1||':MAIN.EMPNO' OR ':MAIN.EMPNO' IS NULL;

BEGIN

OPEN CHK;
LOOP
FETCH CHK INTO :SEARCH.EMPNO,:SEARCH.ENAME,:SEARCH.JOB, :SEARCH.MGR, :SEARCH.HIREDATE, :SEARCH.SAL, :SEARCH.COMM, :SEARCH.DEPTNO;
EXIT WHEN CHK%NOTFOUND;
NEXT_RECORD;
END LOOP;
CLOSE CHK;

GO_BLOCK('MAIN');
END;

and form is attached plzz view it then u remember what iam going to do.
  • Attachment: aa.JPG
    (Size: 50.18KB, Downloaded 113 times)
Re: PL/SQL assigning SELECT statement to variable [message #418442 is a reply to message #418433] Sat, 15 August 2009 05:48 Go to previous messageGo to next message
siddiqui88
Messages: 18
Registered: July 2009
Location: Pakistan
Junior Member
can i use variable insted of operators. like that

thanks

regard
siddiqui
Re: PL/SQL assigning SELECT statement to variable [message #418443 is a reply to message #418433] Sat, 15 August 2009 06:09 Go to previous message
delna.sexy
Messages: 941
Registered: December 2008
Location: Surat, The Diamond City
Senior Member
If this question is related to Oracle Forms, then you should post it in Forms section of this forum.

regards,
Delna
Previous Topic: Unknown Forms failure in create_obj in CLIENT_OLE2 when communicating with COM
Next Topic: FRM-41211: Integration error
Goto Forum:
  


Current Time: Sat Dec 03 22:13:19 CST 2016

Total time taken to generate the page: 0.19308 seconds