Return a row for sql plsql

Hi all

I get columns 5 and 6 in the form of a record variable, a join of multiple tables, returned by a function called func. These columns belong to different variable tables.this of record is returned by a function in my sql environment, where I'm using a statement similar to the Sub statement.

Select func (par1, par2) of double;


I created a compatible record type in my schema using the Sub statement.

CREATE OR REPLACE TYPE ME_TYPE AS
OBJECT
(
number of col1,
col2 number.


col6 varchar2 (1000)
);




I created a variable of type record in my plsql function, using the statement
declare
me_type var1;

Start


Select
tab1. Col1,
Tab2.col2,
.
.
. tab6.col6
in
var1. Col1,
var1.col2,
.
.
var6.col6
Of
tab1, tab2, tab2...
where
condition1,
condition2

.but its throwing an error of

ORA-06530: Reference to the composite uninitialized
ORA-06512: at "my_package", line 177

Can someone pls suggest? I know that a collection should iniialized before available. Is it the same thing with a record? If so, how.



Thank you

You can use the function to deal WITH

create or replace type my_type is object
(
    empno integer
  , ename varchar2(10)
)
/
show err
create or replace function my_function return my_type
as
  l_emp my_type;
begin
  select my_type(empno, ename) into l_emp
    from emp
   where empno = 7369;

   return l_emp;
end;
/
show err

with t
as
(
  select my_function as val
    from dual
)
select treat(val as my_type).empno as empno
     , treat(val as my_type).ename as ename
  from t;

Tags: Database

Similar Questions

  • Variable in which returns no rows

    Hello

    I'm sorry if this is a simple question but I must be missing something and I can not find the answer. I'm writing a very simple search, and when I get to the USER: P10_SEARCH (inside the SQL workshop pop up) it returns no rows, but when I change it to "where ut." USERNAME = 'USER' "without the double quote him returns the row for the USER username. I'm under APEX 3.2.0.00.27 in 10 Express. I looked at some examples of Oracle applications and I couldn't find my mistake, if someone could guide me in the right direction I'd appreciate it.


    Select ut. Username "username".
    ut. Username "username".
    ut. FIRST_NAME. ' ' || STH Last_name 'full name '.
    ut. DEPARTMENT "Department".
    c USER_TABLE
    where ut. USERNAME =: P10_SEARCH

    Hello
    If the USER name column is defined as a CHAR data type, then you will need to mount your binding variable (P10_SEARCH) being of the CHAR type.

    ....
    where a.USERNAME = cast( :P10_SEARCH as char(n)  )   --- where n is the same size as declared for USERNAME
    

    CITY

    Published by: city has on January 4, 2010 17:09

  • subquery returns no row in the main query, but hard returns the value of the master query

    Oracle 11g, Solaris SPARC 64-bit:

    This is the master query: its not to return all the lines

    Select count (*) in the sadmin.usr_mods where to_char (ts_id) in ((select to_char (rtrim (ltrim(TS_MODULES,','), ',')) in the sadmin.usr_rfc where TS_KINTANA_PACKAGE_NUMBER = '123' and ts_projectid = 3));

    COUNT (*)

    ----------

    0

    But wherever if I use subquery only returns he lines:

    SQL > select rtrim (ltrim(TS_MODULES,','), ',') from the sadmin.usr_rfc where TS_KINTANA_PACKAGE_NUMBER = '123' and ts_projectid = 3;

    RTRIM (LTRIM(TS_MODULES,','), ',')

    --------------------------------------------------------------------------------

    49,54

    If I use these values as hardcoded to a select master it will return 2 rows:

    SQL > select count (*) in the sadmin.usr_mods where to_char (ts_id) in ('49 ', ' 54');

    COUNT (*)

    ----------

    2

    TS_MODULES datatype is CLOB

    TS_ID datatype is set to number

    Help, please

    with

    usr_rfc as

    (select 3 ts_projectid, 123 ts_kintana_package_number, to_clob(',49,54,') ts_modules

    of the double

    ),

    usr_mods as

    (select ts_id 49 Union double all the)

    Select 50 in all double union

    Select double 54

    )

    Select count (*)

    of usr_mods

    where to_char (ts_id) in (select regexp_substr (to_char (rtrim (ltrim(TS_MODULES,','), ',')),'[^,] +', 1, level))

    of usr_rfc

    where TS_KINTANA_PACKAGE_NUMBER = '123'

    and ts_projectid = 3

    connect by level<= regexp_count(to_char(rtrim(ltrim(ts_modules,','),',')),',')="" +="">

    )

    COUNT (*)
    2

    Concerning

    Etbin

    Select count (*)

    of usr_mods

    where instr ((select ',' | to_char (rtrim (ltrim(TS_MODULES,','), ',')) |)) ','

    of usr_rfc

    where TS_KINTANA_PACKAGE_NUMBER = '123'

    and ts_projectid = 3

    ),

    ',' || TO_CHAR (TS_ID) | ','

    ) > 0

  • SQL / PLSQL practice review

    Hello
    I'm looking for SQL, PLSQL practice Exam questions.
    Can you get it someone please let me know where I can find these?

    Concerning
    FM

    Perhaps the [certificate Forum | http://forums.oracle.com/forums/forum.jspa?forumID=459] can help you.
    We are mostly just typing (PL /) here on this forum SQL and PL/SQL SQL statements ;-)

  • SQL query returning no rows, please help!

    I have a table that contains the user checks for a specific procedures alongwith the date stamp. Now, I want the list of all procedures that are not accessible by users in the last 6 months. Or, all of the procedures that have not been used/accessible during the last 6 months.

    That's what I'm trying, but is does not return all rows:

    SELECT DISTINCT proc_name,
    TRUNC (entry_date)
    OF log_web
    WHERE NOT IN (SELECT proc_name proc_name
    OF log_web
    WHERE TRUNC (entry_date) > TRUNC (SYSDATE - 180))
    ORDER BY DESC 2

    Please notify.
    Thank you in advance.

    Hello

    NOT IN never returns TRUE if the subquery returns NULL values. If proc_name doesn't have a NOT NULL constraint, change the subquery to

    WHERE        proc_name     NOT IN ( SELECT  proc_name
                                FROM      log_web
                         WHERE      entry_date     > TRUNC (SYSDATE - 180)
                         AND      proc_name     IS NOT NULL
                          )
    

    I don't see any other suspect.
    Post a small example of data (CREATE TABLE and INSERT statements) where the query produces results worng.

  • I need issue of SQL/PLSQL for practice

    Hi all

    I need to question of SQL/PLSQL for practice; could everything on send me the URL.

    I need only the PDF file.

    Thank you
    Gregory

    Here is the link for the link of PL/SQL oracle

    http://www.Oracle.com/pls/db111/portal.portal_db?selected=5&frame=

    IN the section of SQL and PL/SQL language, there is the language Pl/SQL.. PDF reference .you can download... its preety good to start.

  • Need help with a SQL qurey that returns multiple lines for a record?

    I have the following query where I use a WHEN clause CASES to determine the date of a change that starts with 'FRLO' on day 1 - day14 of the pay period. It works fine if a folder schedule with a day that begins "FRLO", but if more than one day is "FRLO" then it only returns the first day he finds and not others. Is there a way to get the query to return a ron for every day 1-14 that begins "FRLO"? System if Oracle 11 G
    The order of the results is not important, because this is part of a larger query that orders the results.

    Thanks in advance for any help,
    George
    ---------------------------------------------------------------------------------------------------------------------------------
    SELECT s.empid,
    CASE
    A SUPERIOR TIME (SUBSTR (s.Day1, 0, 4)) = "FRLO".
    THEN
    pp.startpp
    A SUPERIOR TIME (SUBSTR (s.Day2, 0, 4)) = "FRLO".
    THEN
    pp.startpp + 1
    A SUPERIOR TIME (SUBSTR (s.Day3, 0, 4)) = "FRLO".
    THEN
    pp.startpp + 2
    A SUPERIOR TIME (SUBSTR (s.Day4, 0, 4)) = "FRLO".
    THEN
    pp.startpp + 3
    A SUPERIOR TIME (SUBSTR (s.Day5, 0, 4)) = "FRLO".
    THEN
    pp.startpp + 4
    A SUPERIOR TIME (SUBSTR (s.Day6, 0, 4)) = "FRLO".
    THEN
    pp.startpp + 5
    A SUPERIOR TIME (SUBSTR (s.Day7, 0, 4)) = "FRLO".
    THEN
    pp.startpp + 6
    A SUPERIOR TIME (SUBSTR (s.Day8, 0, 4)) = "FRLO".
    THEN
    pp.startpp + 7
    A SUPERIOR TIME (SUBSTR (s.Day9, 0, 4)) = "FRLO".
    THEN
    pp.startpp + 8
    A SUPERIOR TIME (SUBSTR (s.Day10, 0, 4)) = "FRLO".
    THEN
    pp.startpp + 9
    A SUPERIOR TIME (SUBSTR (s.Day11, 0, 4)) = "FRLO".
    THEN
    pp.startpp + 10
    A SUPERIOR TIME (SUBSTR (s.Day12, 0, 4)) = "FRLO".
    THEN
    pp.startpp + 11
    A SUPERIOR TIME (SUBSTR (s.Day13, 0, 4)) = "FRLO".
    THEN
    pp.startpp + 12
    A SUPERIOR TIME (SUBSTR (s.Day14, 0, 4)) = "FRLO".
    THEN
    pp.startpp + 13
    END
    StartDate,
    StartTime, NULL,
    Time NULL terminator,
    8 hours,
    0 minutes
    Time S
    JOIN THE
    payperiods pp
    ON pp.periodid = s.periodid
    WHERE SUPERIOR (SUBSTR (s.Day1, 0, 4)) = "FRLO".
    OR SUPERIOR (SUBSTR (s.Day2, 0, 4)) = "FRLO".
    OR SUPERIOR (SUBSTR (s.Day3, 0, 4)) = "FRLO".
    OR SUPERIOR (SUBSTR (s.Day4, 0, 4)) = "FRLO".
    OR SUPERIOR (SUBSTR (s.Day5, 0, 4)) = "FRLO".
    OR SUPERIOR (SUBSTR (s.Day6, 0, 4)) = "FRLO".
    OR SUPERIOR (SUBSTR (s.Day7, 0, 4)) = "FRLO".
    OR SUPERIOR (SUBSTR (s.Day8, 0, 4)) = "FRLO".
    OR SUPERIOR (SUBSTR (s.Day9, 0, 4)) = "FRLO".
    OR SUPERIOR (SUBSTR (s.Day10, 0, 4)) = "FRLO".
    OR SUPERIOR (SUBSTR (s.Day11, 0, 4)) = "FRLO".
    OR SUPERIOR (SUBSTR (s.Day12, 0, 4)) = "FRLO".
    OR SUPERIOR (SUBSTR (s.Day13, 0, 4)) = "FRLO".
    OR SUPERIOR (SUBSTR (s.Day14, 0, 4)) = "FRLO";

    ----------------------------------------------------------------------------------------------
    OUTPUT CURRENT
    EMPID STARTDATE, STARTTIME ENDTIME HOURS MINUTES
    753738, 25/03/2013, 8, 0
    753740, 25/03/2013, 8, 0
    753748, 25/03/2013, 8, 0

    DESIREE OUTPUT
    EMPID STARTDATE, STARTTIME ENDTIME HOURS MINUTES
    753738, 25/03/2013, 8, 0
    753740, 25/03/2013, 8, 0
    753748, 25/03/2013, 8, 0
    753738, 26/03/2013, 8, 0
    753740, 26/03/2013, 8, 0
    753740, 28/03/2013, 8, 0
    753748, on 01/01/2013, 8, 0
    753738, on 03/04/2013, 8, 0
    753748, on 03/04/2013, 8, 0

    -----------------------------------------------------------------------------------------------
    CREATE THE TABLE PROGRAMS
    (
    SCHEDULEID NUMBER (12) NOT NULL,
    EMPID NUMBER (12) NOT NULL,
    PERIODID VARCHAR2 (6 BYTE) NOT NULL,
    AREAID NUMBER (12) NOT NULL,
    DAY1 VARCHAR2 (50 BYTE),
    DAY 2 VARCHAR2 (50 BYTE).
    DAY 3 VARCHAR2 (50 BYTE).
    DAY4 VARCHAR2 (50 BYTE),
    DAY5 VARCHAR2 (50 BYTE),
    DAY6 VARCHAR2 (50 BYTE),
    DAY 7 VARCHAR2 (50 BYTE).
    JOUR8 VARCHAR2 (50 BYTE),
    DAY9 VARCHAR2 (50 BYTE),
    DAY10 VARCHAR2 (50 BYTE),
    DAY 11 VARCHAR2 (50 BYTE).
    DAY12 VARCHAR2 (50 BYTE),
    J13 VARCHAR2 (50 BYTE),
    DAY14 VARCHAR2 (50 BYTE),
    NOPTIND1 INTEGER DEFAULT 0,
    NOPTIND2 INTEGER DEFAULT 0,
    NOPTIND3 INTEGER DEFAULT 0,
    NOPTIND4 INTEGER DEFAULT 0,
    NOPTIND5 INTEGER DEFAULT 0,
    NOPTIND6 INTEGER DEFAULT 0,
    NOPTIND7 INTEGER DEFAULT 0,
    NOPTIND8 INTEGER DEFAULT 0,
    NOPTIND9 INTEGER DEFAULT 0,
    NOPTIND10 INTEGER DEFAULT 0,
    NOPTIND11 INTEGER DEFAULT 0,
    NOPTIND12 INTEGER DEFAULT 0,
    NOPTIND13 INTEGER DEFAULT 0,
    NOPTIND14 INTEGER DEFAULT 0
    );

    CREATE TABLE PAYPERIODS
    (
    PERIODID VARCHAR2 (6 BYTE) NOT NULL,
    DATE OF STARTPP,
    DATE OF ENDPP
    );

    Insert in CALENDARS
    (SCHEDULEID, EMPID, PERIODID, DAY1, AREAID
    DAY 2, DAY 3, DAY 4, DAY5 DAY6.
    DAY7 JOUR8, DAY9, DAY10, DAY 11,.
    J13, DAY14 DAY12, NOPTIND1, NOPTIND2,
    NOPTIND3, NOPTIND4, NOPTIND5, NOPTIND6, NOPTIND7,
    NOPTIND8, NOPTIND9, NOPTIND10, NOPTIND11, NOPTIND12,
    NOPTIND13, NOPTIND14)
    Values
    (3693744, 753738, '082013' 2167, 'X')
    "FRLO < 1530 > ', ' < 1530 FRLO > ', '1530', '1530', '1530',
    'X', 'X', '1530', '1530', 'FRLO ',.
    "1530', '1530', 'X', 0, 0,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    (0, 0);
    Insert in CALENDARS
    (SCHEDULEID, EMPID, PERIODID, DAY1, AREAID
    DAY 2, DAY 3, DAY 4, DAY5 DAY6.
    DAY7 JOUR8, DAY9, DAY10, DAY 11,.
    J13, DAY14 DAY12, NOPTIND1, NOPTIND2,
    NOPTIND3, NOPTIND4, NOPTIND5, NOPTIND6, NOPTIND7,
    NOPTIND8, NOPTIND9, NOPTIND10, NOPTIND11, NOPTIND12,
    NOPTIND13, NOPTIND14)
    Values
    (3693745, 753740, '082013' 2167, 'X')
    "FRLO < 1530 > ', ' < 1530 FRLO > ', '1530', 'FRLO', '1530',
    'X', 'X', '1530', '1530', ' 1530',
    "1530', '1530', 'X', 0, 0,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    (0, 0);
    Insert in CALENDARS
    (SCHEDULEID, EMPID, PERIODID, DAY1, AREAID
    DAY 2, DAY 3, DAY 4, DAY5 DAY6.
    DAY7 JOUR8, DAY9, DAY10, DAY 11,.
    J13, DAY14 DAY12, NOPTIND1, NOPTIND2,
    NOPTIND3, NOPTIND4, NOPTIND5, NOPTIND6, NOPTIND7,
    NOPTIND8, NOPTIND9, NOPTIND10, NOPTIND11, NOPTIND12,
    NOPTIND13, NOPTIND14)
    Values
    (3693746, 753748, '082013' 2167, 'X')
    "FRLO < 1530 > ', '1530', '1530', '1530', '1530',.
    'X', 'X', ' FRLO < 1530 > ', '1530', 'FRLO ',.
    "1530', '1530', 'X', 0, 0,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    (0, 0);

    COMMIT;

    Insert into PAYPERIODS
    (PERIODID, STARTPP)
    Values
    (TO_DATE '082013', (MARCH 24, 2013 00:00:00 "," MM/DD/YYYY HH24:MI:SS'));))
    COMMIT;

    Hello

    I think you want:

    SELECT
      s.empid,
      pp.startpp,
      startdate,
      NULL starttime,
      NULL endtime,
      8 hours,
      0 minutes
    FROM schedules s
    JOIN payperiods pp
    ON pp.periodid = s.periodid
    WHERE UPPER (SUBSTR (s.Day1, 0, 4)) = 'FRLO'
    
    UNION
    SELECT
      s.empid,
      pp.startpp + 1,
      startdate,
      NULL starttime,
      NULL endtime,
      8 hours,
      0 minutes
    FROM schedules s
    JOIN payperiods pp
    ON pp.periodid = s.periodid
    WHERE UPPER (SUBSTR (s.Day2, 0, 4)) = 'FRLO'
    
    --ETC.
    

    Kind regards

    Peter

  • sql/PLSQL algorithm: is a rectangle filled with the other rectangles

    Hello
    I have 2 tables: T1 and T2:
    with T1 as
    (select 2 FromPeriod, 4 ToPeriod, 10 FromSum, 12 ToSum  from dual)
    select * from t1;
    
    
    with T2 as
    (select 1 FromPeriod, 2 ToPeriod, 9 FromSum, 5 ToSum  from dual
    union all
    select 1 FromPeriod, 3 ToPeriod, 9 FromSum, 4 ToSum  from dual
    union all
    select 2 FromPeriod, 5 ToPeriod, 9 FromSum, 11 ToSum  from dual
    union all
    select 2 FromPeriod, 5 ToPeriod, 11 FromSum, 12 ToSum  from dual)
    select * from t2;
    FromPeriod, ToPeriod are positive whole number without decimal point.
    FromSum, ToSum are positive numbers can have the comma.

    Table T1 contains unique in the columns 'FromPeriod-ToPeriod' points, that means that is there is a record where "FromPeriod-ToPeriod" = [2-4], then it is certainly not rendered as "FromPeriod-ToPeriod" = [1-4] keys wich [2-4] period, such a thing is not possible in table P1, it contains only unique periods that do not touch. Then the records with periods [2-4], [5-6] are ok in there.
    But table T2 allows periods affecting somehow. You can see that T2 contains "FromPeriod-ToPeriod" = [1-2] and also [1-3] that touch each other.

    We can look at the two tables T1 and T2 as rectangles where X - axis is the values of the axes and the "FromPeriod-ToPeriod" is [FromSum, ToSum].
    I need sql/plsql algorithm that returns true if the rectangle of table T1 is discovered/filled with rectangles in table T2. If the rectangle in T1 is completely filled or even more filled than necessary, then algorithm should return true. If even a small neighborhood in rectangle T1 is not filled by rectangles in T2, then the algorithm must return false.

    As see you in the sample data, T1 has a rectangle: [2-4; 10-12] T2 contains 4 mentions that fill/overdraw this area defined by T1. So for the moment the algorithm must return true.

    I do not know how to write effective elsewhere such algorithm, can you help me?

    --
    At the moment I only came with such algorithm/query:

    Test1: this test should return true:
    --query: is rectangle [2-4;10-12] filled? -Yes.
    with T2 as
    (select 1 FromPeriod, 2 ToPeriod, 9 FromSum, 5 ToSum  from dual
    union all
    select 1 FromPeriod, 3 ToPeriod, 9 FromSum, 4 ToSum  from dual
    union all
    select 2 FromPeriod, 5 ToPeriod, 9 FromSum, 11 ToSum  from dual
    union all
    select 2 FromPeriod, 5 ToPeriod, 11 FromSum, 12 ToSum  from dual)
    select * from t2
    where (2 <= ToPeriod and 4 >= FromPeriod) -- x-axes overlapping
    and (10 <= ToSum and 12 >= FromSum)--y-axes overlapping
    ;--2 rows
    
    --
    
    2     5     9     11
    2     5     11     12
    I takes as input the T1 table horizontal axes (2, [4]) and research data table T2 that affect this horizontal axes, also the value axes is compared. But how then? There are 2 files, but it can give 10 stores overlap in the periods and amounts. How to determine now that rectange T1 is filled?

    Test2: This case should return false:
    --query: is rectangle [2-4;10-12] filled? -No.
    with T2 as
    (select 1 FromPeriod, 2 ToPeriod, 9 FromSum, 4 ToSum  from dual
    union all
    select 1 FromPeriod, 3 ToPeriod, 9 FromSum, 4 ToSum  from dual
    union all
    select 2 FromPeriod, 4 ToPeriod, 9 FromSum, 11 ToSum  from dual
    union all
    select 2 FromPeriod, 5 ToPeriod, 13 FromSum, 13 ToSum  from dual)
    select * from t2
    where (2 <= ToPeriod and 4 >= FromPeriod) -- x-axes overlapping
    and (10 <= ToSum and 12 >= FromSum)--y-axes overlapping
    ;--1 row.
    
    2     4     9     11

    Charles,

    I see 2 choices, but none is likely to evolve very well. The first can be with SQL - subdivision T1 into unit squares and see if everything not covered by T2:

    with T1 as
    (select 2 FromPeriod, 4 ToPeriod, 10.1 FromSum, 12 ToSum  from dual)
    , T1X as
    (select (FromPeriod+level)-1 as Period from T1 connect by level <= (ToPeriod-FromPeriod)+1)
    , T1Y as
    (select (FromSum+level*.01)-.01 as Summ from T1 connect by level <= (ToSum-FromSum+.01)/.01)
    , T1XY as (select Period,Summ from T1X,T1Y)
    ,T2 as
    (select 1 FromPeriod, 2 ToPeriod, 9.99 FromSum, 10.1 ToSum  from dual--satisfies sub-region [(2,2);(10.1,10.1)]
    union all
    select 1 FromPeriod, 2 ToPeriod, 9.99 FromSum, 10.11 ToSum  from dual--now satisfied sub-regions: [(2,2);(10.1,10.11)
    union all
    select 2 FromPeriod, 2 ToPeriod, 10 FromSum, 12.01 ToSum  from dual--now satisfied sub-regions: [(2,2);(10.1,12)
    union all
    select 3 FromPeriod, 4 ToPeriod, 10 FromSum, 11.99 ToSum  from dual--now satisfied sub-regions: [(2,2);(10.1,12)],[(3,4);(10,11.99)]
    union all
    select 4 FromPeriod, 4 ToPeriod, 10 FromSum, 13 ToSum  from dual--now satisfied sub-regions: all filled, return true
    )
    select Period,Summ from T1XY
    where not exists (
    select 1
    from T2
    where T2.FromPeriod<=T1XY.Period
    and   T2.ToPeriod>=T1XY.Period
    and   T2.FromSum<=T1XY.Summ
    and   T2.ToSum>=T1XY.Summ
    )
    ;
    

    The second option is more inspiring you described, using a recursive algorithm to subdivide the T1 into small rectangles for each rectangle in T2. For example:

    X(1)={[a,b;c,d]}
    
    Y={[e,f;g,h];[i,j;k,l]}
    
    X(2)={[a,e;c,g];[e,f;c,g];[f,b;c,g];[a,e;g,h];[f,b;g,h];[a,e;h,d];[e,f;h,d];[f,b;h,d]}
    or
    X(2)={[a,b;c,g];[a,b;h,d];[a,e;c,d];[f,b;c,d]}  -- this gives some overlap, but fewer rectangles and the algorithm still works.
    
    You would have to refine it to handle partial overlaps correctly, then drop areas that don't have a positive area. If
    X(2) becomes empty then it is fully covered. It might be most efficient to sort T2 in order of descending area.
    

    Kind regards
    Bob

  • single line sub query returns multiple rows

    Hi, please help me to solve this, working with oracle 11g.


    Update t1 set t1.twyindex = twypoly (select twyindex from twyinfo where t1.id = t2.id t2);

    the error message is:
    *
    ERROR on line 1:
    ORA-01427: einreihig subquery returns multiple rows

    Thank you

    don123 wrote:
    Hi paul, thanks...

    duplicate existing due to the business logic data.

    can I use the SQL mentioned above for all cases?

    is it mandatory to remove duplicates?

    Please provide your suggestions...

    If the company says duplicates are allowed, you have to ask the person who wants what, of the different twyindexes, that they want to use
    updating twyinfo table...

    I use the SQL proposed until they tell you that twyindex to use.

  • Stupid old backpacker (me) cannot understand why this query returns 1 row

    Hi all

    In reference to {: identifier of the thread = 2456973}, why do
    select sum(count(decode(job, 'CLERK', 1, null))) CLERKS
    , sum(count(decode(job, 'SALESMAN', 1, null))) SALESMANS
    from emp group by job;
    only 1 rank and not 1 for each task? In fact, I had to test it myself to believe.

    It returns the data as if the query were
    select sum(CLERKS), sum(SALESMANS)
    from (select count(decode(job, 'CLERK', 1, null)) CLERKS, count(decode(job, 'SALESMAN', 1, null)) SALESMANS
             from emp group by job)
    Using only a single aggregate (count or sum) returns 1 row per job, as expected

    John Stegeman wrote:
    It returns the data as if the query were

    select sum(CLERKS), sum(SALESMANS)
    from (select count(decode(job, 'CLERK', 1, null)) CLERKS, count(decode(job, 'SALESMAN', 1, null)) SALESMANS
    from emp group by job)
    

    Exactly the point ;-)

    It seems that Oracle actually do, a group of 'double' in the same operation.
    Attend plans to explain in this example:

    SQL> select count(decode(job, 'CLERK', 1, null)) CLERKS
      2       , count(decode(job, 'SALESMAN', 1, null)) SALESMANS
      3  from scott.emp group by job;
    
        CLERKS  SALESMANS
    ---------- ----------
             0          0
             0          0
             0          0
             0          4
             4          0
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 1697595674
    
    ---------------------------------------------------------------------------
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------
    |   0 | SELECT STATEMENT   |      |     5 |    40 |     4  (25)| 00:00:01 |
    |   1 |  HASH GROUP BY     |      |     5 |    40 |     4  (25)| 00:00:01 |
    |   2 |   TABLE ACCESS FULL| EMP  |    14 |   112 |     3   (0)| 00:00:01 |
    ---------------------------------------------------------------------------
    

    And compare it to the one with the double aggregates:

    SQL> select sum(count(decode(job, 'CLERK', 1, null))) CLERKS
      2       , sum(count(decode(job, 'SALESMAN', 1, null))) SALESMANS
      3  from scott.emp group by job;
    
        CLERKS  SALESMANS
    ---------- ----------
             4          4
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 417468012
    
    ----------------------------------------------------------------------------
    | Id  | Operation           | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------
    |   0 | SELECT STATEMENT    |      |     1 |     8 |     4  (25)| 00:00:01 |
    |   1 |  SORT AGGREGATE     |      |     1 |     8 |     4  (25)| 00:00:01 |
    |   2 |   HASH GROUP BY     |      |     1 |     8 |     4  (25)| 00:00:01 |
    |   3 |    TABLE ACCESS FULL| EMP  |    14 |   112 |     3   (0)| 00:00:01 |
    ----------------------------------------------------------------------------
    

    There are GROUP BY hash and SORT GLOBAL times.

    It is really unnecessary to an aggregate on an aggregate - if two aggregates are used "in the same group level.
    Sum() aggregates are used on an already aggregated value, so it doesn't look like Oracle which actually cures like 'first do the internal aggregate using the group specified by and then do the external aggregation on the result with any group.'

    Look at this example where I combine aggregates "double" with "single" aggregates:

    SQL> select sum(count(decode(job, 'CLERK', 1, null))) CLERKS
      2       , sum(count(decode(job, 'SALESMAN', 1, null))) SALESMANS
      3       , count(decode(job, 'SALESMAN', 1, null)) SALESMANS2
      4       , count(*) COUNTS
      5  from scott.emp group by job;
    
        CLERKS  SALESMANS SALESMANS2     COUNTS
    ---------- ---------- ---------- ----------
             4          4          1          5
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 417468012
    
    ----------------------------------------------------------------------------
    | Id  | Operation           | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------
    |   0 | SELECT STATEMENT    |      |     1 |     8 |     4  (25)| 00:00:01 |
    |   1 |  SORT AGGREGATE     |      |     1 |     8 |     4  (25)| 00:00:01 |
    |   2 |   HASH GROUP BY     |      |     1 |     8 |     4  (25)| 00:00:01 |
    |   3 |    TABLE ACCESS FULL| EMP  |    14 |   112 |     3   (0)| 00:00:01 |
    ----------------------------------------------------------------------------
    

    When you mix "doubles" and "single" aggregates, Oracle decides that unique aggregates belong to the 'outer' aggregation
    SALESMAN2 did a count on the aggregated work column which is the result of the 'internal' group by - so only 1.
    The count (*) is also the result of the aggregation of the 'internal '.

    I don't know if it's documented or if it is an 'effect' of internal code used for GROUPING SETS or the internal code used to enable the analytical functions like this:

    SQL> select count(decode(job, 'CLERK', 1, null)) CLERKS
      2       , count(decode(job, 'SALESMAN', 1, null)) SALESMANS
      3       , sum(count(decode(job, 'CLERK', 1, null))) over () CLERKS2
      4       , sum(count(decode(job, 'SALESMAN', 1, null))) over () SALESMANS2
      5  from scott.emp group by job;
    
        CLERKS  SALESMANS    CLERKS2 SALESMANS2
    ---------- ---------- ---------- ----------
             0          0          4          4
             4          0          4          4
             0          0          4          4
             0          0          4          4
             0          4          4          4
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 4115955660
    
    ----------------------------------------------------------------------------
    | Id  | Operation           | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------
    |   0 | SELECT STATEMENT    |      |     5 |    40 |     4  (25)| 00:00:01 |
    |   1 |  WINDOW BUFFER      |      |     5 |    40 |     4  (25)| 00:00:01 |
    |   2 |   SORT GROUP BY     |      |     5 |    40 |     4  (25)| 00:00:01 |
    |   3 |    TABLE ACCESS FULL| EMP  |    14 |   112 |     3   (0)| 00:00:01 |
    ----------------------------------------------------------------------------
    

    Personally, I think that I would have preferred if Oracle has raised an error on this "double aggregation" and therefore require me to write this way (if it's the result I wanted):

    select sum(CLERKS), sum(SALESMANS)
    from (select count(decode(job, 'CLERK', 1, null)) CLERKS, count(decode(job, 'SALESMAN', 1, null)) SALESMANS
             from emp group by job)
    

    I don't really see a good use case for aggregations of 'double'-, but rather that he could give you undetected bugs in your code, if you happen to do double aggregation without noticing.

    Interesting thing to know ;-)

  • Interactive report that returns 0 rows on the initial screen of forcing

    How can I get the initial display of my interactive to have 0 rows (and quickly) reports on the initial display, so that the user can determine the lines they want without having to wait for the report view without much in the way of the filters?

    My reports many lines of 50-100 k with several joins of tables: so they are slow and the initial default result set is not useful for them, until they start of construction interactive filters themselves.

    I tried to add a default I / filter R which is never true, return 0 rows, but if I have good corrrectly, APEX will execute the sql 1, returning the default #of ranks backward, THEN that wraps like a subselect and applies to the i / R filters. So, I still have to wait for the report of 'run' before its filtered to 0 rows...

    I'm experimenting also with a flag of pxx_firsttime, intiall value, and according to my report SQL NVL(:Pxx_FIRSTTIME,'Y') = n and (rest of joins of tables)...
    the problem I have with this is, how can I get this option the value N as the user begins to use the interactive report filters, etc., which seem NOT to resubmit the page?

    Thank you

    Hello

    I tried to add a default I / filter R which is never true, return 0 rows, but if I have good corrrectly, APEX will execute the sql 1, returning back by default #of lines, THEN that wraps like a subselect and applies the > I / R filters. So, I still have to wait for the report of 'run' before its filtered to 0 rows...

    Yes, you are right.

    I assume that you already have using the paging Type as line from X to Y.

    the problem I have with this is, how can I get this option the value N as the user begins to use the interactive report filters, etc., which seem NOT to resubmit the page?

    Whenever the user do something with 'Actions', APEX IR will get updated. Thus, to create a dynamic Action that will be triggered before the refreshment of your IR, update the session state from P1_FIRSTTIME_FLAG to "n".

    Kind regards
    Hari

  • Installation fails for SQL Server SP 2 on SQL 2008 R2

    I have SQL 2008 R2 Developer Edition (64-bit) running Windows 7 (64-bit). I followed many workaround solutions listed on this forum all to no prevail!

    I noticed an error in the log in details:

    2010-12-22 06:02:08 Slp: error: Action "SqlEngineConfigAction_patch_configrc_Cpu64" failed during execution.
    2010-12-22 06:02:08 Slp: Action 'ConfigEvent_MPT_AGENT_CORE_CNI_sql_engine_core_inst_Cpu64_Patch_ConfigRC_postmsi' will return false because of the following conditions:
    2010-12-22 06:02:08 Slp: Condition "condition of dependence of the action starring: ConfigEvent_MPT_AGENT_CORE_CNI_sql_engine_core_inst_Cpu64_Patch_ConfigRC_postmsi the condition check function: MPT_AGENT_CORE_CNI_sql_engine_core_inst_Cpu64.» There are 2 characteristics of the dependant. The feature is tested for results: ValidateResult, result. "has failed because it has returned false and true was expected.
    2010-12-22 06:02:08 Slp: Condition is false, because the required functionality SQL_Engine_Core_Inst_sql_engine_core_inst_Cpu64 has failed in the result

    Hello

    Your question is more complex than what is generally answered in the Microsoft Answers forums. It is better suited for SQL server on Technet. Please ask your question in the Technet forum .

    Diana

    Microsoft Answers Support Engineer

    Visit our Microsoft answers feedback Forum and let us know what you think.

    If this post can help solve your problem, please click the 'Mark as answer' or 'Useful' at the top of this message. Marking a post as answer, or relatively useful, you help others find the answer more quickly.

  • Problem establish Oracle Database Gateway for SQL Server

    I configured dblink between Oracle and SQL Server by using the 'Oracle Database Gateway for SQL Server' method.

    I use dg4odbc and freetds, suite Doc-ID 561033.1 .

    I have my isql and osql works correctly, tsql.
    But get below error when query any table/column of Oracle sql * for the sql server database.

    Select subscription_type in Address@ITSMSP;

    ORA-28511: lost RPC connection to heterogeneous remote agent using SID = ORA-28511: lost CPP
    connecting to heterogeneous remote agent to help
    SID = (Description = (Address = (Protocol = TCP)(Host=localhost) (port = 1522)) (CONNECT_DATA = (SID = ITSM-Prod)))
    ORA-02063: preceding the line of ITSMSP


    As per below track appears after the connection is a failure.
    I get this error with each table or column selection.
    I already prepare DBlink user id and password with the double quotes and link with the apostrophe.
    One thing surprised me when I close my session it request commit or rollback.
    Although I don't do anything except select.
    I already tried by setting autocommit on, but still getting the same error.


    We create the oracle for sql server before database gateway. This time, few things are different:
    1. the name of the server (on sql server database) contains a '-' hyphen.
    2. name of database server Sql contain also one '-' hyphen.
    2 sql database server for windows 64 - bit OS, prior, we used 32 bits.

    Please let me know if anyone set the Oracle database gateway using dg4odbc and freetds to sql server where the database of sql server resident in 64-bit windows machine.


    Here's the snapshot trace: remove the server name with *.

    Oracle Corporation - Tuesday 2 April 2013 21:15:38.096

    Heterogeneous Agent release
    11.2.0.3.0

    Oracle Corporation - Tuesday 2 April 2013 21:15:38.096

    Version 11.2.0.3.0

    Hgogprd entries
    HOSGIP to 'HS_FDS_TRACE_LEVEL' returned '4 '.
    Hgosdip entries
    default assignment of 50 HS_OPEN_CURSORS
    setting HS_FDS_RECOVERY_ACCOUNT or 'RECOVER '.
    HS_FDS_RECOVERY_PWD layout to the default
    default HS_FDS_TRANSACTION_LOG of HS_TRANSACTION_LOG layout
    HS_IDLE_TIMEOUT layout to the default 0 value
    layout by default HS_FDS_TRANSACTION_ISOLATION of "READ_COMMITTED".
    layout by default «AL32UTF8» HS_NLS_NCHAR
    layout HS_FDS_TIMESTAMP_MAPPING default 'DATE '.
    layout HS_FDS_DATE_MAPPING default 'DATE '.
    layout HS_RPC_FETCH_REBLOCKING failure to 'ON '.
    HS_FDS_FETCH_ROWS layout without '100 '.
    parameter HS_FDS_RESULTSET_SUPPORT default 'FALSE '.
    parameter HS_FDS_RSET_RETURN_ROWCOUNT default 'FALSE '.
    parameter HS_FDS_PROC_IS_FUNC default 'FALSE '.
    parameter HS_FDS_MAP_NCHAR if there is no 'TRUE '.
    setting HS_NLS_DATE_FORMAT or 'YYYY-MM-DD HH24:MI:SS ".
    parameter HS_FDS_REPORT_REAL_AS_DOUBLE default 'FALSE '.
    HS_LONG_PIECE_TRANSFER_SIZE layout without "65536".
    parameter HS_SQL_HANDLE_STMT_REUSE default 'FALSE '.
    parameter HS_FDS_QUERY_DRIVER if there is no 'TRUE '.
    HOSGIP returned the value 'FALSE' to HS_FDS_SUPPORT_STATISTICS
    parameter HS_FDS_QUOTE_IDENTIFIER if there is no 'TRUE '.
    setting in HS_KEEP_REMOTE_COLUMN_SIZE if 'OFF '.
    parameter HS_FDS_GRAPHIC_TO_MBCS default 'FALSE '.
    parameter HS_FDS_MBCS_TO_GRAPHIC default 'FALSE '.
    Default value of 64 assumed for HS_FDS_SQLLEN_INTERPRETATION
    HS_CALL_NAME_ISP layout "gtw$: SQLTables; GTW$: SQLColumns. GTW$: SQLPrimaryKeys. GTW$: SQLForeignKeys. GTW$: SQLProcedures. GTW$: SQLStatistics; "gtw$: SQLGetInfo.
    parameter HS_FDS_DELAYED_OPEN if there is no 'TRUE '.
    HS_FDS_WORKAROUNDS layout by default "0".
    Release of hgosdip, rc = 0
    ORACLE_SID is ' *-* '.
    Product information:
    Port RLS / Upd:3 / 0 PrdStat:0
    Agent: Oracle Database Gateway for ODBC
    : Installation
    Class: ODBC, ClassVsn:11.2.0.3.0_0011, Instance: *-*.
    Release of hgogprd, rc = 0
    Hgoinit entries
    HOCXU_COMP_CSET = 1
    HOCXU_DRV_CSET = 31
    HOCXU_DRV_NCHAR = 873
    HOCXU_DB_CSET = 873
    HS_LANGUAGE is american_america.we8iso8859p1
    LANG is en_US. UTF-8
    HOCXU_SEM_VER = 112000
    Entry hgolofn to 2013/04/02-21: 15:38
    HOSGIP to 'HS_FDS_SHAREABLE_NAME' returned ' / usr/lib64/libodbc.so '.
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLAllocHandle
    symbol_peflctx = 0x2ca08300
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLBindCol
    symbol_peflctx = 0x2ca08390
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLBindParameter
    symbol_peflctx = 0x2ca08b50
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLCancel
    symbol_peflctx = 0x2ca09dc0
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLDescribeParam
    symbol_peflctx = 0x2ca11890
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLDisconnect
    symbol_peflctx = 0x2ca11d30
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLEndTran
    symbol_peflctx = 0x2ca14580
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLExecute
    symbol_peflctx = 0x2ca15a20
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLFetch
    symbol_peflctx = 0x2ca16220
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLFreeHandle
    symbol_peflctx = 0x2ca17c40
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLFreeStmt
    symbol_peflctx = 0x2ca17c60
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLGetData
    symbol_peflctx = 0x2ca19370
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLGetEnvAttr
    symbol_peflctx = 0x2ca1c4f0
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLGetFunctions
    symbol_peflctx = 0x2ca1c890
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLMoreResults
    symbol_peflctx = 0x2ca1e330
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLNumResultCols
    symbol_peflctx = 0x2ca1ef80
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLParamData
    symbol_peflctx = 0x2ca1f280
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLPutData
    symbol_peflctx = 0x2ca210b0
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLRowCount
    symbol_peflctx = 0x2ca21480
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLSetEnvAttr
    symbol_peflctx = 0x2ca22fc0
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLSetDescRec
    symbol_peflctx = 0x2ca22e10
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLColAttribute
    symbol_peflctx = 0x2ca0a3e0
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLColumns
    symbol_peflctx = 0x2ca0bb80
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLConnect
    symbol_peflctx = 0x2ca0f4f0
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLDescribeCol
    symbol_peflctx = 0x2ca11150
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLDriverConnect
    symbol_peflctx = 0x2ca12890
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLExecDirect
    symbol_peflctx = 0x2ca154b0
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLForeignKeys
    symbol_peflctx = 0x2ca16b40
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLGetConnectAttr
    symbol_peflctx = 0x2ca17fb0
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLGetDescField
    symbol_peflctx = 0x2ca199d0
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLGetDescRec
    symbol_peflctx = 0x2ca19e90
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLGetDiagField
    symbol_peflctx = 0x2ca1b060
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLGetDiagRec
    symbol_peflctx = 0x2ca1bc90
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLGetInfo
    symbol_peflctx = 0x2ca1cad0
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLGetStmtAttr
    symbol_peflctx = 0x2ca1d4d0
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLGetTypeInfo
    symbol_peflctx = 0x2ca1df90
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLPrepare
    symbol_peflctx = 0x2ca1f9b0
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLPrimaryKeys
    symbol_peflctx = 0x2ca1fec0
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLProcedureColumns
    symbol_peflctx = 0x2ca20470
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLProcedures
    symbol_peflctx = 0x2ca20b00
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLSetConnectAttr
    symbol_peflctx = 0x2ca21770
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLSetStmtAttr
    symbol_peflctx = 0x2ca24320
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLSetDescField
    symbol_peflctx = 0x2ca22b30
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLStatistics
    symbol_peflctx = 0x2ca258c0
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Entry hgolofns to 2013/04/02-21: 15:38
    LIBNAME=/usr/lib64/libodbc.so, funcname is SQLTables
    symbol_peflctx = 0x2ca26550
    hoaerr:0
    Out of hgolofns to 2013/04/02-21: 15:38
    Release of hgolofn, rc = 0 to 2013/04/02-21: 15:38
    HOSGIP to 'HS_OPEN_CURSORS' returned '50 '.
    HOSGIP to 'HS_FDS_FETCH_ROWS' returned '100 '.
    HOSGIP for "HS_LONG_PIECE_TRANSFER_SIZE" returned "65536".
    HOSGIP to 'HS_NLS_NUMERIC_CHARACTER' returned '. "
    HOSGIP to 'HS_KEEP_REMOTE_COLUMN_SIZE' returned 'OFF '.
    HOSGIP for "HS_FDS_DELAYED_OPEN" returns 'TRUE '.
    HOSGIP to 'HS_FDS_WORKAROUNDS' returned '0 '.
    HOSGIP to 'HS_FDS_MBCS_TO_GRAPHIC' returned 'FALSE '.
    HOSGIP to 'HS_FDS_GRAPHIC_TO_MBCS' returned 'FALSE '.
    Invalid value of 64 for HS_FDS_SQLLEN_INTERPRETATION
    treat_SQLLEN_as_compiled = 1
    Release of hgoinit, rc = 0 to 2013/04/02-21: 15:38
    Entry hgolgon to 2013/04/02-21: 15:38
    Reco:0, name: *, tflag:0
    Entry hgosuec to 2013/04/02-21: 15:38
    Release of hgosuec, rc = 0 to 2013/04/02-21: 15:38
    HOSGIP to 'HS_FDS_RECOVERY_ACCOUNT' returned 'RECOVER '.
    HOSGIP for "HS_FDS_TRANSACTION_LOG" returns "HS_TRANSACTION_LOG".
    HOSGIP to 'HS_FDS_TIMESTAMP_MAPPING' returned 'DATE '.
    HOSGIP to 'HS_FDS_DATE_MAPPING' returned 'DATE '.
    HOSGIP for "HS_FDS_MAP_NCHAR" returns 'TRUE '.
    HOSGIP to 'HS_FDS_RESULTSET_SUPPORT' returned 'FALSE '.
    HOSGIP to 'HS_FDS_RSET_RETURN_ROWCOUNT' returned 'FALSE '.
    HOSGIP to 'HS_FDS_PROC_IS_FUNC' returned 'FALSE '.
    HOSGIP to 'HS_FDS_REPORT_REAL_AS_DOUBLE' returned 'FALSE '.
    using the * as a default for 'HS_FDS_DEFAULT_OWNER '.
    HOSGIP to 'HS_SQL_HANDLE_STMT_REUSE' returned 'FALSE '.
    Entry hgocont to 2013/04/02-21: 15:38
    HS_FDS_CONNECT_INFO = ' *-* '.
    RC =-1 of HOSGIP for 'HS_FDS_CONNECT_STRING '.
    Entry hgogenconstr to 2013/04/02-21: 15:38
    DSN: *-*, name: *.
    OPTN:
    Entry hgocip to 2013/04/02-21: 15:38
    DSN: *-*.
    Release of hgocip, rc = 0 to 2013/04/02-21: 15:38
    # > connection settings (len = 39) < #.
    ## DSN=****-****;
    #! UID = *;
    #! PWD = *.
    Release of hgogenconstr, rc = 0 to 2013/04/02-21: 15:38
    Entry hgolosf to 2013/04/02-21: 15:38
    ODBC function-available-table 0xFFFE 0x00FF 0xFF00 0x03FF 0xFB7F 0x0000
    0x0000 0x0000 0x0000 0x0000 0x0000 0x0000
    0x0000 0x0000 0x0000 0x0000 0x0000 0x0000
    0x0000 0x0000 0x0000 0x0000 0x0000 0x0000
    0x0000 0x0000 0x0000 0x0000 0x0000 0x0000
    0x0000 0x0000 0x0000 0x0000 0x0000 0x0000
    0x0000 0x0000 0x0000 0x0000 0x0000 0x0000
    0x0000 0x0000 0x0000 0x0000 0x0000 0x0000
    0x0000 0x0000 0x0000 0x0000 0x0000 0x0000
    0x0000 0x0000 0x0000 0x0000 0x0000 0x0000
    0x0000 0 x 0000 0xFE00 0x3F5F
    Release of hgolosf, rc = 0 to 2013/04/02-21: 15:38
    DriverName:libtdsodbc.so, DriverVer:0.91
    DBMS name: Microsoft SQL Server DBMS Version: 95.10.0255
    Release of hgocont, rc = 0 to 2013/04/02-21: 15:38
    SQLGetInfo Returns Y for SQL_CATALOG_NAME
    SQLGetInfo Returns 128 for SQL_MAX_CATALOG_NAME_LEN
    Release of hgolgon, rc = 0 to 2013/04/02-21: 15:38
    Entry hgoulcp to 2013/04/02-21: 15:38
    Entry hgowlst to 2013/04/02-21: 15:38
    Release of hgowlst, rc = 0 to 2013/04/02-21: 15:38
    SQLGetInfo returns 0x1f for SQL_OWNER_USAGE
    Able TXN: isolation 2, Option: 0xf
    SQLGetInfo Returns 128 for SQL_MAX_SCHEMA_NAME_LEN
    SQLGetInfo Returns 128 for SQL_MAX_TABLE_NAME_LEN
    SQLGetInfo returns 134 to SQL_MAX_PROCEDURE_NAME_LEN
    HOSGIP returned the value "TRUE" to HS_FDS_QUOTE_IDENTIFIER
    SQLGetInfo returns "(0 x 22) for SQL_IDENTIFIER_QUOTE_CHAR"
    instance 2 capabilities will be uploaded
    context: 0x00000000, capno:1989, add info: 0
    context: 0x0001ffff, capno:1992, add info: 0
    Release of hgoulcp, rc = 0 to 2013/04/02-21: 15:38
    Entry hgouldt to 2013/04/02-21: 15:38
    NO translation of DD for instance have been downloaded
    Release of hgouldt, rc = 0 to 2013/04/02-21: 15:38
    Entry hgobegn to 2013/04/02-21: 15:38
    tflag:0, original: 1
    Hoi:0x4093b4c8, ttid (len 38) is...
    00: 54415058 2E435245 49474854 4F4E2E45 [TAPX]
    10: 44552E33 61383332 3362322E 312E3233 [3a8323b2.1.23]
    20: 2E323037 3631 [. 20761]
    tbid (len 35) is...
    00: 54415058 2E435245 49474854 4F4E2E45 [TAPX]
    10: 44555 B 31 2E32332E 32303736 315D5B31 [[1.23.20761] [1]]
    [20: 2E345D [. 4]]
    Release of hgobegn, rc = 0 to 2013/04/02-21: 15:38
    Entry hgodtab to 2013/04/02-21: 15:38
    number: 1
    Table: address
    Allocate hoada [0] @ 0x14eedc70
    Hoada free [0] @ 0x14eedc70
    SQL text of hgodtab, id = 0, len = 23...
    00: 73656C 65 6374202A 6 202241 2066726F [select * 'a]
    10: 64647265 737322 [prepare]"
    Entry hgodscr_process_sellist_description to 2013/04/02-21: 15:38


    Thanks a lot for your help.
    PAL

    Published by: 997807 on April 3, 2013 07:26

    Hello
    Thanks for the information. 2.2 UnixODBC driver manager is quite old and there is now one more late 2.3.1 version available here.

    http://www.unixODBC.org/

    by clicking on the tab "Download".
    Can you download and install this version then use in the configuration instead of the 2.2 version?

    Kind regards
    Mike

  • query by returning no rows

    Hi all
    This query returns all rows, but ideally it should.below I enclose the query
    select * FROM SERIAL_NO WHERE  serialno not in (SELECT SERIALNO FROM COB_T_SERIAL_NO
                                                                                union select serialno from genealogy
                                                                                union select lastarchivedby from genealogy
                                                                                union select serialno from asset
                                                                                union select serialno from code_serial_number
                                                                                union select serialno from cost
                                                                                union select serialno from cost_detail
                                                                                union select serialno from disposition
                                                                                union select serialno from disposition_content
                                                                                union select serialno from disposition_line
                                                                                union select serialno from disposition_test_reason
                                                                                union select serialno from inventory_count_serial_no
                                                                                union select serialno from inventory_serial_no
                                                                                union select serialno from inventory_serial_transit
                                                                                union select serialno from material_order_serial_no
                                                                                union select serialno from material_content_serial_no
                                                                                union select serialno from resource_content
                                                                                union select serialno from receipt_container_serial_no
                                                                                union select serialno from resource_serial_no
                                                                                union select serialno from sequence_queue_item
                                                                                union select serialno from serial_no_hold
                                                                                 union select serialno from wip_order_content_serial
                                                                                 union select serialno from wip_serial_no
                                                                                 union select serialno from wip_serial_no_content
                                                                                 union
                                                                                 select a.serialno from resource_labor_detail a  inner join resource_labor_detail_approval b on b.resourcelabordetailid=a.id
                                                                                  union
                                                                                  select c.serialno from labor_detail c inner join labor_detail_approval d on d.labordetailid = c.id
                                                                                   union 
                                                                                   select e.serialno from disposition_reading e  inner join disposition_resource f on f.dispositionreadingid = e.id                              
                                                                                   union select g.serialno from quality_defect g 
                                                                                    inner join   quality_defect_location h on h.qualitydefectid=g.id 
                                                                                    inner join quality_defect_loc_dimension i on i.qualitydefectlocationid=h.id )                          
                                                                                    
                                                                                                                 
                                                                                                                 

    Hello

    964145 wrote:
    right... I understand that it is difficult for you to help without data... it is syntactically correct?

    Yes, the syntax is very well. The fact that it runs (no matter how many rows it returns, if any) tells you that there is no syntax error.

    also, I want only distinct values, so I used the union rather than union all the

    Why do you want only the distinct values? The reulsts will be the same if there are duplicates or not.

    can I use like this? Please suggest

    with union_data as (SELECT SERIALNO FROM COB_T_SERIAL_NO
    union select serialno from genealogy
    ...
    inner join quality_defect_loc_dimension i on i.qualitydefectlocationid=h.id )           
    
    DELETE serial_no where serialno not in  (SELECT  serialno
    FROM    union_data
    WHERE   serialno    IS NOT NULL
    ) ;
    

    What happens when try you it?

    A query can start with the keyword WITH.
    A DELETE statement cannot.
    You can do soemthing like this:

    DELETE  serial_no
    WHERE     serialno   NOT IN  (
                                 WITH    union_data   AS
                          (
                              SELECT  serialno   FROM  cob_t_serial_no   UNION
                           SELECT  serialno   FROM  genealogy            UNION ...
                          )
                                 SELECT  serialno
                                  FROM    union_data
                                  WHERE   serialno    IS NOT NULL
                               ) ;
    

    Published by: Frank Kulash, November 12, 2012 16:22

  • Max returns two rows

    select BOND_SCHED_ID,bond_id,earnings_proceeds,max(s.effective_date) as effective_date
    from XXDL.xxdl_cd_bond_schedk_p2b  s
    Group by BOND_SCHED_ID,bond_id,earnings_proceeds
    Table has two rows it returns two rows. I need to have a single folder
    Actual
    
    10020     7     200     01-FEB-11
    10000     7     100     01-JAN-11
    
    Expected
    10020     7     200     01-FEB-11
    What is the best application I can write

    893185 wrote:

    Table has two rows it returns two rows. I need to have a single folder

    According to what criteria? I'll assume last effective_date for the connection id. If so:

    select  bond_sched_id,
            bond_id,
            effective_date
      from  (
             select  s.*,
                     row_number() over(partition by bond_id order by effective_date desc) rn
               from  XXDL.xxdl_cd_bond_schedk_p2b s
            )
      where rn = 1
    /
    

    SY.

Maybe you are looking for