hi,
i'm using a php script to get data from nav natif base.in the nav 5.01 there is a new table Job N°8004160 which replace the old one N°167.when i execute this query "SELECT * FROM " im getting data from the old one.i've the same problem with job Task.
is there a solution ?
thanks
0
Comments
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
the old one : _8004061 Job
the new one : Job
so there is a explaination why nav odbc confuse the new one with the old one
here is the script
// this part is for connection
dsn = 'navision';//nom de la base de données
$DBUser = 'part';// nom de l'utilisateur de la base de données ciblée
$DBPwd = '';//passe de la base de données ciblée
$link2 = odbc_connect($dsn, $DBUser, $DBPwd ) or die(odbc_errormsg() );//connection à navision
$result = @odbc_data_source( $link2, SQL_FETCH_FIRST );
while($result)
{
if (strtolower($dsn) == strtolower($result)) {
echo $result . "<br>\n";
break;
}
else
$result = @odbc_data_source( $link2, SQL_FETCH_NEXT );
}
//this part its for getting data
$query = 'SELECT "No_","Type","Name","Address","City","Job Title","Status" FROM Resource WHERE (Status = 0 or Status = 1) and Type = 0';
$result = odbc_exec($link2,$query);// on test la connection
if (!$result)
{
print("Execution import resource failed:\n");
print(" State: ".odbc_error($link2)."\n");
print(" Error: ".odbc_errormsg($link2)."\n");
}
else
{
echo $result;
while(odbc_fetch_row($result))// on parcours la table employee sur nav
{
$num = odbc_result($result,'No_');
$ind = mysql_query("SELECT COUNT(*) as count FROM ressource WHERE Code_Ressource like '$num'");
if ($ind) $res = mysql_fetch_array($ind);
if($res == 0)// on teste si 0 nexiste po si 1 existe et donc on najoute po
{
$type = odbc_result($result,'Type');
$name = odbc_result($result,'Name');
$adr = odbc_result($result,'Address');
$ville = odbc_result($result,'City');
$job = odbc_result($result,'Job Title');
$statut = odbc_result($result,'Status');
mysql_query("insert into ressource values('$num','$name','$adr','$ville','$job','$type','$statut')");
}
}
}
//i'm using the exactly same script for Job and Job task
$query = 'SELECT * FROM Job ';//
$result = odbc_exec($link2,$query);// on test la connection
if (!$result)
{
print("Execution import affaire failed:\n");
print(" State: ".odbc_error($link2)."\n");
print(" Error: ".odbc_errormsg($link2)."\n");
}
else
{
echo $result;
while(odbc_fetch_array($result))// on parcours la table employee sur nav
{
$code = odbc_result($result,'No_');//Code affaire
$ind = mysql_query("SELECT COUNT(*) as count FROM affaire WHERE Code_Affaire like '$code' ");
if ($ind) $res = mysql_fetch_array($ind);
if($res == 0)// on teste si 0 nexiste po si 1 existe et donc on najoute po
{
$des = odbc_result($result,'Search Description');//code tache affaire
$des2 = odbc_result($result,'Description');//code tache affaire
$sub = odbc_result($result,'Subject');//code tache affaire
$sol = odbc_result($result,'Finished');//code tache affaire
$type = odbc_result($result,'Job Type');//description tache affaire
mysql_query("insert into affaire values('$code','$des','$des2','$sub','$sol','$type')");
}
}
}
- write a script with only the minimal code needed to retrieve some fields from eg. the Item table
- then modify this script to retrieve some fields from your new Job table
- if this doesn't work, rename the old Job table (I hope you are using a separate development NAV database) to OldJobTable and try again
- if this doesn't work, delete the old Job table (you are working on a separate development database, are you?) and try again
- restart servers to prevent results from being cached
so that confirm that nav confuse the old and the new job table.
but i cant work with this solution i can not rename the job table.
is there a way to bypass this ?
there is a another point.when i access some tables it gaves me an error like this
non unique column reference.
i searched on internet and i founded that it may be caused by 2 fields having the same caption or by a tables which contain many fields.
i have no fields with the same captions.
i've deleted some fields and its works.
in the case too , i can't use this solution.
so i'm open to any suggestion
thanks a lot
for the confusion between names i've changed the captionML of job and i'm using it and its working.i dont know if its a good solution.can this be change cause some problems to nav ?
You can change these ML (=multilanguage) properties without problems. In the NAV code, all references are made through tablenames & fieldnames.
Glad you are finally finding a solution.
but for the no unique column reference .is there a way to make it work without deleting fields from tables.because that what i found.its seems like the Nodbc driver can not handle more than 100 fields.