SQL Insert into... Select...

Post Reply
mtajkov
Posts: 130
Joined: Sun Mar 08, 2009 4:33 pm

SQL Insert into... Select...

Post by mtajkov »

Hi,

I try:

Code: Select all | Expand


.
.
.
    oCn := FW_OpenAdoConnection( aCredentials, .t. )
.
.
.

cSql:="INSERT INTO Smp_Test (SELECT PR_Sifra, PR_Naziv FROM Smp_Partneri)"
oCn:Execute( cSql )
 


i am getting an error:

Error ADODB.Connection/0 S_OK: EXECUTE
Parameter :
[ 1] = C INSERT INTO Smp_Test (SELECT PR_Sifra, PR_Naziv FROM Smp_Partneri)

Please Help
Best regards
Milos

[ FWH 21.11 ] [ xHarbour 1.2.3 Intl. (SimpLex) (Build 20150603) ]
User avatar
cmsoft
Posts: 1297
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina
Been thanked: 2 times

Re: SQL Insert into... Select...

Post by cmsoft »

Make sure that Smp_Test has only two fields of the same type as PR_Sifra and PR_Naziv


If the instead, has more fields that you don't want to fill, then put

Code: Select all | Expand


cSql:="INSERT INTO Smp_Test (PR_Sifra,PR_Naziv) (SELECT PR_Sifra, PR_Naziv FROM Smp_Partneri)"
oCn:Execute( cSql )
 
mtajkov
Posts: 130
Joined: Sun Mar 08, 2009 4:33 pm

Re: SQL Insert into... Select...

Post by mtajkov »

Thank you
Best regards
Milos

[ FWH 21.11 ] [ xHarbour 1.2.3 Intl. (SimpLex) (Build 20150603) ]
Post Reply