الانتقال إلى المحتوى

كيفية اظهار تفاصيل الموظف بمجرد ادخال Empno في جدولemp


abdullah_hamad

Recommended Posts

لسلام عليكم
حاولت بطرق كثيره لاتوصل للحل ولم اقدر اجيده
وكتبت هذا الكود ولكن ماالخطا فيه

DECLARE
ENO NUMBER(4);
BEGIN
ENO:=&ENO;
SELECT * FROM EMP WHERE ENO=EMPNO;
end;
/


بس ماضبط معي فايش الخطا
السوال
من خلال ال PL/SQL
اريد فقط ادخال رقم الموظف EMPNO للجدول EMP وبمجرد ادخال رقم الموظف فيعطيني كل تفاصيل الموظف اي الصف كامل JOB,SAL,DEPTNO,ENAME,HIREDATE والى اخره

ولكم الجزيل الشكر

تم تعديل بواسطة abdullah_hamad
رابط هذا التعليق
شارك

set serveroutput on
DECLARE
ENO NUMBER(4);
v_ename varchar2(20);
BEGIN
ENO:=&ENO;
SELECT ename into v_ename FROM EMP WHERE ENO=EMPNO;
end;



طبعا يحتاجلك ان تستخدم البكج dbms_output.put_line () لكي تعرض النتائج على sql*plus

رابط هذا التعليق
شارك

alsalam alekom
as i understand quation i think that u shoud use cursor to display all employee detail
u have employee table which contain such as 5 columns so u want to see the 5 columns
name of columns is empno ,ename,sal,job,comm then can see this all columns as below

by using pl sql
ed first.sql



declare


cursor c1 is select *from emp;
er emp%rewtype;
Begin
open c1
loop
fetch c1 into er from emp where empno=en;
exit when c1%notfound;
dbms_output.put_line(er.empno||' '||er.ename ||' ' ||er.sal||' '||and so on)
end loop;
close c1;
end ;
/


go to sql and use
@first.sql



in my dbms i used and so on means remaining of columns [/u]


or u can use another way
declare
cursor c1 is select empno ,ename ,sal,job,comm from emp;
no emp.empno%type;
en emp.ename%type;
es emp.sal%type;
ej emp.job%type;
ec emp.comm%type;

Begin
open c1
loop
fetch c1 into no,en,es,ej,ec from emp where empno=no;
exit when c1%notfound;
dbms_output.put_line(er.empno||' '||er.ename ||' ' ||er.sal||' '||and so on)
end loop;
close c1;
end ;
/

رابط هذا التعليق
شارك

انضم إلى المناقشة

يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.

زائر
أضف رد على هذا الموضوع...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   تمت استعادة المحتوى السابق الخاص بك.   مسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

جاري التحميل
×
×
  • أضف...

برجاء الإنتباه

بإستخدامك للموقع فأنت تتعهد بالموافقة على هذه البنود: سياسة الخصوصية