SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 6 of 6
  1. #1
    Junior Member
    Join Date
    Nov 2007
    Posts
    19
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    SQL Statement not executing in WinRunner

    Error:

    Syntax error near 'input' on line 1

    <font class="small">Code:</font><hr /><pre>db_connect ("query1","DSN=STOREDB",30);
    db_execute_query("query1","delete from employee",record_number);
    db_execute_query("query1","input into employee from c:\data\store_data\winrunner_employee.dat format ASCII delimited by ','",record_number);
    db_get_last_error("query1",error);
    pause (error);</pre><hr />

    This works fine when I paste it into dbisql.

    Also, I am connecting to the dbi just fine, my other sql statements run just fine.
    ---My Info---
    1. 9.2
    2. Web/HTTP (HTML mode)
    3. No
    5. None
    6. New
    7. Web 1000
    8. No
    9. Windows Server 2003 SP1
    10. No

  2. #2
    Moderator
    Join Date
    Mar 2002
    Location
    Tampa Bay
    Posts
    7,673
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: SQL Statement not executing in WinRunner

    I can't make much sense out of your cryptic post, but offhand, I suggest you escape the backslashes.

  3. #3
    Junior Member
    Join Date
    Nov 2007
    Posts
    19
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: SQL Statement not executing in WinRunner

    Sorry for the cryptic post. I am trying to connect to the sql db to update records using a comma delimited txt file.

    My sql statement is returning the following error:

    "Syntax error near 'input' on line 1"

    I have no problems running any other sql statements through winrunner, and the sql statement executes just fine when I do it manually. I escaped the backslashes like you said, but that didn't fix the issue.


    Here is my code:

    <font class="small">Code:</font><hr /><pre>
    db_connect ("query1","DSN=STOREDB",30);
    db_execute_query("query1","input into employee from c:\\data\\store_data\\winrunner_employee.dat format ASCII delimited by ',';",record_number);
    ---My Info---
    1. 9.2
    2. Web/HTTP (HTML mode)
    3. No
    5. None
    6. New
    7. Web 1000
    8. No
    9. Windows Server 2003 SP1
    10. No

  4. #4
    Moderator
    Join Date
    Mar 2000
    Location
    Orange County, CA
    Posts
    3,187
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: SQL Statement not executing in WinRunner

    I think I see your problem.

    You are trying to import information from a ascii file into the database. While this may be supported from the interface you normally use for your database, I am pretty confident in saying that functionality isn't going to be supported within WinRunner inherently in the db_* functions.

    What you are probably going to have to do is code a function where it opens the file and parses the information into a format where you can execute individual INSERT statements into the database.
    Insanity: doing the same thing over and over again and expecting different results

  5. #5
    Junior Member
    Join Date
    Nov 2007
    Posts
    19
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: SQL Statement not executing in WinRunner

    [ QUOTE ]
    I think I see your problem.

    You are trying to import information from a ascii file into the database. While this may be supported from the interface you normally use for your database, I am pretty confident in saying that functionality isn't going to be supported within WinRunner inherently in the db_* functions.

    What you are probably going to have to do is code a function where it opens the file and parses the information into a format where you can execute individual INSERT statements into the database.

    [/ QUOTE ]

    Awesome! I'm going to give that a shot. Thanks a lot for your help!
    ---My Info---
    1. 9.2
    2. Web/HTTP (HTML mode)
    3. No
    5. None
    6. New
    7. Web 1000
    8. No
    9. Windows Server 2003 SP1
    10. No

  6. #6
    Senior Member
    Join Date
    Aug 2005
    Location
    Colorado
    Posts
    216
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: SQL Statement not executing in WinRunner

    SQL deletes often don't work properly via WinRunner. WinRunner's support for SQL commands other than "select" is very limited.

    To work around this, I only use WinRunner's db_execute_query for select statements and write my query to a file and do a dos_system call to tell a command line DB client to execute my query.

    I use something like the following to do SQL statements other than select:

    <font class="small">Code:</font><hr /><pre>
    # create query file
    queryFile = getvar("result") &amp; "\\query.sql";

    if((rc = file_open(queryFile,FO_MODE_WRITE)) != E_OK)
    return rc; # failed to open temp query file

    if((rc = file_printf(queryFile,"set scan off;\r\n")) != E_OK)
    return rc;# failed to write to temp query file

    do{
    #Print output to a file.
    if((rc = file_printf(queryFile,"%s;\r\n",sql[i])) != E_OK)
    return rc;# failed to write to temp query file
    i++;
    }while(index(tolower(sql[i]),"select") != 1 &amp;&amp; i&lt;=sql[0]);

    if((rc = file_printf(queryFile,"exit;\r\n")) != E_OK)
    return rc;

    file_close(queryFile);

    # execute the SQL
    rc = dos_system("sqlplus " &amp; db_user &amp; "/" &amp; db_password &amp; "@" &amp; db_server &amp; " @\"" &amp; queryFile &amp; "\"");
    </pre><hr />

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.71%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 02:33 AM.

Copyright BetaSoft Inc.