1

How to insert multiple rows using variable in Oracle database through PHP? My query-:

$qry6= "INSERT INTO sample(name , id , qty , PRICE , tax) VALUES ".$result_product1.";";

where

$result_product1 = (shirt,1,20,300,100),(pant,2,50,400,75),(tie,5,50,100,25);

So how to pass multiple rows in oracle through php? I get from forum as query should be-:

INSERT ALL into sample(name , id , qty , PRICE , tax values (shirt,1,20,300,100)
           into sample(name , id , qty , PRICE , tax values (pant,2,50,400,75)
           into sample(name , id , qty , PRICE , tax values (tie,5,50,100,25);

So plz help me that How can I convert my query in this oracle accepted format.... Plz guide me...

1
  • $result_product is a variable which stores string. Commented Mar 24, 2012 at 10:57

1 Answer 1

1

I dont know much more about insertion in oracle. But as per your question this may help you...

$result_product1 = str_replace( "),(", ") into sample(name , id , qty , PRICE , tax) values (", $result_product1);

And your final query will be...

$qry6= "INSERT INTO sample(name , id , qty , PRICE , tax) VALUES ".$result_product1.";";

Check this...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.