Hallo the master
I have difficulties to insert data into TABLE-B using existing data in TABLE-A and is repeated as many as the number of variables that exist.
TABLE-A
- name
- Cb
- Cbd
- Date
TABLE-B
- Name
- Cb
- Cbd
- Date
- Month
- Year
The following is a script that I use in key processes
/variable dari database
sc_lookup(qdefault, “select Date,Cb,Cbd from table-a where person = ‘{person}’”);
$dt = {qdefault[0][0]};
$cb = {qdefault[0][1]};
$cbd = {qdefault[0][2]};
//variable dari kontrol
$x1= {sbln};//start month
$x2= {ebln};//end month
$yr= {year};//defined year by user
$pers = {person};
$user = [usr_login];
//proses insert ke table-b
if({person}<>""){
for ($x = $x1; $x <= $x2; $x++) {
sc_exec_sql(“insert into table-b(Name,Date,Month,Year,Cb,Cbd)
values($pers,$dt,$x,$yr,$cb,$cbd)”);
}//this query is running well
}
else//in this query I want to insert data from a table-a with the amount of data 100, to the table-b but with repetition as much as $ x, year = $ yr with a different month figures.
for ($x = $x1; $x <= $x2; $x++) {
sc_exec_sql(“insert into table-b(Name,Date,Month,Year,Cb,Cbd)
SELECT Name,Date,$x,Year,Cb,Cbd from table-a”);
}// this query error
how to solve it