odbc query on nav

bimo88bimo88 Member Posts: 22
hi everybody,

i'm trying to do some select queries on nav using odbc,the problem is when i select a table which name doesn't contain a space everything seems to be working .but when the table name contain a space i have no error and no result. i wich someone would help me. thanks

ps:sorry for my english i'm doing my best :p

Comments

  • bbrownbbrown Member Posts: 3,268
    Use Delimited identifiers.

    Ex: Select {field list} from [dbo].[CompanyName$Sales Header]
    There are no bugs - only undocumented features.
  • bimo88bimo88 Member Posts: 22
    can you give me an exemple plz !!
    i've tried this but it doesn't work :
    $query = "SELECT {Ressource No_,Ressource Group No_} FROM [Nav51_171008].[Cosmos 5.01 Resource / Resource Group]";
  • KYDutchieKYDutchie Member Posts: 345
    Hi,

    try :
    $query = "SELECT {Ressource No_,Ressource Group No_} FROM [Nav51_171008].[Cosmos 5_01 Resource _ Resource Group]";

    the characters "\/." are replaced by "_" in SQL.

    Regards,

    Willy
    Fostering a homeless, abused child is the hardest yet most rewarding thing I have ever done.
  • bimo88bimo88 Member Posts: 22
    hi,
    i already tried it but its not working. for the odbc configuration i've choosed in the identifiers option "All Except dot" so i think all the caracters are transfered like they are except the dot which is remplaced by _.other ideas ?!

    sorry for my english :$ i'm doing my best
  • bbrownbbrown Member Posts: 3,268
    $query = "SELECT [Ressource No_],[Ressource Group No_] FROM [Nav51_171008].[dbo].[Cosmos 5.01 Resource / Resource Group]";
    There are no bugs - only undocumented features.
  • bimo88bimo88 Member Posts: 22
    hi again,

    i've tried something and it seems to be working but i have another problem.
    for the query i've tried this :
    $query = "SELECT 'Resource No_','Resource Group No_' FROM \"Resource / Resource Group\" ";
    but when i use the php function ;
    $num_r = odbc_result($result,'Resource No_');
    i get an error :
    Warning: odbc_result() [function.odbc-result]: Field Resource Group No_ not found .
  • bimo88bimo88 Member Posts: 22
    hi,

    i'm using a php script to get data from nav.the problem is that its works on the tables "resource","group" and "Group / Group resource" but it doesn't work on the table "Job" and "Job Task".
    here is the script.

    $query = "SELECT 'No_','Search Description','Description','Subject','Finished','Job Type' FROM Job"; // on récupère les ressource de type 0 et statut 1 et 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
    {
    print("Execution was successful for the table Job.\n");
    while(odbc_fetch_array($result))// on parcours la table employee sur nav
    {
    $num = odbc_result($result,'No_');
    $ind = mysql_query("SELECT COUNT(*) as count FROM affaire WHERE Code_Affaire like '$num'");//on recherche si la ressource n'existe pas deja
    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');
    $des2 = odbc_result($result,'Description');
    $sub = odbc_result($result,'Subject');
    $fin = odbc_result($result,'Finished');
    $type = odbc_result($result,'Job Type');
    mysql_query("insert into affaire values('$num','$des','$des2','$sub','$fin','$type')");

    }
    }

    i want to know if there is a difference between those tables on nav
Sign In or Register to comment.