Announcement

Collapse
No announcement yet.

[SOLVED] Simple Search question

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

  • [SOLVED] Simple Search question

    Hi,

    I'm just started with scriptcase and can not get pass the simple search query form.

    I have an SQL Query to a PostGIS providing a geographical point {x_var} {y_var} and getting a zip code as a result. SELECT zip FROM "public".zip_areas WHERE ST_Contains(the_geom,ST_GeomFromWKB(ST_AsEWKB('POI NT({x_var} {y_var})'::geometry), 4326))

    I started with a search application and defined two fields x_field and y_field with a substitution assignment for the x_var to x_field and y_var to the y_field. I can not find the way to define the output field for the resulting zip.

    What is the right way to do an application with two input fields x: and y:, a search button and one output field zip:?

    Can I have both input fields and output field on the same page where the output field (initially empty) will be filled with the search result? Or do I have to have two pages - one for search with input fields and another (possibly grid?) with output field to display the resulting zip code?

    I could not find a right exampe for this simple scenario.

    Can you point me to a right example or give some hints?

    Thanks.
    Last edited by xaled; 01-21-2013, 11:05 AM.

  • #2
    Hello,

    You can create a Grid application (as you already did), and set it to Start By Search on the main settings (it is the second option).

    Then go to Edit Fields (on your left tab) and select only the fields you want to display on your Grid.

    Now go to Search (on your left tab), go to Select Fields, and select the fields that the user is going to perform a search.

    regards,
    Bernhard Bernsmann

    Comment


    • #3
      Hi bartho,

      thank you for the quick reply.

      Ok, I got it. I have a grid with:
      - Start by Search set
      - only the "zip" field displayed in Grid (set in Edit Fields and in the Fields Positioning).
      - Search in the Grid with two fields x_field and y_field defined and shown (set in the Search Fields Positioning).

      How can I pass the inputed values from the search fields x_field and y_field in the Search to the SQL query (in red) defined in the Grid SQL?

      SELECT zip FROM "public".zip_areas WHERE ST_Contains(the_geom,ST_GeomFromWKB(ST_AsEWKB('POI NT({x_var} {y_var})'::geometry), 4326))

      I was thinking that the Fields Variables create the connection between the input field and the variable, but apparently it does not work.

      I'm getting the error as no input is passed.

      ERROR: parse error - invalid geometry LINE 1: ...ere ST_Contains(the_geom,ST_GeomFromWKB(ST_AsEWKB('POI NT( )'... ^ HINT: "POINT( )" <-- parse error at position 8 within geometry
      select count(*) from zip_areas where ST_Contains(the_geom,ST_GeomFromWKB(ST_AsEWKB('POI NT( )'::geometry), 4326))

      Thanks,
      xaled

      Comment


      • #4
        Ok,

        I got it. After some extensive forum search I found this message http://forum.scriptcase.net/archive/...hp/t-1283.html and realised, that Grid should select the whole range of the zip values: SELECT zip FROM "public".zip_areas

        The Search in Grid sets the required fields {x_field}, {y_field}

        and the Grid's onScriptInit event adds the required WHERE statement using the SC macro:

        sc_select_where(add) = "WHERE ST_Contains(the_geom,ST_GeomFromWKB(ST_AsEWKB('POI NT({x_field} {y_field})'::geometry), 4326))";

        Not sure if this is the best solution, but it works for me.

        Thanks,
        Denis

        Comment


        • #5
          I'm glad you were able to solve the issue.

          regards,
          Bernhard Bernsmann

          Comment

          Working...
          X