Is there better way to write SQl Insert Script

I am running out of ideas while working on one scenario and thought you guys would be able to guide me in right way.
So, the scenario is I have a Table table1 table1(fieldkey, DisplayName, type) fieldkey - pkey   This table have n number of rows. The value of fieldkey in nth row is n. So if we have 1000 record, then the last row has a fieldkey = 1000.
Below is my sample data.
Insert into table1 (FIELDKEY,DISPLAYNAME,TYPE) values
(1001, 'COfficer',100);
Insert into table1 (FIELDKEY,DISPLAYNAME,TYPE) values
(1002, 'PData',100);
Insert into table1 (FIELDKEY,DISPLAYNAME,TYPE) values
(1003, 'EDate',100);
Insert into table1 (FIELDKEY,DISPLAYNAME,TYPE) values
(1004, 'PData',200);
Insert into table1 (FIELDKEY,DISPLAYNAME,TYPE) values
(1005, 'EDate',300);
Insert into table1 (FIELDKEY,DISPLAYNAME,TYPE) values
(1006, 'Owner',400);This way of inserting the row with hardcoded value of fieldkey was creating the problem when the same table was used by other developer for their own new functionality.
So, I thought of using the max(fieldkey) +1 from that table and use it in my insert script. This script file runs every time during software installation.
I thought of using count to see if the row with same displaytype and type exists in that table or not. If exisits do not insert new row, if not insert new row.
It looks like i will have to query the count statement everytime before I insert the row.
select max(fieldkey) +1 into ll_fieldkey from table1
select count(*) into ll_count from table1 where display ltrim(upper(name)) = 'COFFICER' and type =100)
if ll_count >0 then
Insert into table1 (FIELDKEY,DISPLAYNAME,TYPE) values
( ll_fieldkey, 'COfficer',100);
ll_fieldkey := ll_fieldkey +1
end if;
select count(*) into ll_count from table1 where display ltrim(upper(name)) = 'PData' and type =100)
if ll_count >0 then
Insert into table1 (FIELDKEY,DISPLAYNAME,TYPE) values
( ll_fieldkey, 'PData',100);
ll_fieldkey := ll_fieldkey +1
end if;
... and so on for all the insert statement. So, i was wondering if there is some better way to handle this situation of inserting the data.
Thank you

Hi !
For check if the same display name and type already exists in table i would use Unique Key , but then again instead of if statement you should code some exception handlers. ... Hm .. Unque key is by may opinion better solution as
codeing checks .
For faster inserts that is , smaller code .. if there is no rules for values and the values are fixed , in any case you have to do this 100 inserts. If you can "calculate" values then maybe you can figure out some code .. but effect will be the same as hundred insert stetements one after another .. Procedure with this 100 inserts is not so bad solution.
You can fill with values a nested table and then use forall ... save exceptions insert and with above mentioned UK , maybe this will be better.
T
Edited by: ttt on 10.3.2010 13:01

Similar Messages

  • What is a best way to write SQL ?

    Sample Case
    drop table t;
    drop table b;
    create table t ( a varchar2(4), b number, c varchar2(1));
    insert into t values ('A00', 10, 'R');
    insert into t values ('A01', 11, 'R');
    insert into t values ('A02', 12, 'R');
    insert into t values ('A03', 13, 'R');
    insert into t values ('A00', 10, 'P');
    insert into t values ('A01', 11, 'P');
    insert into t values ('A02', 12, 'P');
    insert into t values ('A03', 13, 'P');
    commit;
    create table b ( j varchar(4), k varchar2(1), l varchar2(5), m number(3), n varchar2(5), o number(3));
    insert into b values ('A00', 'P', 'FIXED', 100, 'FLOAT', 60);
    insert into b values ('A01', 'P', 'FIXED', 101, 'FIXED', 30);
    insert into b values ('A02', 'R', 'FLOAT', 45, 'FLOAT', 72);
    insert into b values ('A03', 'R', 'FIXED', 55, 'FLOAT', 53);
    commit;
    10:19:13 SQL> select * from t;
    A B C
    A00 10 R
    A01 11 R
    A02 12 R
    A03 13 R
    A00 10 P
    A01 11 P
    A02 12 P
    A03 13 P
    8 rows selected.
    10:19:19 SQL> select * from b;
    J K L M N O
    A00 P FIXED 100 FLOAT 60
    A01 P FIXED 101 FIXED 30
    A02 R FLOAT 45 FLOAT 72
    A03 R FIXED 55 FLOAT 53
    1/     In table t each reference having 2 records one with P another is with R
    2/     In table b each refrence merged into single record and there are many records which are not existing in table t
    3/      both t and j tables can be joined using a = j
    4/     If from table t for a reference indicator is 'P' then if have to pick up l and m columns, if it is 'R' then I have to pick up n and o columns
    5/     I want output in following format
    A00     P     FIXED          100
    A00     R     FLOAT          60
    A01     P     FIXED          101
    A01     R     FIXED          30
    A02     P     FLOAT          72
    A02     R     FLOAT          45
    A03     P     FLOAT          53
    A03     R     FIXED          55
    6/     Above example is a sample ouput, In above example I have picked up only l,m,n,o columns, but in real example there are many columns ( around 40 ) to be selected. ( using "case when" may not be practical )
    Kindly suggest me what is a best way to write SQL ?
    thanks & regards
    pjp

    Is this?
    select b.j,t.c as k,decode(t.c,'P',l,n) as l,decode(t.c,'P',m,o) as m
    from t,b
    where t.a=b.j
    order by j,k
    J K L M
    A00 P FIXED 100
    A00 R FLOAT 60
    A01 P FIXED 101
    A01 R FIXED 30
    A02 P FLOAT 45
    A02 R FLOAT 72
    A03 P FIXED 55
    A03 R FLOAT 53
    8 rows selected.
    or is this?
    select b.j,t.c as k,decode(t.c,b.k,l,n) as l,decode(t.c,b.k,m,o) as m
    from t,b
    where t.a=b.j
    order by j,k
    J K L M
    A00 P FIXED 100
    A00 R FLOAT 60
    A01 P FIXED 101
    A01 R FIXED 30
    A02 P FLOAT 72
    A02 R FLOAT 45
    A03 P FLOAT 53
    A03 R FIXED 55
    8 rows selected.

  • A better way to write last_day query

    Hi folks,
    I am looking for a better way to write a query to find last_day in month but if its sunday or holiday it should move to day before last day.
    So for example if 31 is sunday it should go for 30, if 30 is holiday it should move down to 29.
    I got this so far but the connect by level is hardcoded to 15. Want to see if there is a better way to get this working:
    select max(datum)
      from (    select last_day(trunc(sysdate)) - level + 1 as datum
                  from dual
            connect by level < 15)
    where to_char(datum, 'day') != 'sunday'    
       and to_char(datum, 'DDMM') not in
             ('3012')Best regards,
    Igor

    Like this
    select to_char(last_day_month, 'Day') day_is,
           last_day_month,
           last_day_month - case when to_char(last_day_month, 'fmday') = 'sunday' then 1
                                 when to_char(last_day_month, 'ddmm' ) = '3012'   then 1
                                 else 0
                            end last_business_day_month
      from (
              select last_day(add_months(trunc(sysdate, 'year'), level-1)) last_day_month
                from dual
              connect by level <= 12
    DAY_IS    LAST_DAY_MONTH LAST_BUSINESS_DAY_MONTH
    Tuesday   31-JAN-12      31-JAN-12              
    Wednesday 29-FEB-12      29-FEB-12              
    Saturday  31-MAR-12      31-MAR-12              
    Monday    30-APR-12      30-APR-12              
    Thursday  31-MAY-12      31-MAY-12              
    Saturday  30-JUN-12      30-JUN-12              
    Tuesday   31-JUL-12      31-JUL-12              
    Friday    31-AUG-12      31-AUG-12              
    Sunday    30-SEP-12      29-SEP-12              
    Wednesday 31-OCT-12      31-OCT-12              
    Friday    30-NOV-12      30-NOV-12              
    Monday    31-DEC-12      31-DEC-12 

  • Is there any way to write-enable an NTFS-format WD external Hard Drive ?

    I have a WD Elements external HD unit, 1TB previously formatted NTFS under Windows XP on a PC. I would like to use this HD unit to both read and write data using both the Windows PC and a MacBook Pro. But when connected to the MacBook Pro (USB), the HD unit shows up as Read Only.
    Is there a way to write-enable the HD unit without losing, or having to backup/restore, the mass of data already saved there ?
    I have tried installing NTFS-G3 on the MBP, as suggested elsewhere. Having done so, when I "get information" about the WD unit, the disc format shows as "Windows NT File System (NTFS)" and not NTFS-G3 as expected. Ran chkdsk on the WD under Windows to iron out any problems in the disc's file system. It ran for several hours before completing successfully, but there was no change at all - the unit is still read-only after re-connecting to the MBP.
    Can anyone help out please?

    Why would you expect it to say NTFS-3G? NTFS-3G is just a program that translates the NTFS to something the Mac OS can deal with. It doesn't change the format of the hard drive. The drive is formatted with the New Technology File System (NTFS), not the NTFS-3G file system.
    Were you not able to write to the drive with NTFS-3G installed? Did you install the free version? If so, did you install MacFuse, also? It is required for the free version of NTFS-3G.
    Edit:
    I just plugged in an NTFS drive and I'm guessing what you were looking for was something to indicate what was doing the translation. On mine I get, "Windows NT File System (Tuxera)." So, I think I understand what you meant before. My guess is as I stated above. Make sure you also have MacFuse installed if you are using the free version of NTFS-3G.
    Message was edited by: Barney-15E

  • Is there a way to create SQL Dev reports with validated binds?

    Is there a way to create SQL Dev reports with validated binds similar to the way user defined extensions can have <prompts> with a <value> that is a SQL statement returning a list of possible values?
    This sure would make select appropriate values for binds in reports easier and less error prone.

    Maybe a forum search on "Windows registry" would turn up some useful things. You're not the first to ask this. You might save yourself and everyone else some time if you'd simply do that.

  • Is there a way to bypass all inserts on a track at once?

    When recording with a ton of inserts, the latency is in the vicinity of about .5 seconds - so is there a way to bypass all inserts on a channel at one?
    So far, I have to open each one and hit "bypass" but I do it so much, since I need to hear it after the inserts, it ends up taking a lot of time.
    I also tried to save the channel setting, reset the channel, then re-insert the channel, but then all automation is lost....

    Not as far as I know, but there are two things that might help.
    1) You don't need to open a plug-in to bypass it - just option-click on its insert slot.
    2) Check out low latency mode. (prefs -> audio -> general) which will bypass plug-ins which exceed your latency preference. Click it off when you're done.

  • Is there any way to write to a socket after shutting it down?

    Guys is there any way to write to a socket after using the shutdownOutput() method?
    I get this complain at runtime
    java.net.SocketException: Cannot send after socket shutdown: socket write error

    Your question embodies a contradiction in terms. Shutting down the socket means that you're telling the other end there is no more data. So you can't send more data. And even if you could, the other end wouldn't read it, because it would think it had already reached end of stream. Because that's what you told it.
    If you don't want HTTP keep-alive, turn it off via the appropriate HTTP header.
    You should be using HttpURLConnection for this, not a Socket. That takes care of your reading problem: it knows how to process the content-length header.

  • Is there any way to write a Java prg without main()

    I would like to know Is there any way to write a Java program without using main() function.

    > i am unable to execute the program ..............i
    think there must be a main method through with the
    program starts
    The program can be compiled and run. After running it, you'll see "They'll kill you for that" followed by something like "java.lang.NoSuchMethodError: main" and finally someone with a big Volvo will burst into your room and runs you over.

  • SQL insert scripts generation from repository data xml file

    Hi All,
    I want to generate sql insert scripts from repository data xml file which contain <add-item>elements.
    Example: data xml file is contains
    <add-item item-descriptor="user" id="741">
    <set-property name="gender"><![CDATA[female]]></set-property>
    <set-property name="emailStatus"><![CDATA[__NULL__]]></set-property>
    <set-property name="receiveEmail"><![CDATA[__NULL__]]></set-property>
    <set-property name="email"><![CDATA[[email protected]]]></set-property>
    <set-property name="password"><![CDATA[a694cb1d6d011eddc444acb77338c1df6a22bac5de26330e2fe1d20f15f97ed6]]></set-property>
    <!-- rdonly derived <set-property name="abandonedOrderCount"><![CDATA[0]]></set-property> -->
    <set-property name="locale"><![CDATA[de_DE]]></set-property>
    <set-property name="userType"><![CDATA[1]]></set-property>
    <set-property name="autoLogin"><![CDATA[__NULL__]]></set-property>
    <set-property name="lastName"><![CDATA[Springford]]></set-property>
    <set-property name="member"><![CDATA[true]]></set-property>
    <set-property name="dateOfBirth"><![CDATA[7/18/1951 00:00:00]]></set-property>
    <!-- rdonly derived <set-property name="age"><![CDATA[61]]></set-property> -->
    <set-property name="registrationDate"><![CDATA[5/16/1996 00:00:00]]></set-property>
    <set-property name="login"><![CDATA[sally]]></set-property>
    <set-property name="lastActivity"><![CDATA[6/9/1999 00:00:00]]></set-property>
    <set-property name="homeAddress"><![CDATA[741]]></set-property>
    <set-property name="passwordSalt"><![CDATA[sally]]></set-property>
    <set-property name="generatedPassword"><![CDATA[__NULL__]]></set-property>
    <set-property name="firstName"><![CDATA[Sally]]></set-property>
    <set-property name="lastPasswordUpdate"><![CDATA[__NULL__]]></set-property>
    </add-item>
    Thanks
    Siva

    HI Rohan,
    Thanks for reply..
    I have checked the startSQLRepository script by using this we can export or import repository data from xml to repository.But in startSQLRepository there is no attribute to generate sql
    insert scripts from data xmls but there is a option to get the sql scripts(-ouputSQL).

  • Looking for a better way to write this SQL

    Oracle version 11R2
    OS version (does not matter)
    What I trying to do is write a query that finds Public Synonyms without a target object. I came up with this but I thinking there's a better way.
    Select
      s.owner, s.synonym_name, s.table_name, s.table_owner, s.db_link, InitCap(o.object_type) object_type
    from  
      sys.DBA_SYNONYMS s, sys.DBA_OBJECTS o
    where 
      s.synonym_name is not null
    and   
      s.table_owner = o.owner (+)
    and   
      s.table_name = o.object_name (+)
    and   
      s.owner = 'PUBLIC'
    and
      object_type is null;  object_type is null appears to be the weakness. It seems the check of the target object should be better.
    Feedback, comments, queries welcome.

    I'm not sure exactly what "better" means in this context (faster, easier to read, etc.) but I'd tend to use a NOT EXISTS
    SELECT s.*
      FROM dba_synonyms s
    WHERE owner = 'PUBLIC'
       AND s.db_link IS NULL
       AND NOT EXISTS (
        SELECT 1
          FROM dba_objects o
         WHERE o.owner = s.table_owner
           AND o.object_name = s.table_name )I added the DB_LINK criteria to filter out public synonyms that reference objects in remote databases which obviously don't exist in the local DBA_OBJECTS.
    Justin

  • Need help to get alternate or better way to write query

    Hi,
    I am on Oracle 11.2
    DDL and sample data
    create table tab1 -- 1 millions rows at any given time
    id       number       not null,
    ref_cd   varchar2(64) not null,
    key      varchar2(44) not null,
    ctrl_flg varchar2(1),
    ins_date date
    create table tab2 -- close to 100 million rows
    id       number       not null,
    ref_cd   varchar2(64) not null,
    key      varchar2(44) not null,
    ctrl_flg varchar2(1),
    ins_date date,
    upd_date date
    insert into tab1 values (1,'ABCDEFG', 'XYZ','Y',sysdate);
    insert into tab1 values (2,'XYZABC', 'DEF','Y',sysdate);
    insert into tab1 values (3,'PORSTUVW', 'ABC','Y',sysdate);
    insert into tab2 values (1,'ABCDEFG', 'WYZ','Y',sysdate);
    insert into tab2 values (2,'tbVCCmphEbOEUWbxRKczvsgmzjhROXOwNkkdxWiPqDgPXtJhVl', 'ABLIOWNdj','Y',sysdate);
    insert into tab2 values (3,'tbBCFkphEbOEUWbxATczvsgmzjhRQWOwNkkdxWiPqDgPXtJhVl', 'MQLIOWNdj','Y',sysdate);I need to get all rows from tab1 that does not match tab2 and any row from tab1 that matches ref_cd in tab2 but key is different.
    Expected Query output
    'ABCDEFG',  'WYZ'
    'XYZABC',   'DEF'
    'PORSTUVW', 'ABC'Existing Query
    select
       ref_cd,
       key
    from
        select
            ref_cd,
            key
        from
            tab1, tab2
        where
            tab1.ref_cd = tab2.ref_cd and
            tab1.key    <> tab2.key
        union
        select
            ref_cd,
            key
        from
            tab1
        where
            not exists
               select 1
               from
                   tab2
               where
                   tab2.ref_cd = tab1.ref_cd
        );I am sure there will be an alternate way to write this query in better way. Appreciate if any of you gurus suggest alternative solution.
    Thanks in advance.

    Hi,
    user572194 wrote:
    ... DDL and sample data ...
    create table tab2 -- close to 100 million rows
    id       number       not null,
    ref_cd   varchar2(64) not null,
    key      varchar2(44) not null,
    ctrl_flg varchar2(1),
    ins_date date,
    upd_date date
    insert into tab2 values (1,'ABCDEFG', 'WYZ','Y',sysdate);
    insert into tab2 values (2,'tbVCCmphEbOEUWbxRKczvsgmzjhROXOwNkkdxWiPqDgPXtJhVl', 'ABLIOWNdj','Y',sysdate);
    insert into tab2 values (3,'tbBCFkphEbOEUWbxATczvsgmzjhRQWOwNkkdxWiPqDgPXtJhVl', 'MQLIOWNdj','Y',sysdate);
    Thanks for posting the CREATE TABLE and INSERT statments. Remember why you go to all that trouble: so the people whop want to help you can re-create the problem and test their ideas. When you post statemets that don't work, it's just a waste of time.
    None of the INSERT statements for tab2 work. Tab2 has 6 columns, but the INSERT statements only have 5 values.
    Please test your code before you post it.
    I need to get all rows from tab1 that does not match tab2 WHat does "match" mean in this case? Does it mean that tab1.ref_cd = tab2.ref_cd?
    and any row from tab1 that matches ref_cd in tab2 but key is different.
    Existing Query
    select
    ref_cd,
    key
    from
    select
    ref_cd,
    key
    from
    tab1, tab2
    where
    tab1.ref_cd = tab2.ref_cd and
    tab1.key    <> tab2.key
    union
    select
    ref_cd,
    key
    from
    tab1
    where
    not exists
    select 1
    from
    tab2
    where
    tab2.ref_cd = tab1.ref_cd
    Does that really work? In the first branch of the UNION, you're referencing a column called key, but both tables involved have columns called key. I would expect that to cause an error.
    Please test your code before you post it.
    Right before UNION, did you mean
    tab1.key    != tab2.key? As you may have noticed, this site doesn't like to display the &lt;&gt; inequality operator. Always use the other (equivalent) inequality operator, !=, when posting here.
    I am sure there will be an alternate way to write this query in better way. Appreciate if any of you gurus suggest alternative solution.Avoid UNION; it can be very inefficient.
    Maybe you want something like this:
    SELECT       tab1.ref_cd
    ,       tab1.key
    FROM           tab1
    LEFT OUTER JOIN  tab2  ON  tab2.ref_cd     = tab1.ref_cd
    WHERE       tab2.ref_cd  IS NULL
    OR       tab2.key     != tab1.key
    ;

  • GUYS!! Is there any way to write BLOB's 4K using Oracle thin driver

    I've been trying for 3 days to do that but nothing worked ...
    Not
    setBinaryStream(x, new ByteArrayInputStream(anArrayWith10KBytes), anArrayWith10KBytes);
    nor setBytes(x, myArray), or setObject(x, myArray).
    Is there any way to store Blobs to Oracle 8.1.6 using the thin driver ????????????
    Please help ... cause I really need it !!!
    Best regards,
    Stefig

    Hi Stefig
    Following code help you to store the files >4k in BLOB column in Oracle database
    test is a table in which TEST is BLOB column
    String url = "jdbc:oracle:thin:@.....";
    String user = "user name";
    String password = "password";
    Connection conn = null;
    PreparedStatement aQuery = null;
    ResultSet rs = null;
    try
    Class.forName("oracle.jdbc.driver.OracleDriver");
    conn = DriverManager.getConnection(url,user,password);
    conn.setAutoCommit(false);
    Statement stmt = conn.createStatement();
    stmt.execute("insert into test values (EMPTY_BLOB())");
    rs = stmt.executeQuery("select TEST from test");
    rs.next();
    BLOB blob =((OracleResultSet)rs).getBLOB(1);
    File f = new File(filename);
    FileInputStream io = new FileInputStream(f);
    OutputStream os = blob.getBinaryOutputStream();
    int size = io.available();
    byte[] buffer = new byte[1024];
    int length=0;
    while((length=io.read(buffer)) != -1)
    os.write(buffer,0,length);
    io.close();
    os.close();
    stmt.execute("commit");
    catch()
    Good Luck
    From
    Sachin

  • Is there better way?

    Hi! To check which input for the population is lower I used double min and double max. But while loop for counting years is not working. What is better way to do it?
    I'd appreciate any help you can give.
    Thanks.
    Program asks for data on two species and has to respond by telling how many years it will
    take for the species with lower
    population outnumber the species that starts with higher population.
    class SpeciesTry
    private String name1;
    private String name2;
    private int population1;
    private int population2;
    private double growthRate1;
    private double growthRate2;
    public void readInput( )
    System.out.println("What is the first species' name?");
    name1 = SavitchIn.readLine( );
    System.out.println("What is the population of the species?");
    population1 = SavitchIn.readLineInt( );
    while (population1 < 0)
    System.out.println("Population cannot be negative.");
    System.out.println("Reenter population:");
    population1 = SavitchIn.readLineInt( );
    System.out.println("Enter growth rate (percent increase per year):");
    growthRate1 = SavitchIn.readLineDouble( );
    System.out.println("What is the second species' name?");
         name2 = SavitchIn.readLine( );
         System.out.println("What is the population of the species?");
         population2 = SavitchIn.readLineInt( );
         while (population2 < 0)
         System.out.println("Population cannot be negative.");
         System.out.println("Reenter population:");
         population2 = SavitchIn.readLineInt( );
         System.out.println("Enter growth rate (percent increase per year):");
    growthRate2 = SavitchIn.readLineDouble( );
    public void writeOutput( )
    System.out.println("Name of the species' = " + name1);
              System.out.println("Population = " + population1);
              System.out.println("Growth rate = " + growthRate1 + "%");
              System.out.println("Name of the species' = " + name2);
              System.out.println("Population = " + population2);
    System.out.println("Growth rate = " + growthRate2 + "%");
    public void outnumbersPopulation()
    double max=0; double min=0; double minGrowthRate=0; double maxGrowthRate=0;
    String maxName=null; String minName=null;
    int years=0;
    if ((population1<=population2)&(growthRate1<=growthRate2))
    System.out.println("The species " + name1 + " will never outnumber the species " + name2 );
    System.exit(0);
    else if ((population2<=population1)&(growthRate2<=growthRate1))
    System.out.println("The species " + name2 + " will never outnumber the species " + name1 );
    System.exit(0);
    if((population1>population2)&(growthRate1<growthRate2))// this is to determine which population is smaller
    max=population1;
    maxName=name1;
    maxGrowthRate=growthRate2;
    min=population2;
    minGrowthRate=growthRate1;
    minName=name2;
    if ((population2>population1) &(growthRate2<growthRate1))
    max=population2;
    maxName=name2;
    maxGrowthRate=growthRate1;
    min=population1;
    minName=name1;
    minGrowthRate=growthRate2;
    while ( (min <=max) & (years > 0) )
    min= (min +((minGrowthRate/100) * min));
    max=(max + ((maxGrowthRate/100) * max));
    years ++;
    System.out.println("The species " + minName + " will outnumber the species " + maxName +
    " in " + (years+1) + " years");
    public class Species
         public static void main(String[] args)
         SpeciesTry s1= new SpeciesTry();
         s1.readInput();
         s1.writeOutput();
         s1.outnumbersPopulation();
    }

    I'm new to Java and posting. So, here's my program again with outnumberPopulation() method formated. Is there any hope for this program?
    class SpeciesTry
    private String name1;
    private String name2;
    private int population1;
    private int population2;
    private double growthRate1;
    private double growthRate2;
    public void readInput( )
    System.out.println("What is the first species' name?");
    name1 = SavitchIn.readLine( );
    System.out.println("What is the population of the species?");
    population1 = SavitchIn.readLineInt( );
    while (population1 < 0)
    System.out.println("Population cannot be negative.");
    System.out.println("Reenter population:");
    population1 = SavitchIn.readLineInt( );
    System.out.println("Enter growth rate (percent increase per year):");
    growthRate1 = SavitchIn.readLineDouble( );
    System.out.println("What is the second species' name?");
         name2 = SavitchIn.readLine( );
         System.out.println("What is the population of the species?");
         population2 = SavitchIn.readLineInt( );
         while (population2 < 0)
         System.out.println("Population cannot be negative.");
         System.out.println("Reenter population:");
         population2 = SavitchIn.readLineInt( );
         System.out.println("Enter growth rate (percent increase per year):");
    growthRate2 = SavitchIn.readLineDouble( );
    public void writeOutput( )
    System.out.println("Name of the species' = " + name1);
              System.out.println("Population = " + population1);
              System.out.println("Growth rate = " + growthRate1 + "%");
              System.out.println("Name of the species' = " + name2);
              System.out.println("Population = " + population2);
    System.out.println("Growth rate = " + growthRate2 + "%");
       public void outnumbersPopulation()
            double max=0;  double min=0; double minGrowthRate=0; double maxGrowthRate=0;
            String maxName=null; String minName=null;
                    int years=0;
            if( population1>population2)// this is to determine which population is smaller
            {    max=population1;
                maxName=name1;
                maxGrowthRate=growthRate2;
                min=population2;
                minGrowthRate=growthRate1;
                minName=name2;
             else
                    max=population2;
                    maxName=name2;
                    maxGrowthRate=growthRate1;
                    min=population1;
                    minName=name1;
                    minGrowthRate=growthRate2;
           if (minGrowthRate<=maxGrowthRate)
              System.out.println(minName+" will never grow larger than "+maxName);
              return;
             while ( (min <=max) & (years > 0) )
                 min= (min +((minGrowthRate/100) * min));
                   max=(max + ((maxGrowthRate/100) * max));
                               System.out.println("Check" + max + min);
                               years ++;
            System.out.println("The species " + minName + " will outnumber the species " + maxName +
            " in " + (years+1) + " years");
    public class Species
         public static void main(String[] args)
         SpeciesTry s1= new SpeciesTry();
         s1.readInput();
         s1.writeOutput();
         s1.outnumbersPopulation();
    }

  • Is there any way to add SQL Server 2008 R2 "SQL Authentication" logins to SQL Server Integration Services

    Hi Experts, 
    We have a way to add the Windows Authentication-logins /OS users  in SSIS
    Component Services -> Computers -> My Computer -> DCOM Config -> MSDTSServer
    Right click on MSDTSServer
    Click properties
    Click on the Security tab
    Select Customize and add the users/groups to the Launch/Activation and Access tabs accordingly
    Add the user to the local Distributed COM Users group
    Restart the SSIS service
    +++But do we have a way to add SQL Server Authetication logins to SSIS, Please clarify me 
    Prem Gokull

    Hi PREM,
    If I understand correctly, you want to use SQL Server Authentication log to SQL Server Integration Services.
    Based on my research, only Microsoft Windows Authentication is available for SSIS. So we cannot use SQL Server Authentication log to SQL Server Integration Services. Besides, we can only add OS users in the DCOM Config permission area.
    Reference:
    Connect to Server (Integration Services)
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Is there any way that we can run script file Directly through RMAN.

    Hi Team,
    I have backup script as ,
    allocate channel t1 type disk;
    backup
    format 'C:\bkup'
    (database);
    release channel t1;
    I had used this script for backup operation on RMAN & its executing properly...as
    RMAN> run
    2> {
    3> allocate channel t1 type disk;
    4> backup
    5> format 'C:\bkup'
    6> (database);
    7> release channel t1;
    8> }     
    Now I want to put this srcipt file in one file i.e (backup.sh) ... Can I give this backup.sh file (stored in disk location)directly to the Run command. Is there any way ..
    Plz comment...

    You can use cmdfile parameter to specify the script which contains the actual code and also you can specify log parameter for the log file. Here is an example:
    rman target / cmdfile=backup.ora log=backup.log
    And here are all the command line parameters which you can use with RMAN:
    Argument Value Description
    target quoted-string connect-string for target database
    catalog quoted-string connect-string for recovery catalog
    nocatalog none if specified, then no recovery catalog
    cmdfile quoted-string name of input command file
    log quoted-string name of output message log file
    trace quoted-string name of output debugging message log file
    append none if specified, log is opened in append mode
    debug optional-args activate debugging
    msgno none show RMAN-nnnn prefix for all messages
    send quoted-string send a command to the media manager
    pipe string building block for pipe names
    timeout integer number of seconds to wait for pipe input
    checksyntax none check the command file for syntax errors
    Daljit Singh

Maybe you are looking for

  • Using variables in a text field

    I am very rusty using lingo, and I cannot find how to do this in any of my old projects (using director 7 if that helps you date this) I am trying to generate a random number, which becomes visible in a text field on the stage after the user presses

  • HOW TO BLOCK THE PURCHASE ORDER AND MARK FOR DELETION ?

    Hi ,                     During the Creation of the Purchase order in the SAP System... After creation of the Purchase order should be blocked and a work item is created for the approver. If the Approver approves the Order then the Order is Unblocked

  • Newbie back end choice

    When installing the trial version of Flash Builder 4 how does a newbie know what to choose as a back end? Someone who just wants to "learn Flex in a week"? Is there a FAQ somewhere, or do we need to post every question? Thanks!

  • RE logical/physical standby database

    1. Why logical standby database is SQL apply, and Physical standby database is redo apply? What 's the meaning/objective for that? (pls don't tell me what is SQL/redo apply) 2. As we know, a logical standby database can be used for reporting and quer

  • Problem in Project progress

    Hi, I am facing problem in Project progress report CNE5. System is calculated 300 % poc in Adjusted aggregated actual POC & Aggregated actual POC field only after full confirmed the activity (Degree of Processing is showing in report as 100%). If I c