18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

Does _getDB (Databases) slect sql method support Sub Queries?

LawZLawZ Members
edited May 2013 in Sahi - Open Source
Hi to any Sahi gurus,

I'm using _getDB API to do a select(sql) method where the statement contains a sub query. For example:

var $rs = db.select("SELECT * FROM table1 WHERE table1.pk IN (SELECT pk FROM table2 WHERE pk = 2)");

It gives me an error of "TypeError: Cannot read property "CATEGORY_NAME" from undefined" during execution.

But it works if I change the statement to the follows:

var $rs = db.select("SELECT * FROM table1 WHERE table1.pk = 2");

Can anyone let me know if sub query is supported and how I can apply it?

Many Thanks,


Best Answer

  • Answer ✓
    Hi,

    If anyone still is interested in answering it... The answer is yes, Sahi _getDB does support sub queries.

    I debugged my code again and noticed there was a typo in one of the methods that caused the issue.

    Sahi works. :)

    -LawZ

Answers

  • hi LawZ,

    I am not a guru, but the problem is you are trying to read value CATEGORY_NAME which is not there in your queries output.

    I think the issues is,
    In your main select statement, you are trying to get all column by using *.
    in your sub query you are only selecting pk.
    try using "select * " in place of "select pk" in your sub query.

    Like i mentioned, i am not an expert in coding or queries. i could be wrong.

    Regards,
    Sreekanth.
  • LawZLawZ Members
    Hi Sreekanth, Firstly thanks for your reply, but this is not the issue. I should have been more clear on the issue statement.


    To anyone who could help me resolve this issue:

    The following is the db connection and select(sql) method to get the data:

    var db = _getDB("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@dbDriver:sid","username", "password");
    var $rs = db.select("select category_name from t_category where gl_id in (select gl_id from t_gl where gl_pk = 2)");

    It gives me the error (TypeError: Cannot read property "CATEGORY_NAME" from undefined) when I have a sub query in the select(sql). But it would run successfully without the sub query as follows,

    var $rs = db.select("select category_name from t_category where gl_id = 123");

    Please help,
    Thanks,

    -LawZ
  • LawZLawZ Members
    Can anyone please help? Thanks a bunch! -LawZ
Sign In or Register to comment.