Announcement

Collapse
No announcement yet.

late night question - search negates the WHERE clause in the SQL of a grid

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • late night question - search negates the WHERE clause in the SQL of a grid

    I have a grid, and I hard code the where clause directly into the SQL.

    But I just noticed that when I use the search button, if I do not enter anything into the fields, it shows me all the records (no where clause).

    What am I doing wrong?

  • #2
    Hi Jamie,

    whats your where clause and which version of sc? In SC 7.1 I can not reconstruct the "problem".
    Best regards: - Reinhard -

    I use ScriptCase 8 Enterprise Edition, Version 8.(latest)

    Comment


    • #3
      Hi Reinhard,
      I am on SC6. What I was doing was using the following in onScriptInit, and it initially worked when I stared in Summary mode, and also when I clicked on the links in summery.


      // see if we are at site or just team level
      if ([glo_site_id] == "")
      {
      // no site id, so we are up at team level
      [credittitle] = "Credits and Refund Requests for Team: ".[glo_team_name];

      if (empty({sc_where_current}))
      {
      sc_select_where(add) = " where OrgID = [glo_team_id] ";
      }
      else
      {
      sc_select_where(add) = " AND OrgID = [glo_team_id] ";
      }

      }
      else
      {
      [credittitle] = "Credits and Refund Requests for Site: ".[glo_site_name];

      // there is a site id, so just show that one site worth of credit activity
      if (empty({sc_where_current}))
      {
      sc_select_where(add) = " where OrgID = [glo_team_id] AND SiteID = [glo_site_id] ";
      }
      else
      {
      sc_select_where(add) = " AND OrgID = [glo_team_id] AND SiteID = [glo_site_id] ";
      }

      }


      But when I did a quick search or a full search (using the button), no matter what I did in the normal events and the search events, it would end up showing me all records (no longer filtered by my WHERE clause). What I did was limit where in my system I can reach this grid app, and made the WHERE clause hardcoded in my SQL for the grid (no longer in the scripts). It kinda sucks, but it works for now. Oh well!

      Thanks,
      Jamie

      Comment


      • #4
        One idea - you hardcoded this in your grid:

        SELECT ... WHERE [glo_where_phrase_1] AND [glo_where_phrase_2] AND [glo_where_phrase_x]

        In your scripts you write:

        initial:

        [glo_where_phrase_1] = "1=1";
        [glo_where_phrase_2] = "2=2";
        [glo_where_phrase_x] = "3=3";

        grid:

        [glo_where_phrase_1] = "OrgID = [glo_team_id]";

        Before the grid, the select statement show all records with this statement (1=1, 2=2 etc. are only placeholders):

        SELECT ... WHERE 1=1 AND 2=2 AND 3=3

        In the grid:

        SELECT ... WHERE OrgID = 1 AND 2=2 AND 3=3

        So you have only one select statement and replace if required the conditions.
        Best regards: - Reinhard -

        I use ScriptCase 8 Enterprise Edition, Version 8.(latest)

        Comment

        Working...
        X