FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour SQL Insert into... Select...
Posts: 130
Joined: Sun Mar 08, 2009 04:33 PM
SQL Insert into... Select...
Posted: Thu Jul 14, 2022 09:06 AM
Hi,

I try:

Code (fw): Select all Collapse
.
.
.
    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) ]
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: SQL Insert into... Select...
Posted: Thu Jul 14, 2022 12:16 PM
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 (fw): Select all Collapse
cSql:="INSERT INTO Smp_Test (PR_Sifra,PR_Naziv) (SELECT PR_Sifra, PR_Naziv FROM Smp_Partneri)"
oCn:Execute( cSql )
Posts: 130
Joined: Sun Mar 08, 2009 04:33 PM
Re: SQL Insert into... Select...
Posted: Thu Jul 14, 2022 12:49 PM

Thank you

Best regards

Milos



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

Continue the discussion