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;

Similar Messages

  • 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 sql for this logic

    Hi,
    Below is my table with columns like a,b,c
    a      b       c
    1     null   null
    null   2     null
    null  null   3
    I need output like a b c
                              1 2 3

    Hi,
    Here's one way
    SELECT  MIN (a)  AS a
    ,       MIN (b)  AS b
    ,       MIN (c)  AS c
    FROM    my_table;
    I hope this answers your question.
    If not, post  a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
    Point out where the query above is giving the wrong results, and explain, using specific examples, how you get the correct results from the given data in those places.  If you changed the query at all, post your code.Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • Need query for this logic..

    Hi,
    Need a SQL query to achieve this..
    Ex:
    Select object_name from user_objects where object_name in('EMP','DEPT')
    You will get 2 table names.
    DEPT
    EMP
    Now I want to count how many records are there in each table
    Output should be like
    DEPT 4
    EMP 13
    Please let me know how can we write it ?
    Thanks in Advance
    Devender

    You need to create a function to cout rows.
    Here is an example
    CREATE OR REPLACE
    FUNCTION get_rows (
         t_owner IN varchar2 default user,
        t_name IN varchar2
    RETURN  integer
    IS
         outVal integer;
    BEGIN
         select null
         into outVal
         from dba_tables
         where ( owner=t_owner )
              and ( table_name=t_name );
        execute immediate 'select count(*) from '||t_owner||'.'||t_name into outVal;
        RETURN outVal;
    EXCEPTION
         WHEN no_data_found THEN
              return null;
    END;
    /And here is the query.
    Processing ...
    select owner,object_name,get_rows(owner,object_name) n_rows
    from dba_objects
    where object_name in('EMP','DEPT')
    Query finished, retrieving results...
           OWNER                       OBJECT_NAME                                          ROWS                
    SCOTT                    EMP                                                                       14
    SCOTT                    DEPT                                                                       4
    2 row(s) retrieved

  • Require a Message mapping for this Logic.

    Hi Experts,
    I require a Message mapping for this Logic.
    In the Source there are 4 fields and, the Target side, the fields should appear like this.
    Source Structure- File
    Record
    |-> Header
    Order_No
    Date
    |-> Item
    Mat_No
    Quantity
    Target Structure-IDoc
    IDoc
    |-> Header
    |-> Segment
    Delivery_Order_No
    Recv_Date
    |-> Item
    |-> Segment
    Delivery_Order_No
    Material_Num
    Recv_Quantity.
    The Logic is for every Order number an IDOC is generated.And if the Material num matches then the quantity should be added. and important note  is that the material numbers are different for every order number. That means if a material number is 2 in the order number A. Then the material number can never be 2 in any of the order numbers.Here is the following with an example for the above scenario.
    For example:-
    we have
    Source Structure- File
    Order-no Date Mat_No Quantity
    1 01/02/2011 A 10
    1 01/02/2011 B 15
    1 01/02/2011 A 10
    2 01/02/2011 C 10
    2 01/02/2011 C 10
    3 01/02/2011 D 20
    3 01/02/2011 D 10
    3 01/02/2011 E 25
    Target Structure-IDoc
    Delivery_Order_No Recv_Date Material_Num Recv_Quantity
    1 01/02/2011 A 20
    1 01/02/2011 B 15
    2 01/02/2011 C 20
    3 01/02/2011 D 30
    3 01/02/2011 E 25
               So for this example total of 5-Idocs created. That means for this example if Order_No is 1 When the Mat_No is A the quantity gets added. For this Scenario 1 IDoc with four Fields 2 in Header(Delivery_Order_No, Recv_Date) and 2 in Item(Material_Num, Recv_Quantity) is generated by adding the quantity field in the Target Side. Similarly if Order_No is 1 when the Mat_No is B  then separate IDoc is generated with four Fields 2 in Header(Delivery_Order_No, Recv_Date) and 2 in Item(Material_Num, Recv_Quantity) in the Target Side. Similarly, if Order_No is 2 when the Mat_No is C, an IDoc is generated with four Fields 2 in Header(Delivery_Order_No, Recv_Date) and 2 in Item(Material_Num, Recv_Quantity) by adding the quantity field  in the Target Side.  ike wise the process goes on upto 3.Kindly do the needy..
    Thanq very much in advance..
    Edited by: Prashanth Bharadwaj on Oct 17, 2011 1:29 PM

    Hi Prashanth,
    Concatinate the two fields OrderNo and MaterialNo and follow the below logic which will resolve your problem.
    concatinationOfOrderNo&MaterialNo>removecontext>sort>splitByValueChange>collapseContext-->IDOC
    concatinationOfOrderNo&MaterialNo>removecontext>sort>splitByValueChange>collapseContext>splitByEachValue>subString(0,1)-->Delivery_Order_No
    formatByExample>collapseContext>SplitByEachValue-->Recv_Date
    FormatByExample:
    input1:resulrOfSortByKey
    input2:concatination>removecontext>sort-->SplitByValuChange
    sortByKey:
    input1:concatination-->removecontext
    input2:date-->removecontext
    concatinationOfOrderNo&MaterialNo>removecontext>sort>splitByValueChange>collapseContext>splitByEachValue>subString(1,1)-->Material_Num
    formatByExample>sum>Recv_Quantity
    FormatByExample:
    input1:sortByKey
    input2:concatination>removecontext>sort-->SplitByValueChange
    SortByKey:
    input1:concatination-->removecontext
    input2:Quantity-->removeContext
    Regards,
    Priyanka.

  • 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.

  • Please provide code for this logic

    Hi,
    table
    id                    code
    145623          xyz001
    178956          sbh002
    165895          sbi003
    As per this logic,for  every new entity of id a new autogenerated code will be  generated.
    This (xyz or sbh or sbi) code should be fetched using select query (select b_code into table.code from cmp where c_id =145623)
    using id(145623). And 001,002 is autogenerated code and should be concentrated with xyz ex: xyz001
    Here we can use trigger with sequence
    Could you please help me..

    How many times you will ask same question???
    You need to use pl/sql block for your requirement   some thing like this:
    create sequence and add into pl/sql block like:
    >>Select max(count) into temp_var where id=’sbi’
    >>New_code:=’sbi’+temp_var;
    Now you need to optimize it...
    Thanks...

  • How to write code for this logic, plz help me very urgent

    Hi All,
    i am new to sap-abap, i got this work and i m working on this can any body help me in writing code, plz help me, this is very very urgent.
    here  i m giving my logic, can anybody send me the code related to this logic.
    this is very urgent .
    this program o/p should be in ALV format and need to create one commond 'SAVE" on this o/t list  if  user clicks save processedon and processedby fields in ZFIBUE should be updated automatically.
    i am creating one custom table zfibue having fields: (serialno, bukrs, matnr,prdha,hkont,gsber,wrbtr,budat, credate, cretime,processed, processedon, processedby,mapped)
    fields of zfibue:
    serailno = numc
    bukrs = char
    matnr = char
    prdha = char
    hkont = char
    gsber = char
    wrbtr = char
    budat = date
    credate = date
    cretime = time
    processed= char
    processedon = date
    processedby = char
    mapped = char      are   belongs to above type data types
    and seelct-optionfields:  s_bukrs for bseg-bukrs
                                        s_hkont for bseg-hkont,
                                         s_budat for bkpf-budat,
                                         s_processed for zfibue-processed,
                                          s_processedon for zfibue-processedon,
                                          s_mapped. for zfibue-mapped
    parameters: p_chk1 as checkbox,
                      p_chk2 as checkbox.
                      p_filepath type rlgrap-filename.
    1.1 Validate the user inputs (S_BUKRS and S_HKONT) against respective check tables (T001 and SKB1). If the validation fails, provide respective error message. Eg: “Invalid input for Company Code”.
    1.2 Fetch SERIALNO, BUKRS, MATNR, PRDHA, HKONT, GSBER, WRBTR, BUDAT, CREDATE, CRETIME, PROCESSED, PROCESSEDON, PROCESSEDBY, MAPPED from table ZFIBUE into internal table GT_ZFIBUE where BUKRS IN S_BUKRS, HKONT IN S_HKONT, BUDAT IN S_BUDAT, PROCESSED IN S_PROCESSED, PROCESSEDON IN S_PROCESSEDON, and MAPPED IN S_MAPPED.
    1.3 If P_CHK2 = ‘X’, go to step 1.11. Else continue.
    1.4 If P_CHK1 = ‘X’, continue. Else go to step 1.9
    1.5 Fetch MATNR, PRDHA from MARA into GT_MARA for all entries in GT_ZFIBUE where MATNR = GT_ZFIBUE-MATNR.
    1.6 Sort and delete adjacent duplicates from GT_MARA based on MATNR.
    1.7 Loop through GT_ZFIBUE where PRDHA = blank.
              Read Table GT_MARA based on MATNR = GT_ZFIBUE-MATNR.
              IF sy-subrc = 0.
                     Move GT_MARA-PRDHA to GT_ZFIBUE-PRDHA.
                  Modify Table GT_ZFIBUE. “Update Product Hierarchy
                 Endif.
        Fetch PRDHA, GSBER from ZFIBU into GT_ZFIBU for all entries in GT_ZFIBUE where PRDHA = GT_ZFIBUE-PRDHA.
        Read Table GT_ZFIBU based on PRDHA = GT_ZFIBUE-PRDHA.
              IF sy-subrc = 0.
                     Move GT_ZFIBU-GSBER to GT_ZFIBUE-GSBER.
                  Move “X” to GT_ZFIBUE-MAPPED.      
                  Modify Table GT_ZFIBUE.
                 Endif.   
    Endloop.
    1.8 Modify database table ZFIBUE from GT_ZFIBUE.
    1.9 Fill the field catalog table GT_FIELDCAT using the details of output fields listed in section “Inputs/Outputs” (above).
       Eg:                 LWA_ FIELDCAT -SELTEXT_L = 'Serial Number’.
                              LWA_ FIELDCAT -DATATYPE = ‘NUMC’.
                              LWA_ FIELDCAT -OUTPUTLEN = 9.
                              LWA_ FIELDCAT -TABNAME = 'GT_ZFIBUE'.
                              LWA_ FIELDCAT-FIELDNAME = 'SERIALNO'.
              Append LWA_FIELDCAT to GT_FIELDCAT
    Note: a) The output field GT_ZFIBUE-PROCESSED will be editable marking INPUT = “X” in field catalog (GT_FIELDCAT).
             b) The standard ALV functionality will be used to give the user option for selecting all or blocks of entries at a time.
             c) The PF-STATUS STANDARD_FULLSCREEN from function group SLVC_FULLSCREEN will be copied to the program and modified to include a “SAVE” button.
    1.10 Call the function module REUSE_ALV_GRID_DISPLAY passing output table GT_ZFIBUE and field catalog GT_FIELDCAT. Additional parameters like I_CALLBACK_PF_STATUS_SET (= ‘ZFIBUESTAT’) and I_CALLBACK_USER_COMMAND (=’HANDLE_USER_ACTION’) will also be passed to handle user events. Go to 2.14.
    1.11 Download the file to P_FILEPATH using function module GUI_DOWNLOAD passing GT_ZFIBUE.
    1.12 Exit Program.
    Logic to be implemented in  routine “Handle_User_Action”
    This routine will have the following interface:
    FORM Handle_User_Action  USING r_ucomm LIKE sy-ucomm
                                                               rs_selfield TYPE slis_selfield.
    ENDFORM.
    Following logic will be implemented in this routine:
    1.     If r_ucomm = ‘SAVE’, continue. Else exit.
    2.     Loop through GT_ZFIBUE where SEL_ROW = ‘X’. “Row is selected
    a.     IF GT_ZFIBUE-PROCESSED = ‘X’.
    i.     GT_ZFIBUE-PROCESSEDON = SY-DATUM.
    ii.     GT_ZFIBUE-PROCESSEDBY = SY-UNAME.
    iii.     MODIFY ZFIBUE FROM work area GT_ZFIBUE.
    Endif.
    Endloop.

    Hi Swathi,
    If it's very very urgent then you better get on with it, don't waste time on the web. Chop chop.

  • How to write code for this logic in a routine, very urgent --help me

    hi all,
    i want to apply this logic into one subroutin ZABC.
    here i m giving my logic ,can any body help me in coding for this, this is very urgent, i hv to submit on wednesday.
    4.1 Read the company code number BSEG-BUKRS from document line item.
    4.2 Fetch PRDHA from MARA into GV_PRDHA where MATNR = BSEG-MATNR.
    4.3 Fetch Business area (GSBER) from ZFIBU into GV_GSBER where (PRDHA = GV_PRDHA and BUKRS = BSEG-BUKRS) OR (PRDHA = GV_PRDHA and BUKRS = SPACE).
    4.4 If business area match is found, go to step 3.9. Else continue.
    4.5 If BKPF-BLART IN set “ZVS_POSDT” OR BKPF-XBLNR starts with “I0*”, execute steps below. Else, go to Step 3.6.
    i. MOVE: BSEG-BKURS TO work area field WA_ZFIBUE-BUKRS,
    BSEG-MATNR TO work area field WA_ZFIBUE-MATNR,
    GV_PRDHA TO work area field WA_ZFIBUE-PRDHA,
    BSEG-HKONT TO work area field WA_ZFIBUE-HKONT,
    BSEG-GSBER TO work area field WA_ZFIBUE-GSBER,
    BSEG-PSWBT TO work area field WA_ZFIBUE-PSWBT,
    BKPF-BUDAT TO work area field WA_ZFIBUE-BUDAT,
    SY-DATUM TO work area field WA_ZFIBUE-CREDATE,
    SY-UZEIT TO work area field WA_ZFIBUE-CRETIME,
    Fetch running serial number (WA_ZFIBUE-SERIALNO) from ZFICO. This number will be stored in ZFICO with PARAMTYPE = "BPM030307", SUBTYPE = "ZFIBUE" and KEY1 = "SERIALNO". The actual serial number will be stored in the field VALUE1.
    i. Insert WA_ZFIBUE INTO ZFIBUE.
    ii. Send email notification to the user (if it is not already sent to user on the same posting date).
    Use function module ‘SO_NEW_DOCUMENT_ATT_SEND_API1’ to send mail.
    Fetch email address and date of last email from ZFICO. These values will be stored in ZFICO with PARAMTYPE = "BPM030307", SUBTYPE = "EMAIL" and KEY1 = "<USERNAME>". The email address will be stored in the field VALUE1 and posting date in VALUE2. Once mail is sent, VALUE2 is updated with latest posting date (BKPF-BUDAT).
    iii. Increment the running serial number and update ZFICO with new serial number.
    a. GV_ SERIALNO = WA_ZFIBUE-SERIALNO + 1
    b. Update ZFICO Set value1 = GV_SERIALNO
    Where PARAMTYPE = "BPM030307" AND
    SUBTYPE = "ZFIBUE" AND
    KEY1 = "SERIALNO".
    iv Move “VDFT” to BSEG-GSBER.
    v. Exit routine.
    4.6 Fetch MTART into GV_MTART from MARA where MATNR = BSEG-MATNR.
    4.7 If SY-BATCH = INITIAL AND GV_MTART <> ‘ROH’, issue the error message - “Maintain the mapping of product hierarchy <PRDHA> from article <MATNR> for <BUKRS>”. Else, go to step 3.8.
    4.8 If SY-BATCH <> INITIAL AND GV_MTART <> ‘ROH’, issue the error message - “Maintain product hierarchy on article master”. Go to step 3.10.
    4.9 Move GV_GSBER TO BSEG-GSBER.
    4.10 Exit Routine
    plz give me reply asap --this is very urgent
    thanks in advance
    swathi

    Hi Swathi,
    If it's very very urgent then you better get on with it, don't waste time on the web. Chop chop.

  • 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 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

  • 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.

Maybe you are looking for