Problem with creating view with group by

I created a veiw like this
CREATE OR REPLACE FORCE VIEW "Emp" ("team", "Num") AS
select team, count(*) AS Num
from employee
group by team
The data in the view like this:
team Num
1 29
2 10
5 1
I have team 1, 2, 3, 4, 5 in table employee. I wanta the view to have data like this;
team Num
1 29
2 10
3 0
4 0
5 1
is there some way to achieve this?
Thanks for your help.

SQL> select * from emp;
     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
      7566 JONES      MANAGER         7839 02-APR-81       2975       1000         20
      7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
      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
      7369 SMITH      CLERK           7902 17-DEC-80        800                    20
      7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
      7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
      7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
      7788 SCOTT      ANALYST         7566 09-DEC-82       3000                    20
      7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
      7876 ADAMS      CLERK           7788 12-JAN-83       1100                    20
      7900 JAMES      CLERK           7698 03-DEC-81        950                    30
      7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
14 rows selected.
SQL> select deptno, count(*)
  2    from emp
  3  group by deptno;
    DEPTNO   COUNT(*)
        10          3
        20          5
        30          6
SQL> can you post the result of this query:
  select distinct team from employee;note: just want to check what team values do you have from your table employee

Similar Messages

  • Problem while Creating MVLOG with synonym in Oracle 9i:Is it an Oracle Bug?

    Hi All,
    I am facing a problem while Creating MVLOG with synonym in Oracle 9i but for 10G it is working fine. Is it an Oracle Bug? or i am missing something.
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    SQL>
    SQL> create table t ( name varchar2(20), id varchar2(1) primary key);
    Table created.
    SQL> create materialized view log on t;
    Materialized view log created.
    SQL> create public synonym syn_t for t;
    Synonym created.
    SQL> CREATE MATERIALIZED VIEW MV_t
      2  REFRESH ON DEMAND
      3  WITH PRIMARY KEY
      4  AS
      5  SELECT name,id
      6  FROM syn_t;
    Materialized view created.
    SQL> CREATE MATERIALIZED VIEW LOG ON  MV_t
      2  WITH PRIMARY KEY
      3   (name)
      4    INCLUDING NEW VALUES;
    Materialized view log created.
    SQL> select * from v$version;
    BANNER
    Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production
    PL/SQL Release 9.2.0.6.0 - Production
    CORE    9.2.0.6.0       Production
    TNS for Solaris: Version 9.2.0.6.0 - Production
    NLSRTL Version 9.2.0.6.0 - Production
    SQL>
    SQL> create table t ( name varchar2(20), id varchar2(1) primary key);
    Table created.
    SQL> create materialized view log on t;
    Materialized view log created.
    SQL> create public synonym syn_t for t;
    Synonym created.
    SQL> CREATE MATERIALIZED VIEW MV_t
    REFRESH ON DEMAND
    WITH PRIMARY KEY
    AS
      2    3    4    5  SELECT name,id
    FROM syn_t;   6
    Materialized view created.
    SQL> CREATE MATERIALIZED VIEW LOG ON  MV_t
    WITH PRIMARY KEY
    (name)
      INCLUDING NEW VALUES;  2    3    4
    CREATE MATERIALIZED VIEW LOG ON  MV_t
    ERROR at line 1:
    ORA-12014: table 'MV_T' does not contain a primary key constraintRegards
    Message was edited by:
    Avinash Tripathi
    null

    Hi Nicloei,
    Thanks for the reply. Actually i don't want any work around (Creating MVLOG on table rather than synonym is fine with me) . I just wanted to know it is actually an oracle bug or something else.
    Regards
    Avinash

  • Problem in creating PDF with InDesign CS5.5

    Problem in creating PDF with InDesign CS5.5:
    exporting a file in pdf, setting "Press Quality" or "PDF/X-1a: 2001" and selecting "Crop Marks" and the surplus of xx mm, the elements contained in the MASTER page move from the original position or disappear at random.
    Can you help me, please?
    Thanks a lot.

    Try Remove minor corruption by exporting

  • Create View  with Force and No Force

    Can Anyone Tell me how to create view with force and no force i have very little idea about this

    This is the syntax.
    CREATE [OR REPLACE] FORCE VIEW view
    [(alias[, alias]...)]
    AS subquery
    [WITH CHECK OPTION [CONSTRAINT constraint]]
    [WITH READ ONLY [CONSTRAINT constraint]];You can see interesting threads about this topic here.
    Re: Creating view forcibly
    Creating View forcefully
    Cheers
    Sarma.

  • Is it possible to create views with parameters ?

    Hi,
    As MS-Access, is it possible to create views with parameters ?
    Ms-Access syntax : parameters [a] text; select * from table where code = [a]
    If yes, can you give samples ?
    Regards
    Pascal

    I suggest you you write a stored procedure that returns a recordset in oracle. Then execute the stored procedure and loop through the record set.
    Look in in MS Knowledgebase searching on ADO Stored Proceedures for the VB/C++/VBS .. code.
    Look in in Oracle PL/SQL guide for the Stored Proceedure code.

  • Problem while creating xml with cdata section

    Hi,
    I am facing problem while creating xml with cdata section in it. I am using Oracle 10.1.0.4.0 I am writing a stored procedure which accepts a set of input parameters and creates a xml document from them. The code snippet is as follows:
    select xmlelement("DOCUMENTS",
    xmlagg
    (xmlelement
    ("DOCUMENT",
    xmlforest
    (m.document_name_txt as "DOCUMENT_NAME_TXT",
    m.document_type_cd as "DOCUMENT_TYPE_CD",
    '<![cdata[' || m.document_clob_data || ']]>' as "DOCUMENT_CLOB_DATA"
    ) from table(cast(msg_clob_data_arr as DOCUMENT_CLOB_TBL))m;
    msg_clob_data_arr is an input parameter to procedure and DOCUMENT_CLOB_TBL is a pl/sql table of an object containing 3 attributes: first 2 being varchar2 and the 3rd one as CLOB. The xml document this query is generating is as follows:
    <DOCUMENTS>
    <DOCUMENT>
    <DOCUMENT_NAME_TXT>TestName</DOCUMENT_NAME_TXT>
    <DOCUMENT_TYPE_CD>BLOB</DOCUMENT_TYPE_CD>
    <DOCUMENT_CLOB_DATA>
    &lt;![cdata[123456789012345678901234567890123456789012]]&gt;
    </DOCUMENT_CLOB_DATA>
    </DOCUMENT>
    </DOCUMENTS>
    The problem is instead of <![cdata[....]]> xmlforest query is encoding everything to give &lt; for cdata tag. How can I overcome this? Please help.

    SQL> create or replace function XMLCDATA_10103 (elementName varchar2,
      2                                             cdataValue varchar2)
      3  return xmltype deterministic
      4  as
      5  begin
      6     return xmltype('<' || elementName || '><![CDATA[' || cdataValue || ']]>
      7  end;
      8  /
    Function created.
    SQL>  select xmlelement
      2         (
      3            "Row",
      4            xmlcdata_10103('Junk','&<>!%$#&%*&$'),
      5            xmlcdata_10103('Name',ENAME),
      6            xmlelement("EMPID", EMPNO)
      7         ).extract('/*')
      8* from emp
    SQL> /
    <Row>
      <Junk><![CDATA[&<>!%$#&%*&$]]></Junk>
      <Name><![CDATA[SMITH]]></Name>
      <EMPID>7369</EMPID>
    </Row>
    <Row>
      <Junk><![CDATA[&<>!%$#&%*&$]]></Junk>
      <Name><![CDATA[ALLEN]]></Name>
      <EMPID>7499</EMPID>
    </Row>
    <Row>
      <Junk><![CDATA[&<>!%$#&%*&$]]></Junk>
      <Name><![CDATA[WARD]]></Name>
      <EMPID>7521</EMPID>
    </Row>
    <Row>
      <Junk><![CDATA[&<>!%$#&%*&$]]></Junk>
      <Name><![CDATA[JONES]]></Name>
      <EMPID>7566</EMPID>
    </Row>
    <Row>
      <Junk><![CDATA[&<>!%$#&%*&$]]></Junk>
      <Name><![CDATA[MARTIN]]></Name>
      <EMPID>7654</EMPID>
    </Row>
    <Row>
      <Junk><![CDATA[&<>!%$#&%*&$]]></Junk>
      <Name><![CDATA[BLAKE]]></Name>
      <EMPID>7698</EMPID>
    </Row>
    <Row>
      <Junk><![CDATA[&<>!%$#&%*&$]]></Junk>
      <Name><![CDATA[CLARK]]></Name>
      <EMPID>7782</EMPID>
    </Row>
    <Row>
      <Junk><![CDATA[&<>!%$#&%*&$]]></Junk>
      <Name><![CDATA[SCOTT]]></Name>
      <EMPID>7788</EMPID>
    </Row>
    <Row>
      <Junk><![CDATA[&<>!%$#&%*&$]]></Junk>
      <Name><![CDATA[KING]]></Name>
      <EMPID>7839</EMPID>
    </Row>
    <Row>
      <Junk><![CDATA[&<>!%$#&%*&$]]></Junk>
      <Name><![CDATA[TURNER]]></Name>
      <EMPID>7844</EMPID>
    </Row>
    <Row>
      <Junk><![CDATA[&<>!%$#&%*&$]]></Junk>
      <Name><![CDATA[ADAMS]]></Name>
      <EMPID>7876</EMPID>
    </Row>
    <Row>
      <Junk><![CDATA[&<>!%$#&%*&$]]></Junk>
      <Name><![CDATA[JAMES]]></Name>
      <EMPID>7900</EMPID>
    </Row>
    <Row>
      <Junk><![CDATA[&<>!%$#&%*&$]]></Junk>
      <Name><![CDATA[FORD]]></Name>
      <EMPID>7902</EMPID>
    </Row>
    <Row>
      <Junk><![CDATA[&<>!%$#&%*&$]]></Junk>
      <Name><![CDATA[MILLER]]></Name>
      <EMPID>7934</EMPID>
    </Row>
    14 rows selected.
    SQL>

  • How I can create view with parameters?

    I have very big query (2000 rows) and 2 parameters.
    How I can create view with parameters?

    If I use this small part of my query than I have error :
    java.lang.NullPointerException
         at oracle.javatools.db.ora.OracleSQLQueryBuilder.buildQuery(OracleSQLQueryBuilder.java:199)
         at oracle.javatools.db.ora.OracleSQLQueryBuilder.buildQuery(OracleSQLQueryBuilder.java:147)
    What does it means?
    select
    ' Payroll ' as Revenue
    , t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
    from
    acct a, total t, property p, param par
    where
    nvl(t.hacct, 0) = nvl(a.hmy, 0)
    and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
    and nvl(t.iBook, 0) = 0
    and nvl(a.iacctType, 0) = 0 /*Regular accts*/
    and nvl(t.hppty, 0) = nvl(p.hmy, 0)
    and ( nvl(a.scode, 0) between 60000 and 6009000 )
    union all ---------------------------------------------------------------------------------------------------------------------------------
    select
    ' Payroll Taxes '
    , t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
    from
    acct a, total t, property p, param par
    where
    nvl(t.hacct, 0) = nvl(a.hmy, 0)
    and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
    and nvl(t.iBook, 0) = 0
    and nvl(a.iacctType, 0) = 0 /*Regular accts*/
    and nvl(t.hppty, 0) = nvl(p.hmy, 0)
    and
    (nvl(a.scode, 0) between 60100 and 60690 )
    union all -------------------------------------------------------------------------------------------------------------------------------
    select
    ' Workers Comp/Disability '
    , t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
    from
    acct a, total t, property p, param par
    where
    nvl(t.hacct, 0) = nvl(a.hmy, 0)
    and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
    and nvl(t.iBook, 0) = 0
    and nvl(a.iacctType, 0) = 0 /*Regular accts*/
    and nvl(t.hppty, 0) = nvl(p.hmy, 0)
    and
    ( nvl(a.scode, 0) between 61200 and 61260)
    union all -------------------------------------------------------------------------------------------------------------------------------
    select
    ' Pension and Hospitalization '
    , t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
    from
    acct a, total t, property p, param par
    where
    nvl(t.hacct, 0) = nvl(a.hmy, 0)
    and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
    and nvl(t.iBook, 0) = 0
    and nvl(a.iacctType, 0) = 0 /*Regular accts*/
    and nvl(t.hppty, 0) = nvl(p.hmy, 0)
    and
    ( nvl(a.scode, 0) between 61000 and 61550 )
    union all -------------------------------------------------------------------------------------------------------------------------------
    select
    ' Other Labor Costs '
    , t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
    from
    acct a, total t, property p, param par
    where
    nvl(t.hacct, 0) = nvl(a.hmy, 0)
    and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
    and nvl(t.iBook, 0) = 0
    and nvl(a.iacctType, 0) = 0 /*Regular accts*/
    and nvl(t.hppty, 0) = nvl(p.hmy, 0)
    and
    ( nvl(a.scode, 0) between 616000 and 616400 )

  • Makes it possible to create view with parameters

    makes it possibel to create view with paramater, example
    create or replace view v_test(segment varchar2)
        select * from ref_user where segment = segmentThanks

    thanks..
    select count(distinct substr(a.svm_id,1,10)) jumlah " +
       " from daily_distribution_pop a, ref_toko b " +
       " where " +
       " substr(a.svm_id,1,10)=b.id and b.segment_type = 'A' and enable_flag='Y' " +
       " and a.tgl_visit between to_date('" + fromStartDate + "', 'dd/MM/yyyy') and to_date('" + fromEndDate + "', 'dd/MM/yyyy')
         and " + whereA + "= '" + whereB + "' " +
       " and substr(a.pom_id,1,2) = 'DP' and (a.qty_instore <> 0 or a.qty_delivered <> 0) ";
    {code}
    where fromStartDate,  fromEndDate, whereA, whereB  is variable parameter from asp.net.
    how to i can implement with view                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Problem with creating/viewing PDF's from InDesign CS3

    I have a problem with our PDF workflow and just cannot seem to resolve it.
    The problem is as follows: My coworker and I (both designers running CS3 on iMac's running 10.5.6 Leopard) work daily on producing documents and graphic layouts.
    Internally we can view and print PDF documents we create just fine with no troubles with the exception of our supervisor, who is running a mac with Tiger operating system. Our office environment is both Mac and PC. On may occasions he cannot print PDF's we create. Many times his prints will contain garbled characters, drop italics and formatting, replace fonts, or just print slowly.
    This problem is also happening to our editor who is offsite. This is a fairly serious problem for her, considering her job relies heavily on being able to view and open PDF files we create. She was able to send a PDF file which shows the garbled mess her printer spit out when she printed. Apparently there were pages upon pages of messy garbled text. When documents do print from her, they are usually very slow in printing, taking up to a minute or more to print each page.
    The sample of what she sent me is attached, and can also be found on my MobileMe iDisk at: http://public.me.com/rlcollier (document entitled Print Results.PDF)
    My question really to the community is obviously what might be causing these problems. Its very frustrating not being able to determine if its something we're doing ourselves thats causing some incompatability or corruption in these files, or if its the users systems themselves. I can say that Debra our editor has can have a garbled mess of a 4 page file from us, and then turn around and print a graphic heavy 90 page PDF with ease from Boeing. Our PDF's seem to be the only ones she struggles with. That being said, my inclination is that its something on our end.
    Any ideas of where to start looking? Any help at all would be greatly appreciated and welcomed. Thanks!

    I currently had our editor test printing of some of our files using both Foxit and Adobe Reader (as was suggested) in order to see if either made a difference in her printing ability and here is what she came back with:
    I tried to print out both these pdfs (David's is the one you reworked and Lisa's HESSM-3, both sent yesterday).
    With Adobe:  David's first page printed quickly, but it had errors (part of his pants didn't print, and there's an arbitrary shaded box in the text).  Page 2 didn't print--every time I tried it had a different "offending command" code.  Printing Lisa's HESSM  made it up to page 7 before problems showed up (stock photo only partially printed), and it stopped on page 8 (with the random "offending command" code).
    With Foxit:  Both David's and the HESSM pdfs printed completely and without error...but it took a long time.   David's 2 pages took about 3 to 4 minutes, and HESSM's 16 pages took close to 20 minutes.  The time is in the transfer of data to the printer; the physical printing  goes pretty quickly.
    I cant say that I believe email is the problem, although I cant rule it out. I've tested emailing vs. passing through our workgroup with my supervisor, and it does not make any difference in his ability (or lack of ability) to print our files. He was able to print to a different printer (an HP 4650 as opposed to a 4100) without troubles. He refuses to believe its a printer problem however because PDF files originating from our office are the only ones he has trouble with. Never has he had any trouble with a single PDF file produced from any other source. This is also the case for our editor who only has trouble with PDF files originating from either mine, or my coworkers systems.
    PS: I've attached both files that were referenced by our editor above for viewing/testing.

  • Create view with union

    Hi all,
    I have tried to create a view with next code:
    CREATE VIEW vista_urbanizacion AS SELECT
    RUPI_URBANIZACIONES.NOMBRE_URBANIZACION,
    RUPI_URBANIZACIONES.NRO_PREDIOS,
    RUPI_URBANIZACIONES.NRO_URBANIZACION,
    RUPI_URBANIZACIONES.ESTADO,
    RUPI_URBANIZACIONES.FECHA_INGRESO,
    RUPI_URBANIZACIONES.AREA_TERRENO,
    RUPI_URBANIZACIONES.TIPO,
    RUPI_URBANIZACIONES.UBICACION_ARCHIVO,
    RUPI_URBANIZACIONES.NRO_SUPERURBANIZACION,
    RUPI_URBANIZACIONES.ID_URBANIZADOR,
    RUPI_URBANIZACIONES.AREA_TOTAL_CESION,
    RUPI_ESCRITURAS.MATRICULA_INMOBILIARIA,
    RUPI_ESCRITURAS.NOTARIA,
    RUPI_ESCRITURAS.CIUDAD,
    RUPI_ESCRITURAS.ACTO_JURIDICO,
    RUPI_ESCRITURAS.FECHA_ESCRITURA,
    RUPI_ESCRITURAS.NRO_ESCRITURA,
    RUPI_ESCRITURAS.CONSECUTIVO,
    RUPI_ESCRITURAS.URBANIZACI_NRO_URBANIZACION,
    RUPI_ACTAS.TIPO_ACTA,
    RUPI_ACTAS.NRO_ACTA,
    RUPI_ACTAS.FECHA_ACTA
    FROM
    RUPI_URBANIZACIONES,
    RUPI_ESCRITURAS,
    RUPI_ACTAS
    WHERE
    RUPI_URBANIZACIONES.NRO_URBANIZACION =
    RUPI_ESCRITURAS.URBANIZACI_NRO_URBANIZACION
    AND
    FECHA_ESCRITURA IN (SELECT MIN(FECHA_ESCRITURA) FROM RUPI_ESCRITURAS
    WHERE
    RUPI_URBANIZACIONES.NRO_URBANIZACION = RUPI_ESCRITURAS.URBANIZACI_NRO_URBANIZACION)
    AND
    RUPI_URBANIZACIONES.NRO_URBANIZACION =
    RUPI_ACTAS.URBANIZACI_NRO_URBANIZACION
    AND
    FECHA_ACTA IN (SELECT MAX(FECHA_ACTA) FROM RUPI_ACTAS
    WHERE
    RUPI_URBANIZACIONES.NRO_URBANIZACION =
    RUPI_ACTAS.URBANIZACI_NRO_URBANIZACION)
    The problem is the condition "and" from the rupi_escrituras and rupi_actas tables that only will select elements of rupi_urbanizaciones included both in rupi_escrituras and rupi_actas.
    I need to use something like "union" in order to include all the distinct elements of both tables rupi_escrituras and rupi_actas.
    Could anyone help?
    Thanks in advance
    Romulo

    Yep,
    In this query you don't do any join between the tables. So let's get back to the basic.
    Take you first query
    SELECT CBR_ID,PLT_ID,SUM(COUNT_POL)
    FROM
    SELECT  pcd_irs_id CBR_ID, pcd_plt_id PLT_ID , sum(pcd_amount_lc) SUM_PREM,0 COUNT_POL
    FROM seema
    where trunc(pcd_registry_date)=TRUNC(pcd_registry_date)
    and pcd_plt_id in('U01','U02')
    and pcd_irs_id in (55,56)
    AND PCD_IRS_TYPE!=4
    GROUP BY PCD_irs_ID,PCD_PLT_ID
    UNION
    SELECT PLM_CBR_ID CBR_ID,PLM_PLT_ID PLT_ID,0 SUM_PREM, COUNT(PLM_POLICY_NO) COUNT_POL
    FROM sarah
    WHERE  trunc(PLM_registry_date)=TRUNC(PLM_registry_date)
    AND PLM_PLT_ID IN('U01','U02)
    GROUP BY PLM_CBR_ID,PLM_PLT_ID)
    GROUP BY CBR_ID,PLT_ID
    ORDER BY CBR_ID,PLT_IDThis query is quite near to the result that you need. You are very near to the result just add the filter that you need in the second query:
    SELECT CBR_ID,PLT_ID,SUM(COUNT_POL)
    FROM
    SELECT  pcd_irs_id CBR_ID, pcd_plt_id PLT_ID , sum(pcd_amount_lc) SUM_PREM,0 COUNT_POL
    FROM seema
    where trunc(pcd_registry_date)=TRUNC(pcd_registry_date)
    and pcd_plt_id in('U01','U02')
    and pcd_irs_id in (55,56)
    AND PCD_IRS_TYPE!=4
    GROUP BY PCD_irs_ID,PCD_PLT_ID
    UNION
    SELECT PLM_CBR_ID CBR_ID,PLM_PLT_ID PLT_ID,0 SUM_PREM, COUNT(PLM_POLICY_NO) COUNT_POL
    FROM sarah
    WHERE  trunc(PLM_registry_date)=TRUNC(PLM_registry_date)
    AND PLM_PLT_ID IN('U01','U02)
    and PLM_CBR_ID in (55,56)          --<<<<<<<<< ADDED FILTER
    GROUP BY PLM_CBR_ID,PLM_PLT_ID)
    GROUP BY CBR_ID,PLT_ID
    ORDER BY CBR_ID,PLT_IDand you are done.
    Bye
    Antonio

  • Cannot create view with parameter bindings

    Hi, I'm trying to create this view in SQLPlus:
    SELECT order_no, SUM(cut_qty),
    SUM(received_qty)
    FROM (
    SELECT order_no, cut.dated, DECODE(cut.bimetallic, 'F', cut.quantity, cut.quantity/2) cut_qty,0 AS received_qty
    FROM cut_shop_orders_dated cut
    WHERE cut.dated BETWEEN TO_DATE('&date1','DD/MM/YYYY') AND TO_DATE('&date2','DD/MM/YYYY')
    UNION
    (SELECT order_no, rec.dated, 0, rec.quantity
    FROM received_shop_orders_dated rec
    WHERE rec.dated BETWEEN TO_DATE('&date3','DD/MM/YYYY') AND TO_DATE('&date4','DD/MM/YYYY')))
    GROUP BY order_no
    The problem is that sqlplus asks me for the parameter values and then creates it with these values as literal dates in the to_date function, those not asking for parameter values in runtime.
    How can I create it using parameters with no values at design time?
    Thanks.
    Leandro.

    if you want something like :
    select * from emp $where_clause;
    you can write a procedure with parameter and run it as dynamic sql for example
    create or replace procedure pr1 ( p_where   varchar2) is
    begin
      execute immediate 'create or replace view view_name as select * from emp '|| p_where;
    end pr1;
    /then run it on sql*plus
    SQL> exec pr1('where deptno = 10');
    make sure you give yourself "create any view" rights explicitly.
    HTH
    Ghulam

  • Problem with object view with primary-key based object identifier

    Hello!
    I met such problem.
    t1 is persinstent-capable class:
    class t1 : public PObject { .... };
    T1OV is object view, based on object table T1OT
    I1 is primary key of the table T1OT.
    Next code:
    t1* t = new (conn, "T1OV") t1(...);
    conn->commit();
    try
    t->markDelete();
    conn->commit(); // exception throws here
    Works fine if T1OV defined as:
    create view t1ov of t1 with object identifier default
    as select * from t1ot;
    And throws an exception
    "ORA-22883: object deletion failed"
    if:
    create view t1ov of t1 with object identifier (I1)
    as select * from t1ot;
    Such problem also occurs when object view is based on relational table/view (OID is primary-key based).
    Also it occurs when
    t->markModified() used insted of t->markDelete()
    I am using Oracle 9i second release for windows and
    MS VC++
    Thank You

    http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_85a.htm#2065512
    You can specify constraints on views and object views. You define the constraint at the view level using the out_of_line_constraint clause. You define the constraint as part of column or attribute specification using the inline_constraint clause after the appropriate alias.
    Oracle does not enforce view constraints. However, operations on views are subject to the integrity constraints defined on the underlying base tables. This means that you can enforce constraints on views through constraints on base tables.
    Restrictions on View Constraints
    View constraints are a subset of table constraints and are subject to the following restrictions:
    You can specify only unique, primary key, and foreign key constraints on views. However, you can define the view using the WITH CHECK OPTION clause, which is equivalent to specifying a check constraint for the view.
    Because view constraints are not enforced directly, you cannot specify INITIALLY DEFERRED or DEFERRABLE.
    View constraints are supported only in DISABLE NOVALIDATE mode. You must specify the keywords DISABLE NOVALIDATE when you declare the view constraint, and you cannot specify any other mode.
    You cannot specify the using_index_clause, the exceptions_clause clause, or the ON DELETE clause of the references_clause.
    You cannot define view constraints on attributes of an object column.
    Rgds.

  • Creating Views with DI APIs DoQuery-Method in SQL 2005

    Hi @All,
    I've had the following (solved) problem:
    The DB installer of one of our AddOns is also creating a bunsh of views for our UDTs. The installer always executes the following two statements for each view:
    IF OBJECT_ID ('[dbo].[@NSP_EXAMPLE_VIEW]', 'V' ) IS NOT NULL
        DROP VIEW  [dbo].[@NSP_EXAMPLE_VIEW];
    CREATE VIEW [dbo].[@NSP_EXAMPLE_VIEW] AS
    SELECT
         T0.U_Field3,
         T1.U_Field1,
    FROM
         [dbo].[@NSP_A] T0 INNER JOIN
         [dbo].[@NSP_B] T1 ON
         T0.U_Key=T1.U_Key  AND
         T0.U_CostNo=T1.U_CostNo;
    This has worked fine for the first 3 views we need. Then came the 4th view and we get an exception from the doQuery. I had to change the SQL-2005 compatibility level back to 80 to create the 4th view because of an incompatible "FOR BROWSE"-statement.
    When it was created under level 80 I saw the problem: ONLY the 4th view was extended with the "FOR BROWSE"-Statement by DI-API. I didn't see any difference in the 4th VIEW-statement which could be the reason that only this one gets the "FOR BROWSE"
    Anyway! Big thanks to  John Mackin and the users of this thread:
    [Formatted search;
    Adding an SQL-comment "--FOR BROWSE" at the end of the VIEW-creation statement has solved the problem.
    (I hope the DI-API query parser will not change this behaviour in the future :-o )
    Cheers,
    Roland

    Thanks for the replies, but casting gave me the original 'General Error' as well.
    I tried to make a stored procedure out of it. I used this page as a guide:
    http://www.davidhayden.com/blog/dave/archive/2005/12/30/2652.aspx
    The stored procedure looks like this:
    set ANSI_NULLS ON
    set QUOTED_IDENTIFIER ON
    go
    CREATE PROCEDURE [dbo].[TestItems]
        @PageIndex INT,
        @PageSize INT
    AS
    BEGIN
    WITH tmpItems AS (
    SELECT ROW_NUMBER() OVER (ORDER BY ItemCode DESC)AS Row, ItemCode, ItemName
    FROM OITM)
    SELECT ItemCode, ItemName
    FROM tmpItems
    WHERE Row between (@PageIndex - 1) * @PageSize + 1 and @PageIndex*@PageSize
    END
    I am able to call this stored procedure like this:
    exec TestItems 10, 10  -- (returns item 91 to 100).
    This solution meets my immediate requirements, but I don't like the fact that I added the stored procedure to the administration itself. Is it possible to add the stored procedure to a different database and still use the DI server?
    Thanks for your time!
    Vincent

  • Problem of creating workbook with permanent template?

    Hi all,
    Iam facing some problem while creating the workbook with permanent template.Let me expalin in detail.
    I have created 3 queries (ex:Stock) and i have to insert these in one workbook with permanent template.I  had selected the the permanent template option in settings also.iam able to insert the 3 queris and iam not getting the permanent tempalate.which is mandatory.
    I tried saving the existing workbook with same tempalate and removed the query and tried to insert the queries but iam getting <b>abbort system error in program</b>
    Pls help me out of this issue.
    Thanks and regards,
    Rajeev

    Hi Joe,
    We've seen this error when using express VI's inside of template VI's which are loaded using VI server. Are you doing that? If yes, then take all the express VIs that are inside the template VI and turn them into static subVIs.
    I don't know if it will help in your case, but let's try it.
    Regards,
    Luca
    Regards,
    Luca

  • What is the use for CREATING VIEW WITH CHECK OPTION?

    Dear Legends,
    I have a doubt
    What is the use for creating view?
    A: First Data Integrity, Selecting Particular Columns..
    What is the use for creating a view with check option?
    A: As per oracle manual I read that its a referential integrity check through views.
    A: Enforcing constraints at DB level.
    A: using CHECK OPTION we can do INSERTS UPDATES for a view for those columns who have no constraints... is it right??
    A: If we do a INSERT OR UPDATE for columns who have constraints it will show error... is it right???
    Please clear my doubt's Legends
    Lots of Thanks....
    Regards,
    Karthik

    Hi, Karthick,
    karthiksingh_dba wrote:
    ... What is the use for creating view?
    A: First Data Integrity, Selecting Particular Columns..Most views are created and used for convenience. A view is a saved query. If the same operations are often done, then it can be very convenient to code those operations once, in a view, and refer to the view rather than explicitly doing those operations.
    Sometimes, views are created and used for security reasons. For example, you many want to allow some users to see only certain rows or certain columns of a table.
    Views are necessary for INSTEAD OF triggers.
    What is the use for creating a view with check option?
    A: As per oracle manual I read that its a referential integrity check through views.The reason is integrity, not necessarily referential integrity. The CHECK option applies only when DML is done through the view. It prohibits certain changes. For example, if a user can't see certain rows through a view, the CHECK option keeps the user from creating such rows.
    A: Enforcing constraints at DB level.I'm not sure what you mean. Please give an example.
    A: using CHECK OPTION we can do INSERTS UPDATES for a view for those columns who have no constraints... is it right??No. Using CHECK OPTION, you can do some inserts and updates, but not others. The columns involved may or may not have constraints in either case.
    A: If we do a INSERT OR UPDATE for columns who have constraints it will show error... is it right???If you try to violate a constraint, you'll get an error. That happens in views with or without the CHECK OPTION, and also in tables.

Maybe you are looking for

  • Problem with "Movies" GUI, keeps kicking me out.

    Every other channel (i.e. Netflix) functions normally when using my Apple Remote and my Apple TV 2 running the latest iOS, but when i try to use the iTunes "Movies" store, I cannot properly navigate throught the "menu bar". I click on the Movies icon

  • Calling web service with utl_dbws and parsing the xml result with Xpath

    I'm invoking a web service from the database(10.2.0.2.0) using sys.utl_dbws and all is working well. After executing response := sys.utl_dbws.invoke(call_, request); I execute dbms_output.put_line(substr(response.getstringval(),1,1500)); which result

  • !!!Problems Using Logic With Reason in Rewire Mode!!!

    Hi, Maybe someone can help me... I can´t Hear any sound coming out of Reason into logic! This is what i did: 1- loaded logic 2- loaded reason (used the Redrum, L+R and connected to the 1 and 2 Audio OUT of reason) 3- selected a audio track in Logic P

  • Safari doesn't work

    set up my new imac/ airport extreme wired connection yesterday everything worked fine over night lost internet connection (mail,itunes etc) today i can get firefox fired up the network diagnostics says everything is fine but safari, itunes, and mail

  • IPhoto no good in Leopard anymore

    I've got iPhoto v.2 that came w/ my computer four years ago. Just updated to Leopard and SURPRISE! Leopard doesn't support iPhoto 2. No disclaimers before I bought the software of course. Is there anyway to continue saving and editing my photos w/Leo