Is It Possible to Combine Two Oracle SQL Queries and Upload Data to Two Tables at Once?

I have these two queries in my PHP code that need to be run at the same time:

Doing it this way just causes errors, so I'm wondering if there's a way to combine them into one SQL query that executes and sends data to two different tables.

Thanks.

                case 'FILESTRUCTURES':
                $DB->query("
                        INSERT INTO srdb_request_fs
                        (
                        request_cn
                        ,created_by
                        ,projectname
                        ,projectsteward
                        ,groupmanager
                        ,fs_notes
                        ,pathname
                        ,foldername
                        ,shortname
                        ,fullname
                        ,request_fs_type_cn
                        ,previous_work_point
                        ,requested_due_date
                        ,unit_request
                        ,primary_purpose_descr
                        ) VALUES (
                        :request_cn
                        ,:created_by
                        ,:projectname
                        ,:projectsteward
                        ,:groupmanager
                        ,:fs_notes
                        ,:pathname
                        ,:foldername
                        ,:shortname
                        ,:fullname
                        ,:request_fs_type_cn
                        ,:previous_work_point
                        ,TO_DATE(:requested_due_date, 'MM-DD-YYYY')
                        ,:unit_request
                        ,:primary_purpose_descr
                        $values
                        )
                        "
                        ,$args
                );


                $DB->query("
                        INSERT INTO srdb_request_fs
                        (
                        request_cn
                        ,created_by
                        ,add_sub_name
                        ,add_subprogram_folder
                        ,add_restricted_subfolder
                        ,author_name
                        ,read_to
                        ,subfolder_description
                        ,previous_work_point
                        ,requested_due_date
                        ,unit_request
                        ,primary_purpose_descr
                ) VALUES (
                        :request_cn
                        ,:created_by
                        ,:add_sub_name
                        ,:add_subprogram_folder
                        ,:add_restricted_subfolder
                        ,:author_name
                        ,:read_to
                        ,:subfolder_description
                        ,:request_fs_type_cn
                        ,:previous_work_point
                        ,TO_DATE(:requested_due_date, 'MM-DD-YYYY')
                        ,:unit_request
                        ,:primary_purpose_descr
                        $values
                )
                        "
                        ,$argsDos
                );
                break;

Answers


To insert values into different tables in one INSERT statement you can use multi-table insert syntax in Oracle:

SQL> create table t1 (x int, y int)
  2  /

SQL> create table t2 (x int, y int, z int)
  2  /

SQL> insert all
  2  into t1 (x,y) values(xs,ys)
  3  into t2 (x,y,z) values(xs,ys,zs)
  4  select 1 xs, 2 ys, 3 zs from dual
  5  /

SQL> select * from t1
  2  /

         X          Y                                                           
---------- ----------                                                           
         1          2                                                           

SQL> select * from t2
  2  /

         X          Y          Z                                                
---------- ---------- ----------                                                
         1          2          3                                                

Need Your Help

Application of Entity Framework to scientific (numerical) processing program

wpf entity-framework optimization inotifypropertychanged

I have a thought provoking question, in relation to the use Entity Framework (EF) to persist data. My (intended) application is not a typical LOB scenario where the standard CRUD operations are don...