Need skeleton for this

Using Dynamic
Creating a procedure emp_data with three parameters p_colname varchar2, p_value varchar2, p_ref ref_cursor
Based on the value in p_colname and p_value query the emp table and return the result set in a Cursor.
Validate the value of p_colname , it must be a valid column_name in table emp
can u give the skeleton for this ... i am nt getting how to do this for REF Cursor as parameter

need skeleton for thisalmost the whole body ;) :
SQL> create or replace procedure emp_data (p_colname varchar2, p_value varchar2,
p_ref out sys_refcursor)
as
   p_cnt integer := 0;
begin
   select count ( * )
     into p_cnt
     from cols
    where table_name = 'EMP' and column_name = upper (p_colname);
   if p_cnt = 1
   then
      open p_ref for
         'select ' || p_colname || ' from emp where ' || p_colname || ' = :1'
         using p_value;
   else
      raise_application_error (-20003,
      'Column ' || p_colname || ' does not exist');
   end if;
end emp_data;
Procedure created.
SQL> var c refcursor
SQL> exec emp_data('eame', 'SCOTT',:c)
BEGIN emp_data('eame', 'SCOTT',:c); END;
Error at line 27
ORA-20003: Column eame does not exist
ORA-06512: at "MICHAEL.EMP_DATA", line 17
ORA-06512: at line 1
SQL> exec emp_data('ename', 'SCOTT',:c)
PL/SQL procedure successfully completed.
SQL> print
ENAME    
SCOTT    
1 row selected.

Similar Messages

  • Pls i need help for this simple problem. i appreciate if somebody would share thier ideas..

    pls i need help for this simple problem of my palm os zire 72. pls share your ideas with me.... i tried to connect my palm os zire72 in my  desktop computer using my usb cable but i can't see it in my computer.. my palm has no problem and it works well. the only problem is that, my  desktop computer can't find my palm when i tried to connect it using usb cable. is thier any certain driver or installer needed for it so that i can view my files in my palm using the computer. where i can download its driver? is there somebody can help me for this problem? just email me pls at [email protected] i really accept any suggestions for this problem. thanks for your help...

    If you are using Windows Vista go to All Programs/Palm and click on the folder and select Hot Sync Manager and then try to sync with the USB cable. If you are using the Windows XP go to Start/Programs/Palm/Hot Sync Manager and then try to sync. If you don’t have the palm folder at all on your PC you have to install it. Here is the link http://kb.palm.com/wps/portal/kb/common/article/33219_en.html that version 4.2.1 will be working for your device Zire 72.

  • Need Sequence for this logic

    Hi,
    I need sequence for autogenerate of code
    Table 1
    id     code
    We need to autogenerate code for every new entity of id 
    ex:
    id          code
    sbi        sbi001
    hsb        hsb002 
    xyz        xyz003
    And
    ex:
    id          code
    sbi      s001
    hsb     h002
    xyz    x003

    You can use a Sequence and Trigger in combination like this
    create table t
      id   varchar2(10)
    , code varchar2(25)
    create sequence t_seq;
    create or replace trigger t_trig before insert on t for each row
    declare
      l_seq integer;
    begin
      select t_seq.nextval into l_seq from dual;
      :new.code := :new.id || to_char(l_seq, 'fm099');
    end;
    insert into t (id) values ('sbi');
    insert into t (id) values ('hsb');
    insert into t (id) values ('xyz');
    select * from t;

  • Need code for this Small validation on when-validate-item

    Hi All,
    I have a text item(date datatype) in forms 4.5 I need to do a small validation want to write on when-validate-item. When I enter a date in that text item (Ex 10-JUN-2005) it has to check
    1) It Cannot be "blank"
    2) It cannot be "Not older than today"
    can you please put me code for this small validation. I am new to Forms.
    Thanks in Advance,
    Reddy

    I always put code in the when-validate-RECORD trigger to ensure fields are entered, rather than setting the property. That way, the user can enter other fields within the record, and then gets a message that the field is required only when leaving the record.
    ...of course, if the date item is the only field in the block, then the when-validate triggers will not run unless the user at least types a space in the date. In that case, you need to check in the key-commit trigger.

  • Need Ideas for This Puzzle

    The puzzle relates to displaying check boxes (checkbox or multibox).
    What I have are members who belong to professional groups and sub-groups. E.g.,
    Group A with sub-groups A-1, A-2, A-3, A-4.
    Group B with sub-groups B-1, B-2, B-3
    Group C with sub-groups C-1, C-2, C-3, C-4, C-5, C-6
    etc.
    web site users make multiple selections among groups. And all members in those groups will receive an e-mail message.
    I can display a check box for every single "sub-group". And give each "group" a "select all" check box. All I have to take care are the checked "sub-groups".
    The challege comes as the "roles" of the web site users are introduced. According to the role of the web site user, I have to display certain groups (not all the groups) and certain sub-groups (not all sub-groups within a group) to him/her.
    How do I disply groups and their sub-groups under such a condition?

    well, presuming you still need all values..., something along these lines
    <%
    boolean checked = isChecked("a"); // check if the value should be checked by default
    if(showCheckbox(user, "a")) { // check if, for this user, the checkbox should be visible
    %>
    <input type="checkbox" name="a" value="a" <%= checked ?"checked":"" %>>
    <%
    } else { // show disabled checkbox (or leave that out to show nothing...)
    %>
    <input type="checkbox" name="noname" <%= checked ? "checked" : "" %> disabled="diabled" />
    <%
       if(checked) { // don't need hidden value if default is unchecked
    %>
    <input type="hidden" name="a" value="a">
    <%
    %>

  • I need solution for this query

    hi all,
    could anyone please send me solution for this query these are the database tables am having
    TABLE NAME :USERS
    ATTRIBUTES
    UNAME
    PASSWORD
    GROUPNAME
    TABLE NAME:GROUPS
    ATTRIBUTES
    GROUPID
    GROUPNAME
    my requirement is that i need 2 acces the groupname of a particular user and the reamining groups to which i doesn't belong in A SINGLE QUERY
    my result needs to be like this
    Authorised group
    consultant
    UNAuthorised groups
    sales
    vender
    recruiter
    admin
    if any body got the solution please send

    hi All,
    I have 3 tables 1)PREVILEGES (groupname, previleges(values y or n only))
    2)GROUPS (groupid, groupname)
    3) USERS (uname, groupname).
    Here each user belongs to one group, each user hav a default previlege means example if user is consutant then he can access only consultant group. Means default previlege will be used. For default previleges, there is no record in Previleges table.
    The Problem is that, I need to reterive the groupname from users which de doesn't belong as well as his previleges from previleges, If there is no values in previleges in the table it should return n. or value what is therey.
    the different groups are
    SALES,CONSULTANT,VENDER,RECRUTER,ADMIN

  • Need procedure for this logic

    Hi
    I need a procedure 4 this logic,
    Need to get 32+ inputs in procedure of same type varchar2,
    If comp_id !=360
    insert 32 inputs in table column-> value using custom-id
    Note:
    Column : brand-code,value,custom_name using custom_id
    brand-code gets from comp-id from another table
    i/p- from procedure comp_id and 32 inputs
    This 32 inputs should use varray cocept
    end if;
    ex:
    table 1
    brand_code custom-id value editble
    table 2
    custom-id custom-name
    Could you please share ur suggestions

    Create or replace procedure cdm_cl_proc is
    v_sqnum number(3);
    cursor c1 is
    select dcn, pp_code from d_cl_ext;
    Cursor c2 is
    Select t_code, s_date, area_chrg, rc_pct from d_c_p_ext;
    Begin
    for v1 in c1
    Loop
    update d_cl set pp_code = v1.pp_code
    where dcn=v1.dcn;
    select d_sqnum into v_sqnum from d_cl
    where dcn=v1.dcn;
    For v2 in c2
    Loop
    Update d_c_p set area_chrg= v2.area_chrg, rc_pct=v2.rc_pct
    Where t_code= v2.t_code and s_date = v2.s_date
    and d_sqnum = v_sqnum;
    if mod(c2%rowcount,1000)=0 then
    commit;
    end if;
    End loop;
    if mod(c1%rowcount,1000)=0 then
    commit;
    end if;
    End loop;
    Commit;
    End;
    I amable to load the data when dcn is matched but, if the dcn is not matched no data found error is coming. can u suggest error handling for this.

  • Need code for this checkbox trigger...please

    Hi All,
    I have a checkbox in detail block where block is having No. of records displayed is 3(Three) so Checkbox and all other items are displaying thrice. I am inserting the records 1 by 1 using the following code
    Declare
    Begin
         Loop
              First_Record;
              Insert into Veri_Test values(:PNo,:c1);
              Exit When :System.Last_Record='TRUE';
              Next_Record;
         End Loop;
         COMMIT;
    End;
    Its inserting properly. no problem. But what I want is
    when i checked on 1st row of checkbox remaining two(2nd,3rd row) checkboxes should be disabled. If i uncheck 1st row checkbox then
    remaining two should be enabled. As same way
    If i click on 3rd row of checkbox remaining two(1,2) should be disabled. If i uncheck 3rd row checkbox then remaining two(1,2) should be enabled.
    Hope its clear. is it possible ? if yes can anyboxy give the code for this checkbox trigger ?
    Thanks in Advacne
    Devender

    Hello,
    Apply this in a When-Checkbox-Changed trigger:
    Declare
       -- Record being modified --
       LN$CurRec pls_integer := :system.cursor_record ;
       LN$Rec    pls_integer := 1 ;
    Begin
       If :BLOC.CB1 = 'O' Then
          -- Goto first record --
          First_record ;
          Loop
             If LN$Rec <> LN$CurRec Then
                -- record <> current record --
                :BLOC.CB1 := 'N' ;
             End if ; 
             If :system.last_record = 'TRUE' Then
                Exit ;
             End if ;
             -- Goto next record --
             Next_record ;
             LN$Rec := LN$Rec + 1 ;
          End loop ;
          -- Jump to current record --                
          Go_Record( LN$CurRec );
       End if ;
    End ;Francois

  • Need Solution for this Intersting scenario

    Hi All,
        Our Client is having Office in X - country & Y- Country In Y country there is two division. Import Div & Local Divison. Two book of account have to be maintained. for this.
    Good is being purchase from X for - $100 by Y Import Div
    Stock is transfered to Local Div at - $70
    Sold in the marked at - $90 by Local Div.
    After sale Y Import Div Get rebate for sale - $20
    If we consolidate the 2 books of account we get the profit - $10
    This is the scenario how it will be done....
    Please explain in detail.....
    Regards,
    Subha jo

    Hi
    First your Y-Import Division importing the material for $100 and after that is is getting $20 rebate....so the actual cost of the material is $80. Then this $80 material is transfered to Y- Local Division and sold for $ 90
    So finally you are getting $10 as a profit
    Regards
    S.Baskaran

  • I need selution for this massage

    hi apple
    my problem if i go to update my app i see this massage
    (There was an error in the App Store. Please try again later. (13) )
    pleas send to me the selution for this and thanks
    Mthaqafy

    HI EAGLE2009
    MY ID DOSN'T WORK IN ITUNES PLEASE HEPL ME
    EMAIL ID AND PASSOWARD IS CORRECT BUT I HAVE NO CREADIT CARD ?
    ANY SOLATIONS ?

  • Need logic for this output  itab  format

    hi guys
    i need the output itab in following format
    i have data in my present  itab
    itab-f1     itab-f2    itab-f3
    AAA         10    (means null,' ')
    AAA         20            
    BBB         10          
    BBB         20    A1
    BBB         30         
    and i want output in following way output itab
    itab-f1     itab-f2    itab-f3
    AAA     30          
    BBB         60      A1
    can anyone suggest me code for this

    You want the sum of f2 for a group of f1's?
    Is f3 going to be the same for that group?
    Try this
    sum = 0
    sort itab by f1.
    itab2 like itab.
    loop itab.
    sum = itab-f2 + sum.
    f3var = tab-f3.
    at end of f1.
    move itab-f1 to itab2-f1.
    move sum to itab2-f2.
    move f3var to itab2-f3.
    append itab2.
    sum = 0.
    endat.
    endloop.
    Edited by: Ramiro Escamilla on Feb 7, 2008 11:29 PM

  • Need input for this requirement?

    Hi All,
    I got new requirement. In this i need to display one world map on that map i have so show blinking star for the customer countries.
    if the user click on perticular blinking star i need to display some data.
    How to achive this? please help me out.
    Thanks and Regards,
    Phani Kumar.

    Phani,
    You can also use Google Maps API .You can find help in below links:
    http://code.google.com/apis/maps/documentation/reference.html
    http://net.tutsplus.com/javascript-ajax/this-is-how-you-use-the-google-maps-api/
    -Suresh

  • Need code for this program in pl/sql

    Hi,
    was looking for a pl/sql code for the following case
    If there are two employees from the EMP table. i want all the names of the managers common to the two employees....
    to explain in detail : if employee1 and employee2 have the same manager mgr1....mgr1 should be displayed.
    else if employee 1 and employee2 have no immediate manager in common...meaning team leader of employee 1 and employee2 are different but the project managers for both the employee is same..in this case the project manager's name should be displayed......
    else in worst case when there are no managers common between these two employees.........the CEO who is at the highest level is common....then display CEO's name
    it's hierchiacal structure......
    thanks,
    Preethi

    Why PL/SQL? Why not look at if this can be done using SQL firstly? SQL is the preferred language for crunching Oracle data. Not PL/SQL.
    Think data sets.
    One method to do this in SQL would be to build a hierarchical list of managers for each employee. E.g.
    LEVEL MANAGER
    1     Jack
    2     John
    10     Dan the CEOOnce you have such a list for each employee, you can join these two lists on matching names. Then you simply need to find the matching join that has the lowest level.
    I'm sure there are other approaches. But unless you put together some test data, put together some SQLs and play around with this problem, you are not going to learn anything.
    And no, copying and pasting an answer that someone is inevitable to post in response is NOT learning anything new.
    So why not try and solve this problem yourself? Gain some new knowledge. That will only do your career well as your employer is after all expecting you to write the code to solve this problem - and not for members of this forum to supply the code for you.

  • Need help for this Procedure

    A Simple procedure for inserting rows in the table
    This is how the Source Table looks like Table Name:BSNL Contains the following Data. Here the Column MDI is Bold and MAI is regular and PRN# is Bold.
    MDI MAI PNR#
    50001112220 5000111220 25000
    50001112221 5000111221 25001
    50001112222 5000111222 25002
    50001112223 5000111223 25003
    50001112224 5000111224 25004
    50001112225 5000111225 25005
    50001112226 5000111229 25006
    Destination table TVS which contains two columns(MDI and PNR#)
    Here i have to write a procedure which inserts row in the destination table TVS according to the following condition
    1) If mdi=mai then insert only one row in the destination table TVS with mdi and pnr# shown below the column MDI is Bold and PNR# is Regular
    MDI PNR#
    50001112220 25000
    2) If MDI <> MAI then insert values like this
    if MDI=50001112226 and MAI=50001112229 and PNR#=25006 then insert it
    like shown below in the destination Table ie PNR# remains same and only the
    MDI values will be inserted in incremented way the columns MDI is Bold and
    PNR# is Regular.
    MDI PNR#
    50001112226 25006
    50001112227 25006
    50001112228 25006
    50001112229 25006
    so any idea please share it with me
    Thanks in Advance.

    You can check the following script - this will work in 9i --
    satyaki>
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    satyaki>
    satyaki>
    satyaki>create table bsnl
      2    (
      3       MDI     number(15),
      4       MAI     number(15),
      5       PNR     number(5)
      6    );
    Table created.
    satyaki>
    satyaki>
    satyaki>insert into bsnl values(&MDI,&MAI,&PNR);
    Enter value for mdi: 50001112220
    Enter value for mai: 50001112220
    Enter value for pnr: 25000
    old   1: insert into bsnl values(&MDI,&MAI,&PNR)
    new   1: insert into bsnl values(50001112220,50001112220,25000)
    1 row created.
    satyaki>/
    Enter value for mdi: 50001112221
    Enter value for mai: 50001112221
    Enter value for pnr: 25001
    old   1: insert into bsnl values(&MDI,&MAI,&PNR)
    new   1: insert into bsnl values(50001112221,50001112221,25001)
    1 row created.
    satyaki>/
    Enter value for mdi: 50001112222
    Enter value for mai: 50001112222
    Enter value for pnr: 25002
    old   1: insert into bsnl values(&MDI,&MAI,&PNR)
    new   1: insert into bsnl values(50001112222,50001112222,25002)
    1 row created.
    satyaki>/
    Enter value for mdi: 50001112223
    Enter value for mai: 50001112223
    Enter value for pnr: 25003
    old   1: insert into bsnl values(&MDI,&MAI,&PNR)
    new   1: insert into bsnl values(50001112223,50001112223,25003)
    1 row created.
    satyaki>/
    Enter value for mdi: 50001112224
    Enter value for mai: 50001112224
    Enter value for pnr: 25004
    old   1: insert into bsnl values(&MDI,&MAI,&PNR)
    new   1: insert into bsnl values(50001112224,50001112224,25004)
    1 row created.
    satyaki>/
    Enter value for mdi: 50001112225
    Enter value for mai: 50001112225
    Enter value for pnr: 25005
    old   1: insert into bsnl values(&MDI,&MAI,&PNR)
    new   1: insert into bsnl values(50001112225,50001112225,25005)
    1 row created.
    satyaki>/
    Enter value for mdi: 50001112226
    Enter value for mai: 50001112229
    Enter value for pnr: 25006
    old   1: insert into bsnl values(&MDI,&MAI,&PNR)
    new   1: insert into bsnl values(50001112226,50001112229,25006)
    1 row created.
    satyaki>
    satyaki>
    satyaki>commit;
    Commit complete.
    satyaki>
    satyaki>
    satyaki>set lin 10000
    satyaki>
    satyaki>
    satyaki>select * from bsnl;
           MDI        MAI        PNR
    5.0001E+10 5.0001E+10      25000
    5.0001E+10 5.0001E+10      25001
    5.0001E+10 5.0001E+10      25002
    5.0001E+10 5.0001E+10      25003
    5.0001E+10 5.0001E+10      25004
    5.0001E+10 5.0001E+10      25005
    5.0001E+10 5.0001E+10      25006
    7 rows selected.
    satyaki>select to_char(MDI) MDI,
      2            to_char(MAI) MAI,
      3            to_char(PNR)
      4     from bsnl;
    MDI                                      MAI                                      TO_CHAR(PNR)
    50001112220                              50001112220                              25000
    50001112221                              50001112221                              25001
    50001112222                              50001112222                              25002
    50001112223                              50001112223                              25003
    50001112224                              50001112224                              25004
    50001112225                              50001112225                              25005
    50001112226                              50001112229                              25006
    7 rows selected.
    satyaki>
    satyaki>
    satyaki>select * from tvs;
    select * from tvs
    ERROR at line 1:
    ORA-00942: table or view does not exist
    satyaki>create table tvs
      2   (
      3      MDI      number(15),
      4      PNR      number(5)
      5   );
    Table created.
    satyaki>
    satyaki>
    satyaki>select * from tvs;
    no rows selected
    satyaki>
    satyaki>
    satyaki>insert into tvs
      2  select MDI + (level - 1) MDI,PNR
      3  from bsnl
      4  connect by rownum <= decode((MAI - MDI),0,1,(MAI - MDI)+1)
      5  order by MDI;
    10 rows created.
    satyaki>
    satyaki>
    satyaki>select to_char(MDI) MDI,
      2            to_char(PNR) PNR
      3     from tvs;
    MDI                                      PNR
    50001112220                              25000
    50001112221                              25001
    50001112222                              25002
    50001112223                              25003
    50001112224                              25004
    50001112225                              25005
    50001112226                              25006
    50001112227                              25006
    50001112228                              25006
    50001112229                              25006
    10 rows selected.
    satyaki>Regards.
    Satyaki De.
    Oops!
    Needs to modify my script now.

  • Need Sql for this problem

    Hi Gurus
    I have below situtation which need to be sorted out by SQL (10g version)
    Below is the sample data.
    Date     Amt1     Amt2     Amt3     Totl
    201009     10     10     10     30
    201010     20     20     20     90
    201011     30     20     10     150
    Totl is the calculation field and remaining data is available in DB table say tab1. If you see logic of identifying Totl --> addition of Amt1,Amt2,Amt3 with Totl of prev month. For 201010 it is 20+20+20 =60 and this 60 will need to added to 201009 totl 30 and hence final sum is 90.
    Please provide to resolve this.

    You need to do cumulative sum.
    with t
    as
    select 201009 dt, 10 a1, 10 a2, 10 a3 from dual union all
    select 201010, 20, 20, 20 from dual union all
    select 201011, 30, 20, 10 from dual
    select dt, a1, a2, a3, sum(a1+a2+a3) over(order by dt) tot
      from t

Maybe you are looking for

  • AP Payment document update

    Hi Consultants, We have requirement to update AP payments checks voucher field in payment overview screen from Cash Management. we will load the bank back file (which have account number) to CM for reconcilication after this process we need to update

  • Detecting peaks in blood pressure waveform.

    Hello all. I am studying human pulse waveforms and attempting to detect peaks in real time. I have a continuous stream of data coming in a serial port, this is converted from characters into integer values which are then plotted as a moving waveform.

  • Planning Layout for Activity Rate

    Hi My Client is a German Company. Controlling Area currency is EURO, It has operations in India also. For India, required to create BDC for Activity rate planning. 1. Is it necessary to create separate Planning Layout for INR currency?..I did not fin

  • Using useBean for authentication

    Hi, I am creating a login page for personalization, After the login the user can access his/her information, so in my authentication.jsp I am making all the properties available to the user. However I have the properties stored in two different beans

  • Cascade LOV for Multi Row Report

    Hi, Is there a way to support cascaded LOV's in a report, where there are multiple rows? Thanks