Question

How do u do a SELECT at runtime & output the data according to the date range specified?

Asked by: priti_81

Say you have four tables in the db like the following (those are the table name and the columns)

Sales Table-     Product_ID, Area_ID, Date, Amount
Product Table-   Product_ID, P_Name
Area Table-      Area_ID, A_Name
Time Table-      Date, Month_ID, Quater

There are 3 item types in the oracle 6i form I created.
1.I have all the above mentioned column names in  check boxes,
2.I have a place to input the time period e.g.: _____________ to ____________
3.and a button called Execute

At runtime the user ticks the check boxes (column names) that he wants to merge, inputs the time period
(e.g.: 01-JAN-2003 to 21-FEB-2003) and then he clicks on the Execute button.

What I would like is the code for the above. The code that will take the user inputs at runtime (both column names and the time period) execute the query and outputs the result on another window.

Please please help
urgent
Priti

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
2003-03-05 at 07:11:18ID20539391
Tags

oracle

Topic

Oracle 3rd Party Tools

Participating Experts
6
Points
0
Comments
27

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. D2K runtime Installation.
    Hi, I am trying to load a developer 2000 runtime by copying the DLL and EXE. After copying all the files I had tried to run a FMX. But it is giving problem to run. I don't want to run a setup. I want to distribute a supporting files to the user. I want to make my own setup....
  2. runtime
    I am a tester the application keeps producing runtime errors. Each error has a number is there a catalogue defining the meaning of these runtime errors for reporting purposes it would seem better to say ' runtime caused due to..... rather that just stating the run time number'
  3. Oracle Runtime library.
    Hello how are you today? I need some information on Oracle Runtime library. What it is? What it is used for? Can you please point me to written articles, white papers ect. - Thank you -
  4. Oracle Runtime Error
    Hi Experts, I am completly new to Oracle so please forgive me if i am not giving you sufficient information relating to the issue i am having. In order for an analyst in Oracle to link onto my PC (OWC session) I need to run a certain program through the Metalink Oracle web ...

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: lmedfoPosted on 2003-03-05 at 07:21:02ID: 8072369

This looks like homework for a class.  Is it?
LM

 

by: priti_81Posted on 2003-03-05 at 07:47:03ID: 8072583

can u pls help?

 

by: lmedfoPosted on 2003-03-05 at 09:51:55ID: 8073494

We don't do your homework for you.  That's called cheating.  At least attemp to do parts of it.  If you get stuck on something we can give you examples of how to do it.  But don't ask someone else to do your homework for you.

 

by: AvotarPosted on 2003-03-05 at 22:14:38ID: 8077813

especially this... cuz this is really easy...

 

by: priti_81Posted on 2003-03-06 at 02:41:55ID: 8078887

This is what I tried..
here you check if the checkbox is checked in the form. If it is checked, the column name is passed to the SQLSTR’s select statement in the EXEC_SQL. If not checked its ignored.
__________________________________________________________________
IF Checkbox_Checked(Sales.Product_ID) THEN           pass Sales.Product_ID to SQLSTR’s select statement   ELSE      ignore  END IF;  
IF Checkbox_Checked(Sales.Area_ID) THEN        pass Sales.Area_ID to SQLSTR’s select statement  
ELSE
      ignore
END IF;  .
.
.
IF Checkbox_Checked(Time.Quater) THEN        pass Time.Quater to  SQLSTR’s select statement   ELSE           ignore
END IF;  END;  __________________________________________________________________


DECLARE
CONNECTION_ID      EXEC_SQL.CONNTYPE;
CURSOR_NAME      EXEC_SQL.CURSTYPE;
SQLSTR          VARCHAR2(2000);



BEGIN
CONNECTION_ID:= exec_sql.open_connection('samual/lakecity@viva8');
CURSOR_NAME := exec_sql.open_cursor(CONNECTION_ID);


SQLSTR :=( SELECT    Sales.Product_ID, Sales.Area_ID, Sales.Date, Sales.Amount,
                Product.Product_ID, Product.P_Name,
                Area.Area_ID, Area.A_Name,
                Time.Date, Time.Month_ID, Time.Quater

FROM                      Sales, Product, Area, Time

WHERE                    ‘Sales.Product_ID= Product.Product_ID’||
‘AND                           Sales.Area_ID = Area.Area_ID          ’||
‘AND                          Sales.Date = Time.Date               ’||
‘AND                          DATE BETWEEN  :D1 AND :D2';


exec_SQL.parse(CONNECTION_ID,CURSOR_NAME,SQLSTR,exec_sql.v8);
rows_processed := exec_sql.execute( CONNECTION_ID,CURSOR_NAME);
     
exec_sql.close_cursor(CONNECTION_ID,CURSOR_NAME);
exec_sql.close_connection(CONNECTION_ID);

END;

__________________________________________________________________

I don’t know how to write the code to pass the chosen columns names from the checkbox checked statements to the SQLSTR in the EXEC_SQL and
EXEC_SQL’s  SQLSTR to accept the parameters I’m sending using the checkbox checked statements. As you can see I am really lost. I have been trying for the last whole week but am not getting anywhere. Due the shear desperation I came here hoping for some help. Pls help me with the code.
Priti

 

by: priti_81Posted on 2003-03-06 at 23:39:03ID: 8086544

I created one oracle 6i form, data block called  “SALES_FACT”  with columns from 4 tables. All these columns were taken to the form in the form of checkboxes. (The form also has a button).  When a checkbox is clicked it has the value “Y”
I added the below coding in a WHEN-BUTTON-PRESSED trigger and it compiled without any errors.
My question is how do I write the EXEC_SQL’s  SQLSTR..? Can I write it like the one I have shown? Please help?  

DECLARE
      v_select VARCHAR2(32000) := 'SELECT';
     
      DATE_ID VARCHAR2(80) := 'SALES_FACT.DATE_ID';
     MONTHI VARCHAR2(80) := 'SALES_FACT.MONTHI';
     QUATER VARCHAR2(80) := 'SALES_FACT.QUATER';
     PRODUCT_ID VARCHAR2(80) := 'SALES_FACT.PRODUCT_ID';
     P_NAME VARCHAR2(80) := 'SALES_FACT.P_NAME';
     AREA_ID VARCHAR2(80) := 'SALES_FACT.AREA_ID';
     A_CATEGORY VARCHAR2(80) := 'SALES_FACT.A_CATEGORY';
     QTY VARCHAR2(80) := 'SALES_FACT.QTY';
     
BEGIN
IF Checkbox_Checked(DATE_ID) THEN            /* DATE CHECKBOXES*/
           v_select := v_select || ' SALES_FACT.DATE_ID,';
END IF;

IF Checkbox_Checked(MONTHI) THEN
           v_select := v_select || ' TIME_DIMEN.MONTH,';
END IF;

IF Checkbox_Checked(QUATER) THEN
           v_select := v_select || ' TIME_DIMEN.QUATER,';
END IF;

IF Checkbox_Checked(PRODUCT_ID) THEN      /* PRODUCT CHECKBOXES*/
           v_select := v_select || 'SALES_FACT.PRODUCT_ID,';
END IF;

IF Checkbox_Checked(P_NAME) THEN
           v_select := v_select || ' PRODUCT_DIMEN.P_NAME,';
END IF;

IF Checkbox_Checked(AREA_ID) THEN                   /* AREA CHECKBOXES*/
           v_select := v_select || ' SALES_FACT.AREA_ID,';
END IF;

IF Checkbox_Checked(A_CATEGORY) THEN
           v_select := v_select || ' AREA_DIMEN.A_CATEGORY,';
END IF;

IF Checkbox_Checked(QTY) THEN           /* QTY CHECKBOXES*/
      v_select := v_select || ' SALES_FACT.QTY,';
END IF;


v_select := RTRIM( v_select, ',' );      

How do you do this part ?


DECLARE
CONNECTION_ID      EXEC_SQL.CONNTYPE;
CURSOR_NAME      EXEC_SQL.CURSTYPE;
SQLSTR          VARCHAR2(2000);

BEGIN
CONNECTION_ID:= exec_sql.open_connection('samual/lakecity@viva8');
CURSOR_NAME := exec_sql.open_cursor(CONNECTION_ID);


SQLSTR :=( SELECT    

FROM                      Sales, Product, Area, Time

WHERE                    ‘Sales.Product_ID= Product.Product_ID’||
‘AND                           Sales.Area_ID = Area.Area_ID          ’||
‘AND                          Sales.Date = Time.Date               ’||
‘AND                          DATE BETWEEN  :D1 AND :D2';


exec_SQL.parse(CONNECTION_ID,CURSOR_NAME,SQLSTR,exec_sql.v8);
rows_processed := exec_sql.execute( CONNECTION_ID,CURSOR_NAME);
exec_sql.close_cursor(CONNECTION_ID,CURSOR_NAME);
exec_sql.close_connection(CONNECTION_ID);

END;



 

by: lmedfoPosted on 2003-03-07 at 07:01:43ID: 8088683

Basically,
just pass the v_select to the sqlstr.  You want the SQLSTR to have the correct select statement.  That would be the one you built in the first part.

 

by: lmedfoPosted on 2003-03-07 at 07:35:54ID: 8088947

ie:
SQLSTR :=( SELECT    :v_select

FROM                      Sales, Product, Area, Time

WHERE                    Sales.Product_ID= Product.Product_ID||
AND                           Sales.Area_ID = Area.Area_ID          ||
AND                          Sales.Date = Time.Date               ||
AND                          DATE BETWEEN  :D1 AND :D2';



I can see where some of the code might cause some errors to occur. But that you'll learn to overcome as you get more practice.

 

by: priti_81Posted on 2003-03-07 at 22:45:34ID: 8093023

Can someone please tell me where the code is wrong. This code is placed in a WHEN-BUTTON-PRESSED trigger.
What I want is for a user inputs at runtime (both column names and the time period) then when the user presses the button to execute the query and outputs the result on another window. Please help me.

_________________________________________________________
DECLARE
      v_select VARCHAR2(32000) := 'SELECT';
     
      DATE_ID VARCHAR2(80) := 'SALES_FACT.DATE_ID';
     MONTHI VARCHAR2(80) := 'SALES_FACT.MONTHI';
     QUATER VARCHAR2(80) := 'SALES_FACT.QUATER';
     PRODUCT_ID VARCHAR2(80) := 'SALES_FACT.PRODUCT_ID';
     P_NAME VARCHAR2(80) := 'SALES_FACT.P_NAME';
     AREA_ID VARCHAR2(80) := 'SALES_FACT.AREA_ID';
     A_CATEGORY VARCHAR2(80) := 'SALES_FACT.A_CATEGORY';
     QTY VARCHAR2(80) := 'SALES_FACT.QTY';
     
  connected  boolean;
  errcode          number     :=error_code;
  cursor_name exec_sql.curstype;
  rows_processed pls_integer;
  connection_id exec_sql.conntype;

BEGIN
IF Checkbox_Checked(DATE_ID) THEN           /* DATE CHECKBOXES*/
          v_select := v_select || ' SALES_FACT.DATE_ID,';
     END IF;
     
     IF Checkbox_Checked(MONTHI) THEN
           v_select := v_select || ' TIME_DIMEN.MONTH,';
     END IF;
     
     IF Checkbox_Checked(QUATER) THEN
           v_select := v_select || ' TIME_DIMEN.QUATER,';
     END IF;
     
     IF Checkbox_Checked(PRODUCT_ID) THEN           /* PRODUCT CHECKBOXES*/
           v_select := v_select || 'SALES_FACT.PRODUCT_ID,';
     END IF;
         
     IF Checkbox_Checked(P_NAME) THEN
           v_select := v_select || ' PRODUCT_DIMEN.P_NAME,';
     END IF;
         
     IF Checkbox_Checked(AREA_ID) THEN           /* AREA CHECKBOXES*/
           v_select := v_select || ' SALES_FACT.AREA_ID,';
     END IF;
         
     IF Checkbox_Checked(A_CATEGORY) THEN
           v_select := v_select || ' AREA_DIMEN.A_CATEGORY,';
     END IF;
         
                   
     IF Checkbox_Checked(QTY) THEN           /* QTY CHECKBOXES*/
           v_select := v_select || ' SALES_FACT.QTY,';
     END IF;
         
     IF Checkbox_Checked(NPS) THEN
           v_select := v_select || ' SALES_FACT.NPS,';
     END IF;

     v_select := RTRIM( v_select, ',' );     /* TO REMOVE THE , IN THE LAST SELECT STATEMENT */




connection_id := exec_sql.open_connection('samual/lakecity@viva8');
connected := exec_sql.is_connected(connection_id);
if connected = TRUE then
    message ('Connected  ');
   
else
    message ('NOT connnected');
end if;


cursor_name := EXEC_sql.open_cursor(connection_id);
     
  SQLSTR :=( SELECT         :v_select
                       FROM     Sales, Product, Area, Timei
           WHERE     'Sales.Product_ID= Product.Product_ID'||
           'AND      Sales.Area_ID = Area.Area_ID '||
           'AND          Sales.Date = Time.Date   '||
           'AND          DATE BETWEEN  :D1 AND :D2';

         
exec_SQL.parse(connection_id,cursor_name,SQLSTR,exec_sql.v7);
rows_processed := exec_sql.execute( connection_id,cursor_name);
exec_sql.close_cursor(connection_id,cursor_name);
exec_sql.close_connection(connection_id);


end;

 

by: priti_81Posted on 2003-03-08 at 06:45:25ID: 8093858

can any one help me?

 

by: lmedfoPosted on 2003-03-08 at 09:08:58ID: 8094301

prito_81
ok. I feel bad for you.  I think you are using a roundabout logic for your program.
Here is an example program from Oracle.  This program will not be the complete solution to your program.  But it does show you the basics.  Re-write your program and then report back.  The steps you are trying to do is good just using the wrong functions.
This is a bulletin from Metalink:

          PASSING RECORD GROUPS TO ORACLE REPORTS & GRAPHICS


Introduction
============
This bulletin explains the processes involved in creating a record
group in Oracle Forms and then passing it to Oracle Reports and Oracle
Graphics.  This bulletin is divided into three main parts.  The first
part describes the creation of a record group and passing it to Oracle
Reports and Oracle Graphics.  The second part describes how to create
a report that will run with the data based on a record group.  The
third part describes how to create a graph that will run with the data
based on a record group.

For the following sections, the emp table must be available in the current
login of Oracle Forms, Reports, and Graphics.  The emp table is a part of the
standard demo tables.  However, if you do not have access to the emp
table, you can create and populate the emp table as follows:

Name                              Type
-------------------------------    ----
EMPNO                             NUMBER(4)
ENAME                             VARCHAR2(10)
JOB                               VARCHAR2(9)
MGR                               NUMBER(4)
HIREDATE                          DATE
SAL                               NUMBER(7,2)
COMM                              NUMBER(7,2)
DEPTNO                            NUMBER(2)

EMPNO ENAME  JOB       MGR   HIREDATE        SAL      COMM DEPTNO
----- ------ --------- ----- --------- --------- --------- ---------
7839  KING   PRESIDENT       17-NOV-81      5000                  10
7698  BLAKE  MANAGER   7839  01-MAY-81      2850                  30
7782  CLARK  MANAGER   7839  09-JUN-81      2450                  10
7566  JONES  MANAGER   7839  02-APR-81      2975                  20
7654  MARTIN SALESMAN  7698  28-SEP-81      1250      1400        30
7499  ALLEN  SALESMAN  7698  20-FEB-81      1600       300        30
7844  TURNER SALESMAN  7698  08-SEP-81      1500         0        30
7900  JAMES  CLERK     7698  03-DEC-81       950                  30
7521  WARD   SALESMAN  7698  22-FEB-81      1250       500        30
7902  FORD   ANALYST   7566  03-DEC-81      3000                  20
7369  SMITH  CLERK     7902  17-DEC-80       800                  20
7788  SCOTT  ANALYST   7566  09-DEC-82      3000                  20
7876  ADAMS  CLERK     7788  12-JAN-83      1100                  20
7934  MILLER CLERK     7782  23-JAN-82      1300                  10


Oracle Forms
============
The following code will create a record group and call Oracle Reports and/or
Oracle Graphics.  You can implement this code in any trigger.  In this example,
the SELECT statement is built as a fixed string.  You may change the
SELECT statement by changing the WHERE or ORDER BY clause, but the number of
columns, data types, and column names must remain the same.

DECLARE
  groupname VARCHAR2(30)     := 'RG1';
  paramlistname VARCHAR2(30) := 'PLIST1';
  qname VARCHAR2(30)         := 'Q_EMP';
  qry VARCHAR2(2000)         := 'SELECT ename, sal, comm' ||
                                'FROM emp' ||
                                'WHERE sal < 2000';
  rgid                       RECORDGROUP;
  plid                       PARAMLIST;
  n                          NUMBER;

BEGIN
  /*
     Make sure the group does not already exists.
  */
  rgid := FIND_GROUP(groupname);

  /*
     If the group exists, then delete it.
  */
  IF NOT ID_NULL(rgid) THEN
     DELETE_GROUP(rgid);
  END IF;

  /*
     Create the group.
  */
  rgid  := CREATE_GROUP_FROM_QUERY(groupname, qry);

  /*
     Make sure the record group is empty.
  */
  DELETE_GROUP_ROW(rgid, ALL_ROWS);

  /*
     Retrieve the data.
  */
  n := POPULATE_GROUP_WITH_QUERY(rgid, qry);

  /*
     Make sure the list does not already exist.
  */
  plid := GET_PARAMETER_LIST(paramlistname);

  /*
     If the list exists, then delete it.
  */
  IF NOT ID_NULL(plid) THEN
     DESTROY_PARAMETER_LIST(paramlistname);
  END IF;

  plid := CREATE_PARAMETER_LIST(paramlistname);
  ADD_PARAMETER(plid, qname, DATA_PARAMETER, groupname);

  /*
     Suppress the parameter form.
  */
  ADD_PARAMETER(plid, 'paramform', TEXT_PARAMETER, 'NO');

  /*
     The following command will call Oracle Reports in SYNCHRONOUS mode.
     To call Oracle Graphics, replace the REPORTS with GRAPHICS.
  */
  RUN_PRODUCT(REPORTS, 'RG', SYNCHRONOUS, RUNTIME, FILESYSTEM, plid, NULL);

  DESTROY_PARAMETER_LIST(plid);
  DELETE_GROUP(rgid);
END;

Note:
1.  DATA_PARAMETER can only be passed in SYNCHRONOUS mode.  For further
   information, see the RUN_PRODUCT description in the Forms reference manual.

2.  If you are experiencing an error like FRM-40105, FRM-41072, FRM-41076, or
   FRM-41077, check how the SELECT statement was built.


Oracle Reports
==============
As mentioned in the previous section, the name, data type, and number of
columns in the report must be the same as the record group in the form.  After
building the following report, you will be able to run it successfully from
the Designer.  When you use RUN_PRODUCT to run this report, this creates the
report based on the data queried by the record group.

Use the following steps to create the report:

1. Create a Query with the following properties:
     Name             : Q_EMP
     SELECT Statement : SELECT ename, sal, comm FROM emp

2. Create a Tabular Default Layout.

3. Generate and Save the Report as RG.


Oracle Graphics
===============
The same will apply for Oracle Graphics as mentioned in the Oracle Reports
section above.  Use the following steps to create the chart:

1. Create a Query with the following properties:
     Name             : Q_EMP
     SELECT Statement : SELECT ename, sal, comm FROM emp

2. Create a Chart based on the Q_EMP query.

3. Generate and Save the Display as RG.

 

by: priti_81Posted on 2003-03-08 at 09:38:15ID: 8094396

Thank you lmedfo thank you so much shall do and get back.
Thanks!! :)
Pri

 

by: priti_81Posted on 2003-03-09 at 02:40:43ID: 8097262

I coded the following and compiled no errors. But when I run there is an error saying : argument 2 to builtin CREATE_GROUP_FROM_QUERY cannot be null. In the example under ORACLE  REPORT it say that the name, data type, and number of columns in the report must be the same as the record group in the form.  I dont know how I can do this? How to create a record group. Please help

I modified  qry VARCHAR2(2000)         := 'SELECT ename, sal, comm' ||
                               'FROM emp' || to  qry VARCHAR2(2000)         := SQLSTR  I hope that can be done..?
 
_____________________________________
DECLARE
             v_select VARCHAR2(32000) := 'SELECT';
             
             DATE_ID VARCHAR2(80) := 'SALES_FACT.DATE_ID';
            MONTHI VARCHAR2(80) := 'SALES_FACT.MONTHI';
            QUATER VARCHAR2(80) := 'SALES_FACT.QUATER';
            PRODUCT_ID VARCHAR2(80) := 'SALES_FACT.PRODUCT_ID';
            P_NAME VARCHAR2(80) := 'SALES_FACT.P_NAME';
            AREA_ID VARCHAR2(80) := 'SALES_FACT.AREA_ID';
            A_CATEGORY VARCHAR2(80) := 'SALES_FACT.A_CATEGORY';
            QTY VARCHAR2(80) := 'SALES_FACT.QTY';

       SQLSTR            VARCHAR2(2000);
       groupname VARCHAR2(30)     := 'RG1';
       paramlistname VARCHAR2(30) := 'PLIST1';
       qname VARCHAR2(30)         := 'Q_EMP';
       qry VARCHAR2(2000)         := SQLSTR ; --(THIS IS THE QUERRY THAT WAS CREATED USING THE  CHECKBOXES.
                                                                                                       -- ACCORDING TO THE EXAMPLE THE qry SHOULD MATCH THE rgid RECORDGROUP.                                                                                    -- BUT I DONT KNOW HOW TO DO THAT)
       rgid                       RECORDGROUP;
       plid                       PARAMLIST;
       n                          NUMBER;
 
 
            
BEGIN

--(TRYING TO GET THE USER INPUTS (CLOMN NAMES) AT RUNTIME TO PASS ON TO THE SELECT STATMENT)----------------------------------------
                      IF Checkbox_Checked(DATE_ID) THEN                                                                   /* DATE CHECKBOXES*/
                         v_select := v_select || ' SALES_FACT.DATE_ID,';
            END IF;
      
            IF Checkbox_Checked(MONTHI) THEN
                   v_select := v_select || ' TIME_DIMEN.MONTH,';
            END IF;
      
            IF Checkbox_Checked(QUATER) THEN
                   v_select := v_select || ' TIME_DIMEN.QUATER,';
            END IF;
            
            IF Checkbox_Checked(PRODUCT_ID) THEN                                                                   /* PRODUCT CHECKBOXES*/
                   v_select := v_select || 'SALES_FACT.PRODUCT_ID,';
            END IF;
            
            IF Checkbox_Checked(P_NAME) THEN
                   v_select := v_select || ' PRODUCT_DIMEN.P_NAME,';
            END IF;
            
            IF Checkbox_Checked(AREA_ID) THEN                                                                               /* AREA CHECKBOXES*/
                   v_select := v_select || ' SALES_FACT.AREA_ID,';
            END IF;
            
            IF Checkbox_Checked(A_CATEGORY) THEN
                   v_select := v_select || ' AREA_DIMEN.A_CATEGORY,';
            END IF;
                  
            IF Checkbox_Checked(QTY) THEN                                                                   /* QTY CHECKBOXES*/
                   v_select := v_select || ' SALES_FACT.QTY,';
            END IF;
            
                  v_select := RTRIM( v_select, ',' );                                          /* THIS IS TO REMOVE THE COMMA IN THE LAST SELECT STATEMENT */



--(TRYING TO CREATE A GROUP,PASS THE SELECT STATEMENT AND THEN GET THE OUTPUT IN ANOTHER WINDOW/REPORT/GRAPHICS)----------------------------------------
 
  SQLSTR :=( 'SELECT'   ||v_select||
                                     'FROM                  Sales, Product, Area, Timei'||
                                     'WHERE          Sales.Product_ID= Product.Product_ID'||
                                     'AND               Sales.Area_ID = Area.Area_ID'||
                                     'AND                Sales.Date = Time.Date'||
                                     'AND                DATE BETWEEN  :D1 AND :D2');
                                                      
 --  Make sure the group does not already exists.
 rgid := FIND_GROUP(groupname);

 --   If the group exists, then delete it.
 IF NOT ID_NULL(rgid) THEN
    DELETE_GROUP(rgid);
 END IF;

  --  Create the group.
 rgid  := CREATE_GROUP_FROM_QUERY(groupname, qry);

  --  Make sure the record group is empty.
 DELETE_GROUP_ROW(rgid, ALL_ROWS);

 --   Retrieve the data.
 n := POPULATE_GROUP_WITH_QUERY(rgid, qry);

 --   Make sure the list does not already exist.
 plid := GET_PARAMETER_LIST(paramlistname);

 --   If the list exists, then delete it.
 IF NOT ID_NULL(plid) THEN
    DESTROY_PARAMETER_LIST(paramlistname);
 END IF;

 plid := CREATE_PARAMETER_LIST(paramlistname);
 ADD_PARAMETER(plid, qname, DATA_PARAMETER, groupname);

 --   Suppress the parameter form.
 ADD_PARAMETER(plid, 'paramform', TEXT_PARAMETER, 'NO');

--    The following command will call Oracle Reports in SYNCHRONOUS mode.
--    To call Oracle Graphics, replace the REPORTS with GRAPHICS.

 RUN_PRODUCT(REPORTS, 'RG', SYNCHRONOUS, RUNTIME, FILESYSTEM, plid, NULL);

 DESTROY_PARAMETER_LIST(plid);
 DELETE_GROUP(rgid);

end;

 

by: lmedfoPosted on 2003-03-09 at 10:45:12ID: 8098383

sqlqry needs to be assigned to the qry variable after it is built.
you have qry assigning it prior to the query being built.

 

by: priti_81Posted on 2003-03-09 at 18:27:19ID: 8100174

i did the change but still the same error.. "argument 2 to builtin CREATE_GROUP_FROM_QUERY cannot be null".
i'm really stuck can someone pls. help me..
___________________________________________________________
DECLARE
             v_select VARCHAR2(32000) := 'SELECT';
             
             DATE_ID VARCHAR2(80) := 'SALES_FACT.DATE_ID';
            MONTHI VARCHAR2(80) := 'SALES_FACT.MONTHI';
            QUATER VARCHAR2(80) := 'SALES_FACT.QUATER';
            PRODUCT_ID VARCHAR2(80) := 'SALES_FACT.PRODUCT_ID';
            P_NAME VARCHAR2(80) := 'SALES_FACT.P_NAME';
            AREA_ID VARCHAR2(80) := 'SALES_FACT.AREA_ID';
            A_CATEGORY VARCHAR2(80) := 'SALES_FACT.A_CATEGORY';
            QTY VARCHAR2(80) := 'SALES_FACT.QTY';

       SQLSTR            VARCHAR2(2000);
       groupname VARCHAR2(30)     := 'RG1';
       paramlistname VARCHAR2(30) := 'PLIST1';
       qname VARCHAR2(30)         := 'Q_EMP';
       qry VARCHAR2(2000);
       rgid                       RECORDGROUP;
       plid                       PARAMLIST;
       n                          NUMBER;
 
 
             

BEGIN

--(TRYING TO GET THE USER INPUTS (CLOMN NAMES) AT RUNTIME TO PASS ON TO THE SELECT STATMENT)----------------------------------------
        IF Checkbox_Checked(DATE_ID) THEN                                                                   /* DATE CHECKBOXES*/
                         v_select := v_select || ' SALES_FACT.DATE_ID,';
            END IF;
      
            IF Checkbox_Checked(MONTHI) THEN
                   v_select := v_select || ' TIME_DIMEN.MONTH,';
            END IF;
      
            IF Checkbox_Checked(QUATER) THEN
                   v_select := v_select || ' TIME_DIMEN.QUATER,';
            END IF;
            
            IF Checkbox_Checked(PRODUCT_ID) THEN                                                                   /* PRODUCT CHECKBOXES*/
                   v_select := v_select || 'SALES_FACT.PRODUCT_ID,';
            END IF;
            
            IF Checkbox_Checked(P_NAME) THEN
                   v_select := v_select || ' PRODUCT_DIMEN.P_NAME,';
            END IF;
            
            IF Checkbox_Checked(AREA_ID) THEN                                                                               /* AREA CHECKBOXES*/
                   v_select := v_select || ' SALES_FACT.AREA_ID,';
            END IF;
            
            IF Checkbox_Checked(A_CATEGORY) THEN
                   v_select := v_select || ' AREA_DIMEN.A_CATEGORY,';
            END IF;
                  
            IF Checkbox_Checked(QTY) THEN                                                                   /* QTY CHECKBOXES*/
                   v_select := v_select || ' SALES_FACT.QTY,';
            END IF;
            
                  v_select := RTRIM( v_select, ',' );                                          /* THIS IS TO REMOVE THE COMMA IN THE LAST SELECT STATEMENT */



--(TRYING TO CREATE A GROUP,PASS THE SELECT STATEMENT AND THEN GET THE OUTPUT IN ANOTHER WINDOW/REPORT/GRAPHICS)----------------------------------------
  qry := SQLSTR ; --(THIS IS THE QUERRY THAT WAS CREATED USING THE CHECKBOXES.
                                                   -- ACCORDING TO THE EXAMPLE THE qry SHOULD MATCH THE rgid RECORDGROUP.
                                                       -- BUT I DONT KNOW HOW TO DO THAT)
  SQLSTR :=( 'SELECT'   ||v_select||
                                     'FROM                  Sales, Product, Area, Timei'||
                                     'WHERE          Sales.Product_ID= Product.Product_ID'||
                                     'AND               Sales.Area_ID = Area.Area_ID'||
                                     'AND                Sales.Date = Time.Date'||
                                     'AND                DATE BETWEEN  :D1 AND :D2');
                                                      
 --  Make sure the group does not already exists.
 rgid := FIND_GROUP(groupname);

 --   If the group exists, then delete it.
 IF NOT ID_NULL(rgid) THEN
    DELETE_GROUP(rgid);
 END IF;

  --  Create the group.
 rgid  := CREATE_GROUP_FROM_QUERY(groupname, qry);

  --  Make sure the record group is empty.
 DELETE_GROUP_ROW(rgid, ALL_ROWS);

 --   Retrieve the data.
 n := POPULATE_GROUP_WITH_QUERY(rgid, qry);

 --   Make sure the list does not already exist.
 plid := GET_PARAMETER_LIST(paramlistname);

 --   If the list exists, then delete it.
 IF NOT ID_NULL(plid) THEN
    DESTROY_PARAMETER_LIST(paramlistname);
 END IF;

 plid := CREATE_PARAMETER_LIST(paramlistname);
 ADD_PARAMETER(plid, qname, DATA_PARAMETER, groupname);

 --   Suppress the parameter form.
 ADD_PARAMETER(plid, 'paramform', TEXT_PARAMETER, 'NO');

--    The following command will call Oracle Reports in SYNCHRONOUS mode.
--    To call Oracle Graphics, replace the REPORTS with GRAPHICS.

 RUN_PRODUCT(REPORTS, 'RG', SYNCHRONOUS, RUNTIME, FILESYSTEM, plid, NULL);

 DESTROY_PARAMETER_LIST(plid);
 DELETE_GROUP(rgid);

end;


 

by: priti_81Posted on 2003-03-09 at 18:28:55ID: 8100182

please help me.

 

by: priti_81Posted on 2003-03-09 at 18:41:45ID: 8100220

has anybody done any coding for some thing like this question? if so can i please have a look at it?
i'm desperate. i need help..  

 

by: priti_81Posted on 2003-03-09 at 18:41:45ID: 8100221

has anybody done any coding for some thing like this question? if so can i please have a look at it?
i'm desperate. i need help..  

 

by: AvotarPosted on 2003-03-09 at 22:18:24ID: 8101020

sigh...

listen.. your query needs to be valid.. and it isn't...

this i copied from your answer:
I modified  “qry VARCHAR2(2000)         := 'SELECT ename, sal, comm' ||
                              'FROM emp' ||” to  qry VARCHAR2(2000)         := SQLSTR  I hope that can be done..?

if you put your string together, this is your result:
SELECT ename, sal, commFROM emp

you have to put in a space either after comm or before FROM .. that way your query-string will be valid..

 

by: priti_81Posted on 2003-03-10 at 05:37:47ID: 8102686

hmmm thanks for the help. ..

 

by: AvotarPosted on 2003-03-10 at 05:40:30ID: 8102708

did it work...? then gimme the points bro..

 

by: priti_81Posted on 2003-03-12 at 05:37:17ID: 8119198

no pal it still doesnt work. think i had enough with forms!!

 

by: lmedfoPosted on 2003-03-12 at 07:15:12ID: 8119979

swap these two statements.  fix the sql.
qry := SQLSTR ; --(THIS IS THE QUERRY THAT WAS CREATED USING THE CHECKBOXES.
                                           -- ACCORDING TO THE EXAMPLE THE qry SHOULD MATCH THE rgid RECORDGROUP.
                                              -- BUT I DONT KNOW HOW TO DO THAT)
 SQLSTR :=( 'SELECT'   ||v_select||
                               'FROM               Sales, Product, Area, Timei'||
                               'WHERE         Sales.Product_ID= Product.Product_ID'||
                               'AND             Sales.Area_ID = Area.Area_ID'||
                               'AND              Sales.Date = Time.Date'||
                               'AND              DATE BETWEEN  :D1 AND :D2');
                                             
Also, look at the from clause.  you have Timei instead of Time.

 

by: mgillmanPosted on 2003-03-26 at 07:07:17ID: 8210914

You initially set your v_select var to 'Select', the you set you8r sqlstr to

SQLSTR :=( 'SELECT' ||v_select||'FROM Sales, Product, Area, Timei'|| 'WHERE Sales.Product_ID= Product.Product_ID'|| 'AND Sales.Area_ID = Area.Area_ID'||
'AND Sales.Date = Time.Date'|| 'AND DATE BETWEEN  :D1 AND :D2');

It looks to me like you have a syntax problem.  When you pass sqlstr to exec_SQL.parse(connection_id,cursor_name,SQLSTR,exec_sql.v7); you are actually passing "select select...".  Try initializing your v_select to null.

 

by: mahbub007Posted on 2003-03-26 at 22:58:02ID: 8215976

hi priti,
         i looked to the query statement u built ,that is
 SQLSTR :=( 'SELECT'   ||v_select||'FROMSales,Product,
Area, Timei'||'WHERE Sales.Product_ID=Product.Product_ID'||
'AND Sales.Area_ID = Area.Area_ID'||'AND Sales.Date = Time.Date'||'AND DATE BETWEEN  :D1 AND :D2');
what i find that is in the where clause there is no condition to join the time table to any other table.
    u have one form where u just check the check boxes to determine which columns from which tables should be selected,suppose u checked the
boxes for the columns Product_ID, P_Name from the product table.but u see,here u r not giving a value for a where cluse that means u r selecting all the rows from the product table.so suppose u checked all the boxes for all the columns for all the tables,then a select statement will be constructed which will look like the one i mentioned above.here u see there is no where condition for a specific table in the where cluse,so the joining conditions between the tables forming the entire where cluse but there is no joining condition between the time table and any other table.so to make ur select statement correct u have to have relations between all tables.i mean there should be atleaset one primary ,foreign key relationship between time table and any other table so that u can use that relation in the join condition.
       what i feel if u correct ur select statement according to my suggestion ,u may become successfull.

thanks
mehbub

 

by: HenkaPosted on 2004-01-20 at 04:39:05ID: 10154389

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

PAQ/No Refund.

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Henka
EE Cleanup Volunteer

 

by: Computer101Posted on 2004-01-27 at 16:13:15ID: 10214612

PAQed - no points refunded (of 85)

Computer101
E-E Admin

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...