Pls help me for following query

THIS IS SAMPLE DATA:
This is my pkg i created one rectype,associative array of rec type;
create or replace package pkg
is
type rec is record(eno number,ename varchar2(10));
type a_array is table of rec index by pls_integer;
end pkg;
The following procedure that contains a in parameter of pkg.associativearray type.
create or replace procedure p(p_in pkg.a_array)
is
begin
dbms_output.put_line('hai');
end p;
I am trying to execute the procedure through the following block;
declare
type aarray is table of pkg.rec index by pls_integer;
lv aarray;
BEGIN
lv(1).eno:=123;
lv(1).ename:='VARMA';
P(lv);
END;
while i am executing i am getting the following error;
Error at line 1
ORA-06550: line 7, column 1:
PLS-00306: wrong number or types of arguments in call to 'P'
ORA-06550: line 7, column 1:
PL/SQL: Statement ignored
pls need a hielp....
Thanks sunitha.

You're getting error because a_array and aarray are different types, despite they are defined the same way.
Try using the table type defined in the package:
SQL> set serverout on
SQL> declare
  2  lv pkg.a_array;
  3  BEGIN
  4  lv(1).eno:=123;
  5  lv(1).ename:='VARMA';
  6  P(lv);
  7  END;
  8  /
hai
Procedura PL/SQL completata correttamente.Max

Similar Messages

  • Help needed for writing query

    help needed for writing query
    i have the following tables(with data) as mentioned below
    FK*-foregin key (SUBJECTS)
    FK**-foregin key (COMBINATION)
    1)SUBJECTS(table name)     
    SUB_ID(NUMBER) SUB_CODE(VARCHAR2) SUB_NAME (VARCHAR2)
    2           02           Computer Science
    3           03           Physics
    4           04           Chemistry
    5           05           Mathematics
    7           07           Commerce
    8           08           Computer Applications
    9           09           Biology
    2)COMBINATION
    COMB_ID(NUMBER) COMB_NAME(VARCHAR2) SUB_ID1(NUMBER(FK*)) SUB_ID2(NUMBER(FK*)) SUB_ID3(NUMBER(FK*)) SUBJ_ID4(NUMBER(FK*))
    383           S1      9           4           2           3
    384           S2      4           2           5           3
    ---------I actually designed the ABOVE table also like this
    3) a)COMBINATION
    COMB_ID(NUMBER) COMB_NAME(VARCHAR2)
    383           S1
    384           S2
    b)COMBINATION_DET
    COMBDET_ID(NUMBER) COMB_ID(FK**) SUB_ID(FK*)
    1               383          9
    2               383          4
    3               383          2
    4               383          3
    5               384          4
    6               384          2          
    7               384          5
    8               384          3
    Business rule: a combination consists of a maximum of 4 subjects (must contain)
    and the user is less relevant to a COMB_NAME(name of combinations) but user need
    the subjects contained in combinations
    i need the following output
    COMB_ID COMB_NAME SUBJECT1 SUBJECT2      SUBJECT3      SUBJECT4
    383     S1     Biology Chemistry      Computer Science Physics
    384     S2     Chemistry Computer Science Mathematics Physics
    or even this is enough(what i actually needed)
    COMB_ID     subjects
    383           Biology,Chemistry,Computer Science,Physics
    384           Chemistry,Computer Science,Mathematics,Physics
    you can use any of the COMBINATION table(either (2) or (3))
    and i want to know
    1)which design is good in this case
    (i think SUB_ID1,SUB_ID2,SUB_ID3,SUB_ID4 is not a
    good method to link with same table but if 4 subjects only(and must) comes
    detail table is not neccessary )
    now i am achieving the result by program-coding in C# after getting the rows from oracle
    i am using oracle 9i (also ODP.NET)
    i want to know how can i get the result in the stored procedure itsef.
    2)how it could be designed in any other way.
    any help/suggestion is welcome
    thanks for your time --Pradeesh

    Well I forgot the table-alias, here now with:
    SELECT C.COMB_ID
    , C.COMB_NAME
    , (SELECT SUB_NAME
    FROM SUBJECTS
    WHERE SUB_ID = C.SUB_ID1) AS SUBJECT_NAME1
    , (SELECT SUB_NAME
    FROM SUBJECTS
    WHERE SUB_ID = C.SUB_ID2) AS SUBJECT_NAME2
    , (SELECT SUB_NAME
    FROM SUBJECTS
    WHERE SUB_ID = C.SUB_ID3) AS SUBJECT_NAME3
    , (SELECT SUB_NAME
    FROM SUBJECTS
    WHERE SUB_ID = C.SUB_ID4) AS SUBJECT_NAME4
    FROM COMBINATION C;
    As you need exactly 4 subjects, the columns-solution is just fine I would say.

  • When i got my new iphone 4, its in recovery mode. while restroing with itunes, im getting error at restoring firmware stage? what could be the reason? pls help me for solution.

    when i got my new iphone 4, its in recovery mode. while restroing with itunes, im getting error at restoring firmware stage? what could be the reason? pls help me for solution.

    You got a new iPhone 4, and out of the box the phone is in recovery mode? If that's the case, return it.
    If you don't want to do that. what error code are you getting?

  • Hi ...Some days ago i bought a used iphone 4s....but i can't activate the phone...when i connect it to itunes it shown that activate the phone but the person was not give me the ID & password....pls help me for this issue....Iphone is my favourite ph

    Hi ...Some days ago i bought a used iphone 4s....but i can't activate the phone...when i connect it to itunes it shown that activate the phone but the person was not give me the ID & password....pls help me for this issue....Iphone is my favourite phone...in my child hood i love Apple products & till now......I can't activate it & for this reason i can't find the carrier network & can't make any call....pls help me...thanks for always support..My device ios is 7.1.2
    & IMEI is : *****
    Br-----------------------
    Fazlur
    <Personal Information Edited By Host>

    It's a security risk to post your IMEI number and I've asked the Hosts to remove it.
    If a second-hand iOS device has been 'Activation locked' then only the previous owner can unlock it, either by providing you with the account ID and password, or by removing it from his list of devices (as he should have done before selling it) - please see http://support.apple.com/kb/ts4515
    If you are unable to contact him to do this then I'm afraid you will not be able to use the device - there is no other way of unlocking it at all. Apple cannot unlock it for you.
    You should if possible return it to wherever you bought it and ask for a refund as in this event the device is completely useless.

  • Help needed for SQL query

    hello ,
    I am a beginner in terms of writing sql queries. I hope some body can help me out.
    I have two tables
    mysql> desc user_group_t;
    ---------------------------------------------------+
    | Field | Type | Null | Key | Default | Extra |
    ---------------------------------------------------+
    | userAccountId | char(8) | | PRI | | |
    | groupId | char(8) | | PRI | | |
    ---------------------------------------------------+
    2 rows in set (0.00 sec)
    mysql> desc group_t;
    ---------------------------------------------------+
    | Field | Type | Null | Key | Default | Extra |
    ---------------------------------------------------+
    | id | char(8) | | PRI | | |
    | name | char(50) | YES | | NULL | |
    | email | char(100) | YES | | NULL | |
    | description | char(254) | YES | | NULL | |
    | parentId | char(8) | YES | | NULL | |
    | creatorId | char(8) | YES | | NULL | |
    | createDate | char(20) | YES | | NULL | |
    | updateDate | char(20) | YES | | NULL | |
    | updatorId | char(8) | YES | | NULL | |
    ---------------------------------------------------+
    9 rows in set (0.00 sec)
    what I want is list of all groups with id,name and #of members(which is the # of rows in the user_group_t for any given id). Importantly I need the groups with 0 members also to be listed. In short my output should contain exactly the same number of rows as in group_t table with an additional column indicating # of members for that group.
    Any help would be greatly appreciated.
    Thanks in Advance.
    -Vasanth

    Thanks Donald,
    Actually I figured it out, with the following query:
    select id,name,sum(if(groupid is not null,1,0)) as members from group_t left join user_group_t on id=groupid group by id;
    I tried your solution, but mysql says there is an error at '+' . Anyway I modified your solution to the one below and it worked.
    select a.id, a.name, count(b.groupid) from group_t a left join user_group_t b on a.id=b.groupid group by a.id, a.name;
    I tried that before but then I used Count(*) instead of count on groupid. Your solution is elagant and I will go with yours.
    Thanks again.
    Vasanth

  • Need help in the following query

    Hi ,
    I have the following query to pull out data for a particular timeperiod( campaign)
    select
    da.acct_nr,smas.mrkt_id,smas.fld_sls_cmpgn_perd_id,smas.acct_key,smas.upln_acct_key,smas.awrd_sls_amt,smas.fld_net_sls_amt
    ,smas.stf_ind,da1.acct_nr,
    smas.fld_sls_cmpgn_perd_id,smas.acct_key,smas.upln_acct_key,smas.awrd_sls_amt,smas.fld_net_sls_amt
    ,smas.stf_ind,da1.acct_nr,prev.*
    From cdw.sum_mrkt_acct_sls smas
    join codi.dim_acct da
    on (smas.mrkt_id = da.mrkt_id and smas.acct_key = da.acct_key)
    join codi.dim_acct da1
    on (smas.mrkt_id = da1.mrkt_id and smas.UPLN_acct_key = da1.ACCT_KEY)
    where smas.acct_key in
    select dwnln_acct_key from codi.dim_ldrshp_genlgy
    where mrkt_id = 66 and fld_sls_cmpgn_perd_id = 20100304
    and root_upln_acct_key = (select acct_key from codi.dim_acct where acct_nr = '0032622' and mrkt_id = 66)
    and
    smas.mrkt_id = 66
    and smas.fld_sls_cmpgn_perd_id = 20100304
    and smas.sls_org_key <> -100
    order by 1
    So this query will pull out data for campaign 20100304
    No i want to modify the query to pull out data for 3 such campaigns.
    for a smas.acct_key
    so data will
    smas.acct_key all the data for 1st campaign , all the data for 2nd campaign. all the data for 3rd campaign
    Could you please help in modifying this query.
    Thanks

    How about this ??
    select da.acct_nr,
           smas.mrkt_id,
           smas.fld_sls_cmpgn_perd_id,
           smas.acct_key,
           smas.upln_acct_key,
           smas.awrd_sls_amt,
           smas.fld_net_sls_amt,
           smas.stf_ind,
           da1.acct_nr,
           smas.fld_sls_cmpgn_perd_id,
           smas.acct_key,
           smas.upln_acct_key,
           smas.awrd_sls_amt,
           smas.fld_net_sls_amt,
           smas.stf_ind,
           da1.acct_nr,
           prev.*
      From cdw.sum_mrkt_acct_sls smas
      join codi.dim_acct da on (smas.mrkt_id = da.mrkt_id and
                               smas.acct_key = da.acct_key)
      join codi.dim_acct da1 on (smas.mrkt_id = da1.mrkt_id and
                                smas.UPLN_acct_key = da1.ACCT_KEY)
    where smas.acct_key in (select dwnln_acct_key
                               from codi.dim_ldrshp_genlgy
                              where mrkt_id = 66
                                and fld_sls_cmpgn_perd_id in( 20100304,20100305,20100306)
                                and root_upln_acct_key =
                                    (select acct_key
                                       from codi.dim_acct
                                      where acct_nr = '0032622'
                                        and mrkt_id = 66))
       and smas.mrkt_id = 66
       and smas.fld_sls_cmpgn_perd_id in( 20100304,20100305,20100306)
       and smas.sls_org_key - 100
    order by 1

  • Need help with the following query

    I have the following data
    INVOICE_ID PAID_AMT PYMNT_GROSS_AMT DISCOUNT
    10151 1375 1375 55
    10151DC -44.81 -44.81 0
    20017 25 25 7
    Ok the data I want to grab the discount field is paid_amt = pymnt_gross_amt and discount <> 0. If however there is another invoice_id out there (same invoice ID except with a DC appended to it like 10151DC) then you want to select the differece between the discount field without the DC and the Invoice ID with the DC the paid_amt field.
    So the results would be.
    Invoice_ID Discount
    10151 10.19
    20017 7
    Thanks for all your help!

    Why scan same table twice when it can be achived using single scan :
    Hope this helps :
    with inv_data as
    (select '10151' invoice_id,
    1375 paid_amt,
              1375 pymnt_gross_amt,
              55 discount from dual
    union all
    select '10151DC' invoice_id,
    -44.81 paid_amt,
              -44.81 pymnt_gross_amt,
              0 discount from dual
    union all
    select '20017' invoice_id,
    25 paid_amt,
              25 pymnt_gross_amt,
              7 discount from dual)
    select replace(invoice_id,'DC') invoice_id,
    sum(case when invoice_id like '%DC' then pymnt_gross_amt
         else discount end) discount
    from inv_data
    group by replace(invoice_id,'DC')
    INVOICE DISCOUNT
    10151 10.19
    20017 7
    2 rows selected.

  • Pls help me for tuning the querry

    Hi Team,
    Can any one help me to tune the query below.
    The table STG_INT_CASHFLOWS has 20 lahks record with index created for PAYMENTDATE,DEALNUMBER,PAYRECEIVEIND.
    Is there any other way like collecting into array and finding the values etc..
    SELECT '1'
    FROM STG_INT_CASHFLOWS
    WHERE PAYMENTDATE < :B4
    AND PAYMENTDATE > TO_CHAR (:B3, 'YYYYMMDD')
    AND DEALNUMBER = :B2
    AND PAYRECEIVEIND = :B1
    AND ROWNUM = 1
    Thanks.

    Logic of my code below.
    For test in(
    select * from STG_INT_CASHFLOWS ORDER BY dealnumber, payreceiveind, TO_DATE (TRIM (paymentdate), 'yyyymmdd')) Loop
    SELECT 0 into Varibale
    FROM STG_INT_CASHFLOWS
    WHERE PAYMENTDATE < test.PAYMENTDATE
    AND PAYMENTDATE > TO_CHAR (sysdate, 'YYYYMMDD')
    AND DEALNUMBER = test.dealnumber
    AND PAYRECEIVEIND = test.PAYRECEIVEIND
    AND ROWNUM = 1
    We have some other logice below and select statement used using the cursor values.
    End loop;
    But we face only performace issue with the main cursor with order by clause. But as per logic order by clause cannot be removed. we will use th select staement mentioned.

  • Hi frnds this is the code for dynamic creation of users in plsql but these statements r not executing so pls help me for this error

    DECLARE
    n NUMBER;
    BEGIN
    n:=1;
    WHILE(n<=10)
    LOOP
    CREATE user EM||n IDENTIFIED BY KLU;
    GRANT CREATE SESSION,GRANT ANY PRIVILEGE TO EM||n;
    COMMIT;
    n:=n+1;
    END LOOP;
    END;

    Hi,
         Here is the dynamic query for creating user and to give grants to user,
    DECLARE
       n         NUMBER;
       cr_user   VARCHAR2 (300);
       gr_user   VARCHAR2 (300);
    BEGIN
       n := 1;
       WHILE (n <= 10)
       LOOP
          cr_user := 'CREATE user EM' || n || ' IDENTIFIED BY KLU';
          gr_user := 'GRANT CREATE SESSION,GRANT ANY PRIVILEGE TO EM' || n || '';
          EXECUTE IMMEDIATE cr_user;
          EXECUTE IMMEDIATE gr_user;
          n := n + 1;
       END LOOP;
    END;
    Edited: Removed When OTHERS Exception Handling from Code.
    Cheers!

  • Help document for Abap Query

    I want to attach application help documentation to an SQ01 query that I have created.
    I should be able to view the application help (In the menu <i><b>Help->Application help</b></i>) when I run this query.
    Can I know the method ?

    Well I forgot the table-alias, here now with:
    SELECT C.COMB_ID
    , C.COMB_NAME
    , (SELECT SUB_NAME
    FROM SUBJECTS
    WHERE SUB_ID = C.SUB_ID1) AS SUBJECT_NAME1
    , (SELECT SUB_NAME
    FROM SUBJECTS
    WHERE SUB_ID = C.SUB_ID2) AS SUBJECT_NAME2
    , (SELECT SUB_NAME
    FROM SUBJECTS
    WHERE SUB_ID = C.SUB_ID3) AS SUBJECT_NAME3
    , (SELECT SUB_NAME
    FROM SUBJECTS
    WHERE SUB_ID = C.SUB_ID4) AS SUBJECT_NAME4
    FROM COMBINATION C;
    As you need exactly 4 subjects, the columns-solution is just fine I would say.

  • Help required for the query

    sir
    below query runs fine
    but the probblem is...i am not able to display the figures in the format '999999.99'
    Also please guide me as to make the query short... can i use cursors here?
    i am using 10g
    select
    LBRCODE branch,
    trim(substr(PRDACCTID,1,8)) product,
    sum(case when totsanclimit between 0 and 200000  then
         (Case when  hrk in (13,14) THEN 
              (CASE WHEN bal4 !=0 THEN  1 else 0 END )
              ELSE
              (CASE WHEN BAL1-(BAL4-BAL5)!=0 THEN 1 ELSE 0 END)
                   END )
    else 0 end )as "bktCount-1",
    SUM( CASE WHEN TOTSANCLIMIT between 0 and 200000 then
         (Case when  hrk in (13,14) THEN 
              to_number(to_char(bal4,'99999999999.99'))
         else
              to_char(BAL1,'99999999999.99')-(to_char(BAL4,'99999999999.99')-to_char(BAL5,'99999999999.99'))
         END )
    ELSE
    0 end) AS"Bkt_1",
    sum(case when totsanclimit between 200001 and 1000000 then
    (Case when  hrk in (13,14) THEN 
              (CASE WHEN bal4 !=0 THEN  1 else 0 END )
              ELSE
              (CASE WHEN BAL1-(BAL4-BAL5)!=0 THEN 1 ELSE 0 END)
                   END )
    else 0 end )as "bktCount-2",
    SUM(
    CASE WHEN TOTSANCLIMIT between 200001 and 1000000
    then
         (Case when  hrk in (13,14) THEN 
              to_number(to_char(bal4,'99999999999.99'))
         else
              to_char(BAL1,'99999999999.99')-(to_char(BAL4,'99999999999.99')-to_char(BAL5,'99999999999.99'))
         END )
    ELSE 0 end) AS"Bkt_2",
    sum(case when totsanclimit between 1000001 and 5000000 then
    (Case when  hrk in (13,14) THEN 
              (CASE WHEN bal4 !=0 THEN  1 else 0 END )
              ELSE
              (CASE WHEN BAL1-(BAL4-BAL5)!=0 THEN 1 ELSE 0 END)
                   END )
    else 0 end )as "bktCount-3",
    SUM(
    CASE WHEN TOTSANCLIMIT between 1000001 and 5000000
    then
         (Case when  hrk in (13,14) THEN 
              to_number(to_char(bal4,'99999999999.99'))
         else
              to_char(BAL1,'99999999999.99')-(to_char(BAL4,'99999999999.99')-to_char(BAL5,'99999999999.99'))
         END )
    ELSE 0 end) AS"Bkt_3",
    sum(case when totsanclimit between 5000001 and 10000000  then
    (Case when  hrk in (13,14) THEN 
              (CASE WHEN bal4 !=0 THEN  1 else 0 END )
              ELSE
              (CASE WHEN BAL1-(BAL4-BAL5)!=0 THEN 1 ELSE 0 END)
                   END )
    else 0 end )as "bktCount-4",
    SUM(
    CASE WHEN TOTSANCLIMIT between 5000001 and 10000000
    then
          (Case when  hrk in (13,14) THEN 
              to_number(to_char(bal4,'99999999999.99'))
         else
              to_char(BAL1,'99999999999.99')-(to_char(BAL4,'99999999999.99')-to_char(BAL5,'99999999999.99'))
         END )
    ELSE 0 end) AS"Bkt_4",
    sum(case when totsanclimit BETWEEN  10000001 AND 200000000  then
    (Case when  hrk in (13,14) THEN 
              (CASE WHEN bal4 !=0 THEN  1 else 0 END )
              ELSE
              (CASE WHEN BAL1-(BAL4-BAL5)!=0 THEN 1 ELSE 0 END)
                   END )
    else 0 end )as "bktCount-5",
    SUM(
    CASE WHEN TOTSANCLIMIT  BETWEEN  10000001 AND  200000000
    then
         (Case when  hrk in (13,14) THEN 
              to_number(to_char(bal4,'99999999999.99'))
         else
              to_char(BAL1,'99999999999.99')-(to_char(BAL4,'99999999999.99')-to_char(BAL5,'99999999999.99'))
         END )
    ELSE 0 end) AS"Bkt_5",
    sum(case when totsanclimit > 200000000 then
    (Case when  hrk in (13,14) THEN 
              (CASE WHEN bal4 !=0 THEN  1 else 0 END )
              ELSE
              (CASE WHEN BAL1-(BAL4-BAL5)!=0 THEN 1 ELSE 0 END)
                   END )
    else 0 end )as "bktCount-6",
    SUM(
    CASE WHEN TOTSANCLIMIT  >  200000000
    then
    (Case when  hrk in (13,14) THEN 
              to_number(to_char(bal4,'99999999999.99'))
         else
              to_char(BAL1,'99999999999.99')-(to_char(BAL4,'99999999999.99')-to_char(BAL5,'99999999999.99'))
         END )
    ELSE 0 end) AS"Bkt_6",
    --total
    sum(
         (Case when  hrk in (13,14) THEN
                     (CASE WHEN bal4 !=0 THEN  1 else 0 END )
                  ELSE
                     (CASE WHEN BAL1-(BAL4-BAL5)!=0 THEN 1 ELSE 0 END)
           end)
    )as "TotCount-7",
    SUM((Case when  hrk in (13,14) THEN 
              to_number(to_char(bal4,'99999999999.99'))
         else
              to_char(BAL1,'99999999999.99')-(to_char(BAL4,'99999999999.99')-to_char(BAL5,'99999999999.99'))
         END )
    ) AS"Total"
    from
    select
    q1.lbrcode,q1.prdacctid,q1.totsanclimit,q2.balance1,balance3,balance4,balance5,balance6,balance7,q3.hrk
    FROM
    SELECT LBRCODE,PRDACCTID,SANCDATE,TOTSANCLIMIT,RNK FROM
               SELECT
               LBRCODE,
               PRDACCTID,
               EFFFROMDATE,
               CURCD,
               PLRLINKYN,
               SANCAUTHORITY,
               SANCDATE,
               TOTSANCLIMIT,
               RANK() OVER (PARTITION BY LBRCODE,PRDACCTID ORDER BY EFFFROMDATE DESC) AS RNK
               FROM LIMIT_MAST
               WHERE LBRCODE IN (3)
    --    AND PRDACCTID LIKE 'PLLN %'
    WHERE RNK=1
    )Q1,
    (SELECT LBRCODE,PRDACCTID,CBLDATE,BALANCE1,BALANCE2,BALANCE3,BALANCE4,BALANCE5,BALANCE6,BALANCE7 FROM
    ( SELECT TRN_MAST.*,
      RANK() OVER(PARTITION BY LBRCODE,PRDACCTID ORDER BY CBLDATE DESC) AS HRK
      FROM TRN_MAST
      WHERE CBLDATE <= TO_DATE('31-MAR-2008','DD-MON-RR')
      AND (LBRCODE,TRIM(SUBSTR(PRDACCTID,1,8))) IN (SELECT LBRCODE,TRIM(PRDCD) FROM PRD_MAST
            WHERE MODULETYPE IN (13,14,30))
    )WHERE HRK=1
    )Q2,
    ( SELECT LBRCODE,TRIM(PRDCD) prd,MODULETYPE hrk FROM PRD_MAST
    WHERE (LBRCODE,TRIM(PRDCD)) IN
    (SELECT LBRCODE,TRIM(SUBSTR(PRDACCTID,1,8)) FROM LIMIT_MAST)
    )q3
    WHERE Q1.LBRCODE=Q2.LBRCODE
    AND Q1.PRDACCTID=Q2.PRDACCTID
    AND TRIM(SUBSTR(Q2.PRDACCTID,1,8))=q3.PRD
    AND Q1.LBRCODE=q3.LBRCODE
    group by lbrcode,trim(substr(prdacctid,1,8))
    order by lbrcode
    /

    Like this?
    SQL> select 123456 my_num from dual;
        MY_NUM
        123456
    SQL>
    SQL> column my_num format 999999.99
    SQL>
    SQL> select 123456 my_num from dual;
        MY_NUM
    123456.00
    SQL>Asif Momen
    http://momendba.blogspot.com

  • Pls help to rewrite the query in another method .

    Insert into bl_voyage_details (BVD_COMPANY,BVD_REFERENCE,BVD_SERIAL,BVD_CARRIER,BVD_VESSEL,BVD_VOY,BVD_LOCATION,BVD_TYPE,BVD_CRT_BY,BVD_CRT_ON,
    BVD_UPD_BY,BVD_UPD_ON,BVD_STATUS,BVD_STATUS_DATE,BVD_STATUS_BY )
    Values (Select bdl_company,bdl_reference,
    *(select nvl(max(bvd_serial),0)+1 from bl_voyage_details)*
    ,bdl_carrier,bdl_vessel,bdl_voy,bdl_location,bdl_type,user,sysdate,user,'0',sysdate,sysdate from bl_details)
    Insert into bl_voyage_details (BVD_COMPANY,BVD_REFERENCE,BVD_SERIAL,BVD_CARRIER,BVD_VESSEL,BVD_VOY,BVD_LOCATION,BVD_TYPE,BVD_CRT_BY,BVD_CRT_ON,
    BVD_UPD_BY,BVD_UPD_ON,BVD_STATUS,BVD_STATUS_DATE,BVD_STATUS_BY )
    Values (Select bdl_company,bdl_reference,
    *(select nvl(max(bvd_serial),0)+1 from bl_voyage_details where (BVD_COMPANY,BVD_REFERENCE)in (bdl_company,bdl_reference)* )
    ,bdl_carrier,bdl_vessel,bdl_voy,bdl_location,bdl_type,user,sysdate,user,'0',sysdate,sysdate from bl_details)
    Edited by: Rinz on Apr 27, 2010 3:57 PM
    Edited by: Rinz on Apr 27, 2010 3:57 PM

    Seems related to your previous question ( Procedure creation )
    Is there any reason why you couldn't just use a sequence:
    insert into bl_voyage_details
    (bvd_company,
      bvd_reference,
      bvd_serial,
      bvd_carrier,
      bvd_vessel,
      bvd_voy,
      bvd_location,
      bvd_type,
      bvd_crt_by,
      bvd_crt_on,
      bvd_upd_by,
      bvd_upd_on,
      bvd_status,
      bvd_status_date,
      bvd_status_by
    select bdl_company,
           bdl_reference,
           some_sequence.nextval,  --<< use a sequence
           bdl_carrier,
           bdl_vessel,
           bdl_voy,
           bdl_location,
           bdl_type,
           user,
           sysdate,
           user,
           sysdate,
           '0',
           sysdate,
           sysdate
    from   bl_details;Also:
    To post formatted code, put the {noformat} {noformat}- tag before and after your examples.
    When you post:
    {noformat} select *
    from dual;
    {noformat}
    it will appear as: select *
    from dual;
    on the forum.
    The FAQ will tell you more: http://forums.oracle.com/forums/help.jspa                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Pls help me in select query......

    My problem is...
    I have to use a select query in such a manner  that i  can compare the last 8 characters or ignore the first one...

    Hi Aarif,
    Try this :
    parameters :
      p_field1(30)  type c.
    Data :
      w_string(8) type c,
      w_firstchar type c,
      t_itab ......,
      fs_itab like line of itab.
    w_string = p_field1+22(8)      " passing last 8 chars into w_string
    w_firstchar = p_field1+0(1).
    select *
       from DataTab Name
       into  table IntTab Name
    where <field name> eq w_string
          or  <field name> ne w_firstchar.
    If you are accepting the value from user then first pass the last 8 characters into w_string and in your select query get the fields where the value is equal to w_string. And pass the first character into another field and to ignore write NE W_FIRSTCHAR.
    There can be other methods also. This is one of the ways.
    Regards,
    Swapna.
    Edited by: NagaSwapna Thota on Jul 19, 2008 9:23 AM

  • Complex query pls help

    I have a row output like this
    select * from test;
    s.no C1 C2 C3
    1 a1 b1 x1
    2 a1 b1 x2
    3 a1 b1 x3
    i want the output as with the new added column as like this
    s.no C1 C2 C3 C4
    1 a1 b1 x1 a1
    2 a1 b1 x2 b1
    3 a1 b1 x3 x3
    pls help me in this query its urgent for the solution

    Hello,
    So, what is the complexity in this query? Would you like to mention from where you will get that C4 column?
    -Ammad

  • How Can i SEt Dynamic Variant For WEEK on SELECTION Screen.pls help me..

    <b>Hi ALL..
    Pls Help Me for this Problem..i am very confused how can i do that...plese tell me proper process..
    i  want set Dynamice Varient for WEEK on Selection screen..
    I have ALrady SET Dynamice Varient for DATE on Selection Screen.ther isd option is D...but in case of WEEK there is a no option...
    Plese help me..
    thaks in advance..
    pls help me..</b>

    Hello,
    Define your select-option in TVARV (assume Z_THISWEEK). And use a program like:
    DATA:
      zlv_week TYPE KWEEK.
    call function 'DATE_GET_WEEK'       
       exporting date = syst-datum
       importing week = zlv_week.
    SELECT SINGLE *
          FROM tvarvc
         WHERE name = 'Z_THISWEEK'
           AND type = 'S'
           AND numb = '0000'.
    tvarvc-low = zlv_week.
    IF syst-subrc <> 0.
        tvarvc-name     = 'Z_THISWEEK'.
        tvarvc-type     = 'S'.
        tvarvc-opti     = 'EQ'.
        tvarvc-sign     = 'I'.
        tvarvc-numb     = '0000'.
        insert tvarvc.
    ELSE.
      update tvarc.
    ENDIF.
    Regards,
    John.

Maybe you are looking for