Solved

Script Case - SQL Query

Posted on 2011-09-27
2
2,585 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now