Question

compilation problem

Asked by: AYEB

I have a proc*c program i add on a request a analytic function using over ( order by 1 ) .
When i compile i have this output .( sorry fo the english speakers )
proc sqlcheck=syntax userid=ter/ter MODE=ORACLE CODE=ANSI_C LINES=NO INCLUDE=/util/include INCLUDE=/glv_projets/ncgtp.qal/util/include INCLUDE=/usr/include/linux ./bfter_traitement_p1p3_.pc
Pro*C/C++: Release 9.2.0.4.0 - Production on Je Jul 31 15:08:00 2008
Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
Valeurs des options système par défaut extraites de : /moteurs/oracle/product/09.02.00.06/precomp/admin/pcscfg.cfg
PCC-I-02106, Nom utilisateur réservé ` SQLCHECK = FULL; nom utilisateur non pris en compte.
Erreur de syntaxe en ligne 2295, colonne 22, fichier ./bfter_traitement_p1p3_.pc:
Erreur à la ligne 2295, colonne 22 dans le fichier ./bfter_traitement_p1p3_.pc
           count(*) over (order by 1) nombre_p3_resultants
.....................1
PCC-S-02201, Symbole "over" rencontré à la place d'un des symboles suivants :
   ) * + - / | at, day, hour, minute, month, second, year,

my pcscfg.cfg is:
sys_include=(/usr/include,/usr/lib/gcc-lib/i386-redhat-linux/3.2.3/include,/usr/lib/gcc-lib/i486-suse-linux/2.95.3/include,/usr/lib/gcc-lib/i386-redhat-linux/2.96/include)
ltype=short


 

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2008-07-31 at 07:17:05ID23610957
Tags

pro*c

,

PCC-S-02201, Symbole "over" rencontré à la place d'un des symboles suivants :

Topics

Oracle 9.x

,

Oracle Database

Participating Experts
2
Points
125
Comments
23

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. /usr/include/sys
    I have inadvertently clobbered /usr/include/sys on my Linux 2.0.27 (Red Hat 4.0)/ AXP (DEC Alpha) system. Where can I find the files I need to restore it or what is the symbolic pointer I should enter to fix the problem?
  2. Speakers
    i have a Sony computer i have 3 speakers 2 on the side and one on the bottom of the monitor, sometimes only one speaker works the bottom one never works . how do i fix this problem? all of the wires are pluged in but the thing still wont work.
  3. Speakers !!
    All of a sudden my speakers stopped working. I checked using the Utility software dell had provided - and the test does finds the speakers and the subwoofer(altec lansing) in working condition - as I was able to hear the test tones and music during the test. But when I get ...
  4. Compile PHP 4.3.10 with-mssql=/usr error: Direct…
    Hi, I have a RH ES3.0 with Apache 2.0 and PHP-4.3.10. I had to recompile my own Apache and PHP-4.3.10 to at all of other functions that did not comes with the APACHE or PHP RPM from RH distribution. On this server I need to access both MySQL and MsSQL 2000 so I tried to ad...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: DrSQLPosted on 2008-07-31 at 07:29:34ID: 22130022

Can you show us the full SQL?  It may be pointing at the "over", but it might be confused by something else.

Good luck!

 

by: sdstuberPosted on 2008-07-31 at 07:31:01ID: 22130034

you'll need to use dynamic sql to execute statements with analytics in them.
It's a limitation of the pro*c syntax checking.

 

by: AYEBPosted on 2008-07-31 at 07:48:17ID: 22130199

Hi DrSQK: This is the request is:
SELECT   t3a.libelle_oremie, a.SEGMENT, a.num_p3, SUM (a.nb_uo),

         SUM (a.tarif * a.nb_uo),count(*) over ( order by 1) nombre_totale

    FROM ter_detail_p3_facture a, ter_ref_tr3a t3a

   WHERE a.date_jour >= TO_DATE ('01/06/2008', 'dd/mm/yyyy')

     AND a.date_jour <= TO_DATE ('30/06/2008', 'dd/mm/yyyy')

     AND a.code_tct IN (SELECT DISTINCT code_tct

                                   FROM ter_ref_tct

                                  WHERE client = 'TER Bourgogne')

     AND t3a.code_localite_tt0020 = a.tt0020

     AND t3a.region_ter = 'AU03'

     AND t3a.num_ordre = (SELECT MAX (num_ordre)

                            FROM ter_ref_tr3a

                           WHERE a.tt0020 = code_localite_tt0020)

GROUP BY t3a.libelle_oremie, a.num_p3, a.SEGMENT

 

 

by: DrSQLPosted on 2008-07-31 at 07:55:11ID: 22130281

You can't mix aggregates and groups.  I'd sugest you just use the record count returned after the query and take the nombre_totale out of the query.

Good luck!

 

by: sdstuberPosted on 2008-07-31 at 08:02:56ID: 22130362

or remove the analytic since it's not really being used for anything...

SELECT   t3a.libelle_oremie, a.SEGMENT, a.num_p3, SUM (a.nb_uo),
         SUM (a.tarif * a.nb_uo), COUNT (*) nombre_totale
    FROM ter_detail_p3_facture a, ter_ref_tr3a t3a
   WHERE a.date_jour >= TO_DATE ('01/06/2008', 'dd/mm/yyyy')
     AND a.date_jour <= TO_DATE ('30/06/2008', 'dd/mm/yyyy')
     AND a.code_tct IN (SELECT DISTINCT code_tct
                                   FROM ter_ref_tct
                                  WHERE client = 'TER Bourgogne')
     AND t3a.code_localite_tt0020 = a.tt0020
     AND t3a.region_ter = 'AU03'
     AND t3a.num_ordre = (SELECT MAX (num_ordre)
                            FROM ter_ref_tr3a
                           WHERE a.tt0020 = code_localite_tt0020)
GROUP BY t3a.libelle_oremie, a.num_p3, a.SEGMENT

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:

Select allOpen in new window

 

by: DrSQLPosted on 2008-07-31 at 08:05:27ID: 22130386

SD,
   It's getting the total records returned (but getting it on every row).  That's why I suggested using the row_count from the pro*c cursor.  Your change gets the count for that libelle_oremie, num_p3, and SEGMENT.

Good luck!

 

by: sdstuberPosted on 2008-07-31 at 08:11:23ID: 22130436

oh, yeah, oops

and just using row_count from the cursor should work, assuming the program pulls the cursor to completion.

 

by: AYEBPosted on 2008-07-31 at 08:23:20ID: 22130552

Yes i need the row count on evry ligne returned. How to do with a cursor ?

 

by: sdstuberPosted on 2008-07-31 at 08:27:48ID: 22130601

then you'll have to use dynamic sql to use the analytic

or, change the way you're processing the cursor, so you can get the rowcount at the end.

or, requery the table to get the count in a scalar subquery, but I don't recommend that as it's the least efficient.

 

by: DrSQLPosted on 2008-07-31 at 08:57:24ID: 22130919

Or use a wrapper:

select inner.*, count(*) nombre_totale
from 
(
SELECT   t3a.libelle_oremie, a.SEGMENT, a.num_p3, SUM (a.nb_uo) sum_nb_uo,
 
         SUM (a.tarif * a.nb_uo) sum_ab_no_tarif
 
    FROM ter_detail_p3_facture a, ter_ref_tr3a t3a
 
   WHERE a.date_jour >= TO_DATE ('01/06/2008', 'dd/mm/yyyy')
 
     AND a.date_jour <= TO_DATE ('30/06/2008', 'dd/mm/yyyy')
 
     AND a.code_tct IN (SELECT DISTINCT code_tct
 
                                   FROM ter_ref_tct
 
                                  WHERE client = 'TER Bourgogne')
 
     AND t3a.code_localite_tt0020 = a.tt0020
 
     AND t3a.region_ter = 'AU03'
 
     AND t3a.num_ordre = (SELECT MAX (num_ordre)
 
                            FROM ter_ref_tr3a
 
                           WHERE a.tt0020 = code_localite_tt0020)
 
GROUP BY t3a.libelle_oremie, a.num_p3, a.SEGMENT
) inner
group by libelle_oremie, SEGMENT, num_p3, sum_nb_uo, sum_ab_no_tarif
 
Good luck!
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:

Select allOpen in new window

 

by: DrSQLPosted on 2008-07-31 at 08:58:49ID: 22130932

I meant to use aggregate (if it's allowed):

select inner.*, count(*) over (order by 1) nombre_totale
from 
(
SELECT   t3a.libelle_oremie, a.SEGMENT, a.num_p3, SUM (a.nb_uo) sum_nb_uo,
 
         SUM (a.tarif * a.nb_uo) sum_ab_no_tarif
 
    FROM ter_detail_p3_facture a, ter_ref_tr3a t3a
 
   WHERE a.date_jour >= TO_DATE ('01/06/2008', 'dd/mm/yyyy')
 
     AND a.date_jour <= TO_DATE ('30/06/2008', 'dd/mm/yyyy')
 
     AND a.code_tct IN (SELECT DISTINCT code_tct
 
                                   FROM ter_ref_tct
 
                                  WHERE client = 'TER Bourgogne')
 
     AND t3a.code_localite_tt0020 = a.tt0020
 
     AND t3a.region_ter = 'AU03'
 
     AND t3a.num_ordre = (SELECT MAX (num_ordre)
 
                            FROM ter_ref_tr3a
 
                           WHERE a.tt0020 = code_localite_tt0020)
 
GROUP BY t3a.libelle_oremie, a.num_p3, a.SEGMENT
) inner
 
 
Good luck!

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:

Select allOpen in new window

 

by: sdstuberPosted on 2008-07-31 at 08:59:10ID: 22130937

won't that count(*) be 1 for every row?

 

by: sdstuberPosted on 2008-07-31 at 09:01:28ID: 22130964

ah ok, but I'd really be surprised if that worked, that seems like it's just moving the problem around.
plus, I don't think it will anyway.  the pro*c compiler doesn't like the "over" clause.

like I said at the beginning, it's a syntax limitation of the pre compiler itself.  You have to use dynamic sql to get analytics to work so the statement won't be parsed until runtime and then by the db server, not the proc pre compiler.

 

by: sdstuberPosted on 2008-07-31 at 09:02:15ID: 22130971

and small correction on wording


count(*) is the aggregate

count(*) over(....) is the analytic.

 

by: AYEBPosted on 2008-07-31 at 09:16:47ID: 22131085

DrSql,  Thanks , but your request does not work and it's not what i'm asking for, my problem is a compilation problem.

 

by: DrSQLPosted on 2008-07-31 at 09:23:46ID: 22131161

Then it's what sdstuber said, a limitation of the compiler to use the analytic syntax.  Including the data any other way (other than dynamic sql) is not going to perform very well:

select original.*, count_query.nombre_totale
from 
(
SELECT   t3a.libelle_oremie, a.SEGMENT, a.num_p3, SUM (a.nb_uo) sum_nb_uo,
 
         SUM (a.tarif * a.nb_uo) sum_ab_no_tarif
 
    FROM ter_detail_p3_facture a, ter_ref_tr3a t3a
 
   WHERE a.date_jour >= TO_DATE ('01/06/2008', 'dd/mm/yyyy')
 
     AND a.date_jour <= TO_DATE ('30/06/2008', 'dd/mm/yyyy')
 
     AND a.code_tct IN (SELECT DISTINCT code_tct
 
                                   FROM ter_ref_tct
 
                                  WHERE client = 'TER Bourgogne')
 
     AND t3a.code_localite_tt0020 = a.tt0020
 
     AND t3a.region_ter = 'AU03'
 
     AND t3a.num_ordre = (SELECT MAX (num_ordre)
 
                            FROM ter_ref_tr3a
 
                           WHERE a.tt0020 = code_localite_tt0020)
 
GROUP BY t3a.libelle_oremie, a.num_p3, a.SEGMENT
) original,
(
SELECT   count(*) nombre_totale
 
    FROM ter_detail_p3_facture a, ter_ref_tr3a t3a
 
   WHERE a.date_jour >= TO_DATE ('01/06/2008', 'dd/mm/yyyy')
 
     AND a.date_jour <= TO_DATE ('30/06/2008', 'dd/mm/yyyy')
 
     AND a.code_tct IN (SELECT DISTINCT code_tct
 
                                   FROM ter_ref_tct
 
                                  WHERE client = 'TER Bourgogne')
 
     AND t3a.code_localite_tt0020 = a.tt0020
 
     AND t3a.region_ter = 'AU03'
 
     AND t3a.num_ordre = (SELECT MAX (num_ordre)
 
                            FROM ter_ref_tr3a
 
                           WHERE a.tt0020 = code_localite_tt0020)
) count_query
 
Good luck!

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:

Select allOpen in new window

 

by: sdstuberPosted on 2008-07-31 at 09:26:51ID: 22131196

until 11g you won't be able to use analytics because the parser is old

See metalink doc  Note:283146.1

The workaround is to use dynamic sql for unsupported syntax (like analytics) so the parsing is not done at compile time.

 

by: sdstuberPosted on 2008-07-31 at 09:31:07ID: 22131237

I REALLY, REALLY wish the unified parser had been introduced earlier and was universal and it would be nice if really were "unified" too.

I've run into this limitation in pro*c and pl/sql too on lots of occasions in db versions 8 through 11.

Even in 11 the syntax isn't fully shared between sql and pl/sql.  But at least the pro*c compiler is more up-to-date.

 

by: AYEBPosted on 2008-07-31 at 09:38:14ID: 22131297

DrSQL,

This is the result of your request:
libelle_oremie      segment      num_p3      sum_nb_uo      sum_ab_no_tarif      nombre_totale
RIOM      A      1      0      0      3146
RIOM      A      2      0      0      3146
RIOM      A      3      0      0      3146
RIOM      A      4      0      0      3146
RIOM      A      5      0      0      3146
RIOM      A      6      0      0      3146
RIOM      A      7      0      0      3146
RIOM      A      8      4      23.92      3146
RIOM      A      9      0      0      3146
RIOM      A      10      0      0      3146
RIOM      A      11      0      0      3146
RIOM      A      12      0      0      3146
RIOM      A      13      0      0      3146
DOMPIERRE SEPT FONS      C      1      0      0      3146
DOMPIERRE SEPT FONS      C      2      0      0      3146
DOMPIERRE SEPT FONS      C      3      0      0      3146
DOMPIERRE SEPT FONS      C      4      0      0      3146
DOMPIERRE SEPT FONS      C      5      0      0      3146
DOMPIERRE SEPT FONS      C      6      0      0      3146
DOMPIERRE SEPT FONS      C      7      0      0      3146
DOMPIERRE SEPT FONS      C      8      234      1464.84      3146
DOMPIERRE SEPT FONS      C      9      0      0      3146
DOMPIERRE SEPT FONS      C      10      0      0      3146
DOMPIERRE SEPT FONS      C      11      0      0      3146
DOMPIERRE SEPT FONS      C      12      0      0      3146
DOMPIERRE SEPT FONS      C      13      0      0      3146
SAINT GERMAIN DES FOSSES      B      1      0      0      3146
SAINT GERMAIN DES FOSSES      B      2      0      0      3146
SAINT GERMAIN DES FOSSES      B      3      0      0      3146
SAINT GERMAIN DES FOSSES      B      4      0      0      3146
SAINT GERMAIN DES FOSSES      B      5      0      0      3146
SAINT GERMAIN DES FOSSES      B      6      0      0      3146
SAINT GERMAIN DES FOSSES      B      7      0      0      3146
SAINT GERMAIN DES FOSSES      B      8      4      24.04      3146
SAINT GERMAIN DES FOSSES      B      9      0      0      3146
SAINT GERMAIN DES FOSSES      B      10      0      0      3146
SAINT GERMAIN DES FOSSES      B      11      0      0      3146
SAINT GERMAIN DES FOSSES      B      12      0      0      3146
SAINT GERMAIN DES FOSSES      B      13      0      0      3146


And this is the result of mine:
libelle_oremie      segment      num_p3      sum(a.nb_uo)      sum(a.tarif*a.nb_uo)      nombre_totale
RIOM      A      1      0      0      39
RIOM      A      2      0      0      39
RIOM      A      3      0      0      39
RIOM      A      4      0      0      39
RIOM      A      5      0      0      39
RIOM      A      6      0      0      39
RIOM      A      7      0      0      39
RIOM      A      8      4      23.92      39
RIOM      A      9      0      0      39
RIOM      A      10      0      0      39
RIOM      A      11      0      0      39
RIOM      A      12      0      0      39
RIOM      A      13      0      0      39
DOMPIERRE SEPT FONS      C      1      0      0      39
DOMPIERRE SEPT FONS      C      2      0      0      39
DOMPIERRE SEPT FONS      C      3      0      0      39
DOMPIERRE SEPT FONS      C      4      0      0      39
DOMPIERRE SEPT FONS      C      5      0      0      39
DOMPIERRE SEPT FONS      C      6      0      0      39
DOMPIERRE SEPT FONS      C      7      0      0      39
DOMPIERRE SEPT FONS      C      8      234      1464.84      39
DOMPIERRE SEPT FONS      C      9      0      0      39
DOMPIERRE SEPT FONS      C      10      0      0      39
DOMPIERRE SEPT FONS      C      11      0      0      39
DOMPIERRE SEPT FONS      C      12      0      0      39
DOMPIERRE SEPT FONS      C      13      0      0      39
SAINT GERMAIN DES FOSSES      B      1      0      0      39
SAINT GERMAIN DES FOSSES      B      2      0      0      39
SAINT GERMAIN DES FOSSES      B      3      0      0      39
SAINT GERMAIN DES FOSSES      B      4      0      0      39
SAINT GERMAIN DES FOSSES      B      5      0      0      39
SAINT GERMAIN DES FOSSES      B      6      0      0      39
SAINT GERMAIN DES FOSSES      B      7      0      0      39
SAINT GERMAIN DES FOSSES      B      8      4      24.04      39
SAINT GERMAIN DES FOSSES      B      9      0      0      39
SAINT GERMAIN DES FOSSES      B      10      0      0      39
SAINT GERMAIN DES FOSSES      B      11      0      0      39
SAINT GERMAIN DES FOSSES      B      12      0      0      39
SAINT GERMAIN DES FOSSES      B      13      0      0      39

 

by: DrSQLPosted on 2008-07-31 at 09:44:20ID: 22131348

Sorry, didn't realize there was that much repetition.  This should fix it:

(note that I just concatenated the "grouped" columns, you might want to lpad/rpad or to_char them to get more consistent results, but I didn't know their data types, typical values, or lengths)

select original.*, count_query.nombre_totale
from 
(
SELECT   t3a.libelle_oremie, a.SEGMENT, a.num_p3, SUM (a.nb_uo) sum_nb_uo,
 
         SUM (a.tarif * a.nb_uo) sum_ab_no_tarif
 
    FROM ter_detail_p3_facture a, ter_ref_tr3a t3a
 
   WHERE a.date_jour >= TO_DATE ('01/06/2008', 'dd/mm/yyyy')
 
     AND a.date_jour <= TO_DATE ('30/06/2008', 'dd/mm/yyyy')
 
     AND a.code_tct IN (SELECT DISTINCT code_tct
 
                                   FROM ter_ref_tct
 
                                  WHERE client = 'TER Bourgogne')
 
     AND t3a.code_localite_tt0020 = a.tt0020
 
     AND t3a.region_ter = 'AU03'
 
     AND t3a.num_ordre = (SELECT MAX (num_ordre)
 
                            FROM ter_ref_tr3a
 
                           WHERE a.tt0020 = code_localite_tt0020)
 
GROUP BY t3a.libelle_oremie, a.num_p3, a.SEGMENT
) original,
(
SELECT   count(distinct t3a.libelle_oremie || a.SEGMENT|| a.num_p3) nombre_totale
 
    FROM ter_detail_p3_facture a, ter_ref_tr3a t3a
 
   WHERE a.date_jour >= TO_DATE ('01/06/2008', 'dd/mm/yyyy')
 
     AND a.date_jour <= TO_DATE ('30/06/2008', 'dd/mm/yyyy')
 
     AND a.code_tct IN (SELECT DISTINCT code_tct
 
                                   FROM ter_ref_tct
 
                                  WHERE client = 'TER Bourgogne')
 
     AND t3a.code_localite_tt0020 = a.tt0020
 
     AND t3a.region_ter = 'AU03'
 
     AND t3a.num_ordre = (SELECT MAX (num_ordre)
 
                            FROM ter_ref_tr3a
 
                           WHERE a.tt0020 = code_localite_tt0020)
) count_query
 
Good luck!
 

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:

Select allOpen in new window

 

by: sdstuberPosted on 2008-07-31 at 09:56:39ID: 22131474

yikes!!!!

wouldn't dynamic sql be easier than all that?  Not to mention more efficient?

 

by: sdstuberPosted on 2008-07-31 at 10:02:53ID: 22131519

your current code probably looks something like


EXEC SQL DECLARE your_cursor  CURSOR FOR
     select ......;

EXEC SQL OPEN your_cursor;

then fetch, process and close.


instead, change it to...

strcpy(sql_string,"select....");  

EXEC SQL PREPARE sql_statement FROM :sql_string;

EXEC SQL DECLARE your_cursor  CURSOR FOR sql_statement;

EXEC SQL OPEN your_cursor;

then fetch, process and close.

basically you just add 1 line, the "prepare" and move the sql text into a c string instead of embedding it in the declare.




 

by: sdstuberPosted on 2008-08-04 at 06:19:32ID: 22152130

Why only a B?  I would have helped more if you needed it?

Please don't accept an answer early and then give a penalty grade without giving the volunteers (not just me) a chance to complete the answer.

Since you did award a penalty, can you please tell me what else I could have done to help more?

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...