Solved

Script Case - SQL Query

Posted on 2011-09-27
2
2,702 Views
Last Modified: 2012-08-13
Hi,
I am using Scriptcase for a project.

I have table as attached
 DB Table
In a grid I have the query "onRecord"


// Check for record
$check_sql = "SELECT sum(recip_export), sum(recip_import), sum(recip_origin_export), sum(recip_mm)"
           . " FROM recip"
           . " WHERE recip_supplier = '" . {recip.recip_supplier} . "'";

sc_lookup(rs, $check_sql);

if (isset({rs[0][0]}))     // Row found
{
    {Exportation} = {rs[0][0]};
    {Import} = {rs[0][1]};
        {Exportation_Origin} = {rs[0][2]};
            {move_manament} = {rs[0][3]};
 
}
else     // No row found
{
    {other_field} = '';
    {other_region} = '';
}

Open in new window


The resulting grid is
Resulting Table
Notice the value 105 and 150 are repeated everywhere.

When I make SQL Query externally I get the result I wanted
SELECT recip.recip_supplier, sum(recip.recip_export), sum(recip.recip_import)
FROM recip GROUP BY recip.recip_supplier

Open in new window


Query Result
Where I am getting wrong. Could some one throw some light, please.

Thanks  
0
Comment
Question by:jayseena
2 Comments
 
LVL 8

Accepted Solution

by:
ropenner earned 500 total points
ID: 36715531
GROUP BY recip.recip_supplier

is missing from your code
0
 

Author Closing Comment

by:jayseena
ID: 36718454
I did that earlier and there was a clash between a group function within SC.
However I managed to avoid that and grouped it in the query, as you suggested
Thanks for your help.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question