Problem with insert select statement in java swing with oracle

i have problem in insert select statement
 public void GetPT()
    {
        try
        {
             Statement st = con.createStatement();
           
            st.executeUpdate(  " INSERT INTO powercard.platinum_card " 
                    + "SELECT DISTINCT '350060' "
                    + "                || ' ' " + "                || Trunc (dbms_random.VALUE (38500001, 51500000)) pt_card_number, "
                    + "                NULL, " + "                card_number, " + "                client_code, " + "                branch_code, "
                    + "                card_product_code, " + "                old_card_number, " 
                    + "                plastic_code, " + "                embossed_name, " + "                expiry_date, " 
                    + "                last_prod_date, " + "                NULL, " + "                user_create, " + "                date_create, " 
                    + "                user_modif, " + "                date_modif, " + "                'NO'                                              flag "
                    + "FROM   card " + "WHERE  card_product_code = '500' " + "       AND status_code = 'N' " 
                    + "       AND expiry_date > SYSDATE + 30 " + "       AND card_number NOT IN (SELECT card_number " 
                    + "                               FROM   powercard.platinum_card) " + "       AND card_number NOT IN (SELECT range_start " 
                   + "                               FROM   stop_list_card_bin_range) " + "       AND old_card_number IS NULL " 
                    + "       AND last_prod_date IS NOT NULL " + "ORDER  BY 1");

 
            con.commit();

           
        //con.close();
        }
        catch (Exception e)
        {
            System.out.println(e);
        }
    } the table didnt get upadated
osama120Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
If it doesn't make any difference when you close the statement, then your criteria are probably not being met. Always a good thing to do to print out the sql.

Have a look at the sql log to see what's actually getting sent to Oracle
0
osama120Author Commented:
how  can i check it
0
objectsCommented:
execute the select from then command line to verify what it returns.
0
Pramod KumarCommented:
Just put your insert statement into a String variable, print the variable to see the actual output of the sql statement with values.
I think there is some problem with the data type ( putting string, date field value into single quote)

Please also send the actual error you are getting.
String sql =   " INSERT INTO powercard.platinum_card " 
                    + "SELECT DISTINCT '350060' "
                    + "                || ' ' " + "                || Trunc (dbms_random.VALUE (38500001, 51500000)) pt_card_number, "
                    + "                NULL, " + "                card_number, " + "                client_code, " + "                branch_code, "
                    + "                card_product_code, " + "                old_card_number, " 
                    + "                plastic_code, " + "                embossed_name, " + "                expiry_date, " 
                    + "                last_prod_date, " + "                NULL, " + "                user_create, " + "                date_create, " 
                    + "                user_modif, " + "                date_modif, " + "                'NO'                                              flag "
                    + "FROM   card " + "WHERE  card_product_code = '500' " + "       AND status_code = 'N' " 
                    + "       AND expiry_date > SYSDATE + 30 " + "       AND card_number NOT IN (SELECT card_number " 
                    + "                               FROM   powercard.platinum_card) " + "       AND card_number NOT IN (SELECT range_start " 
                   + "                               FROM   stop_list_card_bin_range) " + "       AND old_card_number IS NULL " 
                    + "       AND last_prod_date IS NOT NULL " + "ORDER  BY 1";

System.out.println(sql);//check the console

st.executeUpdate(sql);

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CEHJCommented:
>>Just put your insert statement into a String variable, print the variable

That's what i said at first - osama120, can you tell me why you ignored my comment?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.