RE: [PHP-WIN] MSSQL inserting into a table with a valid result set
| From: | Robert Twitty | Date: | Fri, 12 Mar 2004 19:17:23 +0000 |
| Subject: | RE: [PHP-WIN] MSSQL inserting into a table with a valid result set | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-23124@lists.php.net to get a copy of this message | ||
Hi Gerardo
If I understand you correctly, you can use the odbtp extension to
do something like the following:
$con1 = odbtp_connect( 'server1', 'user1', 'pass1',
'database1' ) or die;
$con2 = odbtp_connect( 'server2', 'user2', 'pass2',
'database2' ) or die;
$sql = "SELECT FieldA, FieldB, FieldC FROM Table1";
$qry1 = odbtp_query( $sql, $con1 ) or die;
odbtp_attach_field( $qry1, "FieldA", $FieldA );
odbtp_attach_field( $qry1, "FieldB", $FieldB );
odbtp_attach_field( $qry1, "FieldC", $FieldC );
$sql = "INSERT INTO Table2(FieldA, FieldB, FieldC) VALUES( ?, ?, ? )";
$qry2 = odbtp_prepare( $sql, $con2 ) or die;
odbtp_input( $qry2, 1 );
odbtp_attach_param( $qry2, 1, $FieldA );
odbtp_input( $qry2, 2 );
odbtp_attach_param( $qry2, 2, $FieldB );
odbtp_input( $qry2, 3 );
odbtp_attach_param( $qry2, 3, $FieldC );
while( odbtp_fetch( $qry1 ) ) odbtp_execute( $qry2 ) or die;
odbtp_close( $con1 );
odbtp_close( $con2 );
-- bob
On Fri, 12 Mar 2004, Gerardo Rojas wrote:
> According to your last email, i can accomplish my goal, by doing:
>
> insert into tablename select xxxxx
>
> where xxxx is another table i presume.
>
> I don't have another table, all I have is a valid $result from running a query.
>
> I see what you mean, the thing is that one query is from 1 remote db and the second query
> (insert command) is on another remote db.
>
>
> --
> Gerardo S. Rojas
> mailto: grojas@strategicinc.com
>
>
> -----Original Message-----
> From: Svensson, B.A.T. (HKG) [mailto:B.A.T.Svensson@lumc.nl]
> Sent: Friday, March 12, 2004 12:26 PM
> To: php-windows@lists.php.net
> Subject: RE: [PHP-WIN] MSSQL inserting into a table with a valid result
> set
>
>
> I don't understand your question.
>
> On Fri, 2004-03-12 at 16:42, Gerardo Rojas wrote:
> > Can i do a select from a PHP: resource (positive MSSQL result identifier)
> >
> >
> > --
> > Gerardo S. Rojas
> > mailto: grojas@strategicinc.com
> >
> >
> > -----Original Message-----
> > From: Svensson, B.A.T. (HKG) [mailto:B.A.T.Svensson@lumc.nl]
> > Sent: Thursday, March 11, 2004 3:25 PM
> > To: 'php-windows@lists.php.net '
> > Subject: RE: [PHP-WIN] MSSQL inserting into a table with a valid result
> > set
> >
> >
> > You can do a insert into with a SELECT instead of VALUE,
> > but the attribute in the select must agree with the table
> > definition.
> >
> >
> > -----Original Message-----
> > From: Gerardo Rojas
> > To: php-windows@lists.php.net
> > Sent: 11-3-2004 21:54
> > Subject: [PHP-WIN] MSSQL inserting into a table with a valid result set
> >
> > I have a valid result set from running a simple query. Is there a way
> > of inserting this into an existing table or creating a new table with
> > the result set? All ideas are welcome!
> >
> > MSSQL Server 2000
> > PHP 4.3.4
> > Windows 2000 pro
> > IIS 5.0
> >
> >
> > --
> > Gerardo S. Rojas
> > mailto: grojas@strategicinc.com
> >
> > --
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>