|
Débuté par Cherry, 26 jan. 2008 12:17 - 4 réponses |
| |
| | | |
|
| |
Posté le 26 janvier 2008 - 12:17 |
Hello everyone,
I have a problem when I use this code. Someone in this forum advised me to use this but the error occur when I use it.
Here's the example of what I did
sQRYtxt is string ="INSERT INTO TABLE2 (field1, field2, field3)
SELECT field1, field2, field3 FROM TABLE1
WHERE ..."
SQLExec(sQRYtxt,"MyQRY")
Anyone has any idea how to solve this problem.
Thanks in Advance
Cherry |
| |
| |
| | | |
|
| | |
| |
Posté le 26 janvier 2008 - 16:11 |
Hi Cherry...
I currently don't, and I doubt that anyone could with the elements you are giving us... The first thing you have to learn here is how to ask a question on this forum=:
-1- Copy and paste the REAL query, not a dummy one (or incomplete one) representing what you THINK you coded
-2- In your code, test on possible error after each file access and display the full error message that will give you indications
-3- In your message to the forum, copy the full error message
This way we'll have a chance to have a little idea of what is going on
Best regards
Fabrice
>Hello everyone,
I have a problem when I use this code. Someone in this forum advised me to use this but the error occur when I use it.
>Here's the example of what I did
sQRYtxt is string ="INSERT INTO TABLE2 (field1, field2, field3)
>SELECT field1, field2, field3 FROM TABLE1
WHERE ..."
>SQLExec(sQRYtxt,"MyQRY")
Anyone has any idea how to solve this problem.
>Thanks in Advance
Cherry |
| |
| |
| | | |
|
| | |
| |
Posté le 27 janvier 2008 - 20:37 |
Hi Cherry,
I think I'm the 'Someone'
I gave this example assuming you knew a little SQL.
But looking at what you tried to do, I see you don't know SQL at all.
In that case , you have to learn it first, or to use only the W-language commands. In that case, there is no possibility to do what you wanted to do : filling a lot of records in a table using another table as source, in one single move. (because W-language commands allways threat data record by record)
Try the following :
- replace the Table1 and Table2 in the example by the real table names you want to use,
- replace the field1,... by the real item names from your table
- Forget the WHERE if you want all rows to be copied.
Leo.
>Hi Cherry...
I currently don't, and I doubt that anyone could with the elements you are giving us... The first thing you have to learn here is how to ask a question on this forum=:
>-1- Copy and paste the REAL query, not a dummy one (or incomplete one) representing what you THINK you coded
-2- In your code, test on possible error after each file access and display the full error message that will give you indications
>-3- In your message to the forum, copy the full error message
This way we'll have a chance to have a little idea of what is going on
>Best regards
Fabrice
>>Hello everyone,
I have a problem when I use this code. Someone in this forum advised me to use this but the error occur when I use it.
>>Here's the example of what I did
sQRYtxt is string ="INSERT INTO TABLE2 (field1, field2, field3)
>>SELECT field1, field2, field3 FROM TABLE1
>>SQLExec(sQRYtxt,"MyQRY")
Anyone has any idea how to solve this problem.
>>Thanks in Advance
|
| |
| |
| | | |
|
| | |
| |
Posté le 28 janvier 2008 - 07:46 |
Hi Leo,
Sorry that I said not clear before.
What I did I did my tables instead of using table1 or table2(I know what I should do with this). I know SQL but I think I should learn how to post questions like Fabrice told me to. The error says "number of values to insert differs from number of items" here's what I did.
Insert into personnel(personnel_ID,name_L,Name_E,date_birth,period)
select personnel_ID,name_L,name_E,date_birth,period from personnel_temporary
Where period=1
Cherry
>Hi Cherry,
I think I'm the 'Someone'
>I gave this example assuming you knew a little SQL.
But looking at what you tried to do, I see you don't know SQL at all.
>In that case , you have to learn it first, or to use only the W-language commands. In that case, there is no possibility to do what you wanted to do : filling a lot of records in a table using another table as source, in one single move. (because W-language commands allways threat data record by record)
Try the following :
>- replace the Table1 and Table2 in the example by the real table names you want to use,
- replace the field1,... by the real item names from your table
>- Forget the WHERE if you want all rows to be copied.
Leo.
>>Hi Cherry...
I currently don't, and I doubt that anyone could with the elements you are giving us... The first thing you have to learn here is how to ask a question on this forum=:
>>-1- Copy and paste the REAL query, not a dummy one (or incomplete one) representing what you THINK you coded
-2- In your code, test on possible error after each file access and display the full error message that will give you indications
>>-3- In your message to the forum, copy the full error message
This way we'll have a chance to have a little idea of what is going on
>>Best regards
>>>Hello everyone,
I have a problem when I use this code. Someone in this forum advised me to use this but the error occur when I use it.
>>>Here's the example of what I did
sQRYtxt is string ="INSERT INTO TABLE2 (field1, field2, field3)
>>>SELECT field1, field2, field3 FROM TABLE1
>>>SQLExec(sQRYtxt,"MyQRY")
Anyone has any idea how to solve this problem.
>>>Thanks in Advance
|
| |
| |
| | | |
|
| | |
| |
Posté le 28 janvier 2008 - 10:28 |
The error codes produced by sql interpreters are not allways correct.
The item names of both files are identical, therefore you have to specify :
>
INSERT INTO personnel
(personnel.personnel_id, personnel.name_l, personnel.name_e,
personnel.date_birth, personnel.period)
SELECT personnel_temporary.personnel_id, personnel_temporary.name_l,
personnel_temporary.name_e, personnel_temporary.date_birth,
personnel_temporary.period
FROM personnel_temporary
WHERE personnel_temporary.period = 1
Are you shure that the period item is numeric? If not, embed the 1 in single quotes : '1'
Leo.
PS you can find a lot of usefull sql commands at www.ss64.com
(and at many other sites)
I did't get any SQL education, (did'nt exist yet) I just learned it by reading a few books about SQL. If I can, anybody who can read and has some programming skills can.
Hi Leo,
>Sorry that I said not clear before.
What I did I did my tables instead of using table1 or table2(I know what I should do with this). I know SQL but I think I should learn how to post questions like Fabrice told me to. The error says "number of values to insert differs from number of items" here's what I did. |
| |
| |
| | | |
|
| | | | |
| | |
|