Select query having count function is returning null
Hi Everyone,
Please see the query and help me to get this solved.
DB version
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
"CORE 10.2.0.1.0 Production"
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - ProductionQUERY
SELECT COUNT(*) as V_COUNT
FROM LAB_ORDER_TMPLT_TEST
WHERE TEST_ID IN
(SELECT WEST_TEST_ID
FROM TEST_CODE_CONVERSION TCC
WHERE TCC.EAST_TEST_ID = 2769)
GROUP BY LAB_ORDER_TMPLT_ID
HAVING COUNT(*) > 1;
It's returning null. Is there any way I can get the value as zero instead of null? Please help.Regards,
BS2012.
Hi,
BS2012 wrote:
Hi Everyone,
Please see the query and help me to get this solved.
DB version
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
"CORE 10.2.0.1.0 Production"
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - ProductionQUERY
SELECT COUNT(*) as V_COUNT
FROM LAB_ORDER_TMPLT_TEST
WHERE TEST_ID IN
(SELECT WEST_TEST_ID
FROM TEST_CODE_CONVERSION TCC
WHERE TCC.EAST_TEST_ID = 2769)
GROUP BY LAB_ORDER_TMPLT_ID
HAVING COUNT(*) > 1;
It's returning null.
Really? COUNT never returns NULL; it always returns 0 or a positive integer.
Do you mean the query results in "no rows selected"?
Is there any way I can get the value as zero instead of null? Please help.Do you want a query that will produce the same output as the query above, but will produce a single row containing 0 when the query above does not produce anything? That sounds like a job for an outer join:
WITH original_query AS
SELECT COUNT(*) AS v_count
FROM lab_order_tmplt_test
WHERE test_id IN
( SELECT west_test_id
FROM test_code_conversion tcc
WHERE tcc.east_test_id = 2769
GROUP BY lab_order_tmplt_id
SELECT NVL (o.v_count, 0) AS v_count
FROM dual
LEFT OUTER JOIN original_query o ON o.v_count > 0
;If you'd care to post CREATE TABLE and INSERT statements for the sample data, then I could test this.
Similar Messages
-
Hello,
I've set up a region definition of type "SQL Query(PL/SQL function body return SQL query). In my query I make use of an "in" condition. When I populate :P755_INC_BARG_UNIT with a value of 0F (no quotes), I get the correct count. However, when I set :P755_INC_BARG_UNIT to 0F, 0E I get an invalid count. What do I have to set the page item to?
When running the query in TOAD, and setting :P755_INC_BARG_UNIT to the string inside the brackets (0F, 0E) I get the proper count.
The code I use is shown below. Any help would be appreciated,
Alex.
DECLARE
v_sql VARCHAR2(32767);
BEGIN
SELECT count(*) "cnts",
''Faculty data file IDs missing in appt table'' "err_type"
FROM hradmin.et_faculty_salary fs left outer join
hradmin.appointments appt
ON trim(fs.empl_id) = appt.emp_emp
and appt.ear_activ <> ''Z''
and appt.ear_type = ''F''
and (appt.ear_class in (''A'',''B'',''C'',''D''))
and appt.ear_bargunit in ( :P755_INC_BARG_UNIT )
WHERE appt.emp_emp is null
RETURN v_sql;
END;Alex,
try something like:
DECLARE
v_sql VARCHAR2(32767);
BEGIN
v_sql := <YOUR_SQL_STATEMENT_WITH_P755_INC_BARG_UNIT_IN_IT>;
v_sql := REPLACE(v_sql, ':P755_INC_BARG_UNIT',:P755_INC_BARG_UNIT);
RETURN v_sql;
END; But before doing it read this:
http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:210612357425
After reading you will be able to find the best solution yourself.
Lev -
SQL Query (PL/SQL function body returning SQL query) when using to_char
we are trying to build a report page of Type SQL Query (PL/SQL function body returning SQL query).
our query is so simple, we need to extract the month from the recording_date column.
declare
l_query varchar2(1000);
begin
l_query:='select to_char(recording_date,'MM')from re_productive';
return l_query;
end;
but we are having the following problem for this query
Function returning SQL query: Query cannot be parsed within the Builder. If you believe your query is syntactically correct, check the generic columns checkbox below the region source to proceed without parsing.
(ORA-06550: line 4, column 42: PLS-00103: Encountered the symbol "MON" when expecting one of the following: . ( * @ % & = - + ; < / > at in is mod remainder not rem <> or != or ~= >= <= <> and or like between || multiset member SUBMULTISET_ The symbol ". was inserted before "MON" to continue.)
Notes:
1-the query is correct and it was tested under Toad and SQL Plus.
2- we tried Use Generic Column Names (parse query at runtime only) option but we get the same problem.
any quick help please.Hi
You haven't escaped your quotes in the string. Try this...
DECLARE
l_query VARCHAR2(32767);
BEGIN
l_query:= 'select to_char(recording_date,''MM'') from re_productive';
RETURN l_query;
END;Cheers
Ben -
SQL Query (PL/SQL Function Body returning SQL query) doesn't return any row
I have a region with the following type:
SQL Query (PL/SQL Function Body returning SQL query).
In a search screen the users can enter different numbers, separated by an ENTER.
I want to check these numbers by replacing the ENTER, which is CHR(13) || CHR(10) I believe, with commas. And then I can use it like this: POD IN (<<text>>).
It's something like this:
If (:P30_POD Is Not Null) Then
v_where := v_where || v_condition || 'POD IN (''''''''||REPLACE(''' || :P30_POD || ''', CHR(13) || CHR(10), '','')||'''''''''')';
v_condition := ' AND ';
End If;
But the query doesn't return any rows.
I tried to reproduce it in Toad:
select * from asx_worklistitem
where
POD IN (''''||REPLACE('541449200000171813'||CHR(13) || CHR(10)||'541449206006341366', CHR(13) || CHR(10), ''',''')||'''')
==> This is the query that does't return any rows
select (''''||REPLACE('541449200000171813'||CHR(13) || CHR(10)||'541449206006341366', CHR(13) || CHR(10), ''',''')||'''')
from dual;
==> This returns '541449200000171813','541449206006341366'
select * from asx_worklistitem
where pod in ('541449200000171813','541449206006341366');
==> and when I copy/paste this in the above query, it does return my rows.
So why does my first query doesn't work?
Doe anyone have any idea?
Kind regards,
Geert
Message was edited by:
ZorryThanks for the help.
I made it work, but via the following code:
If (:P30_POD Is Not Null) Then
v_pods := REPLACE(:P30_POD, CHR(13) || CHR(10));
v_where := v_where || v_condition || 'POD IN (';
v_counter := 1;
WHILE (v_counter < LENGTH(v_pods)) LOOP
v_pod := SUBSTR(v_pods, v_counter, 18);
IF (v_counter <> 1) THEN
v_where := v_where || ',';
END IF;
v_where := v_where || '''' || v_pod || '''';
v_counter := v_counter + 18;
END LOOP;
v_where := v_where || ')';
v_condition := ' AND ';
End If;But now I want to make an update of all the records that correspond to this search criteria. I can give in a status via a dropdownlist and that I want to update all the records that correspond to one of these POD's with that status.
For a region you can build an SQL query via PL/SQL, but for a process you only have a PL/SQL block. Is the only way to update all these records by making a loop and make an update for every POD that is specified.
Because I think this will have a lot of overhead.
I would like to make something like a multi row update in an updateable report, but I want to specify the status from somewhere else. Is this possible? -
SQL Query ( PL/SQL function body returning query ) page
Hello Friends,
I have a page with type SQL Query ( PL/SQL function body returning query ).
I have written a pl/sql block that returns a sql query - select statment.
Some times i am getting no data found error - does it got to do with the variable that stores the query .
=======================
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
Error ERR-1101 Unable to process function body returning query.
OK
=====================
When the query is returned with records where exactly the records are stored is it in the variable declared in pl/sql block or with the Oracle Apex implicit cursor.
Here's the pl/sql block ..
The query is generated while the user is navigating through pages ..
====================
declare
l_return_stmt varchar2(32767);
l_select varchar2(32000);
l_from varchar2(32000);
l_where varchar2(32000);
l_order_by varchar2(32000);
l_stmt_recordcount varchar2(32000);
l_recordcount number ;
begin
l_select := 'select '||:P10_VARLIST1||:P10_VARLIST2||:P10_VARLIST3
||:P10_VARLIST4||:P10_VARLIST5;
l_from := ' from '||:P10_RELATION;
if length(:P10_WHERE) > 0 then
l_where := ' where '||:P10_WHERE;
else
l_where := '';
end if;
if length(:P10_ORDER_BY) > 0 then
l_order_by := ' order by '||:P10_ORDER_BY;
else
l_order_by := '';
end if;
l_return_stmt := l_select||l_from||l_where||l_order_by;
:P10_STMT := l_return_stmt;
return l_return_stmt;
end;
=============================
Appreciate your help in this regard.
thanks/kumar
Edited by: kumar73 on Apr 22, 2010 6:38 AMIt looks like the query string you are trying to pass back exceeds the 32K limit for a varchar. Where this is happening is kind of difficult to tell as it could be any number of points, and also depends on what you are passing into the process via page items.
I would first try to establish what combination of page items causes this error to occur. Then, starting from the bottom and working your way backwards, I would start 'switching off' some of the items you use to build your query until it breaks again, thus establishing which part is leading to the error.
Also, I'm not sure what :P10_STMT is doing (are you maybe using this for visiblity of the query created)?
It looks like the query string you are trying to pass back exceeds the 32K limit for a varchar. Where this is happening is kind of difficult to tell as it could be any number of points, and also depends on what you are passing into the process via page items.
I would first try to establish what combination of page items causes this error to occur. then, starting from the bottom and working your way backwards, I would start 'switching off' some of the items you use to build your query until it breaks again, thus establishing which part is leading to the error.
Also, I'm not sure what :P10_STMT is doing (are you maybe using this for visiblity of the query created)? -
SQL query (pl/sql function body returning query) performance issue
I create my report in building my sql instruction with ( SQL Query pl/sql function body returning sql query );
My report take more than 20 seconds however if i did a cut and paste with the sql code in TOAD the same sql take 1 second.
To try to discover the source of the problem; i take the sql generated by the function and i create another report ( sql query ) this new report take 2 seconds.
My query is very big 25,000 characters with database link.
What is the difference between SQL-quey and sql-query(pl/sql function body returning sql query)
Thanks
MarcMarc,
Firstly...don't compare the timings from Toad, since often Toad only fetches the first few records for you (i.e. it pages them).
Secondly....the database link could be a factor here, but without seeing your query it's too hard to say.
Can you post the query somewhere (on a webserver say)? -
SQL Query (pl/sql function body returning Sql query)
Hi All,
I have created a region of "SQL Query (pl/sql function body returning Sql query)" type and it is working fine , but when I am migrating(export /import) this application from development to systest environment ,
It gives error for this region :
Error ERR-1101 Unable to process function body returning query.
OK
ORA-06550: line 1, column 52: PLS-00306: wrong number or types of arguments in call to 'FU_TRADE_REPORT_QUERY' ORA-06550: line 1, column 45: PL/SQL: Statement ignored
Any pointer ...why this is happening.
Thanks
DikshitIf your function is a stored function that is called from within APEX (function body not coded into the app itself), have you made sure that the function has been created and compiles ok prior to installing your apex app.
If there are some dependency issues between other PL/SQL units or database objects that are causing your function not to be compiled, you apex install will fail as you are trying to reference an uncompelled bit of pl/sql.
Let me know how you get on
Regards
Duncan -
Problem with select query inside a function.
Hi,
i have created a function as
create or replace function "NEW"
(emp in number,
s_date in DATE,
e_date in DATE)
return number
is
v_alo number default 0;
v_alo2 number default 0;
v_date date;
begin
select sum(allocation_percent) into v_alo from employeeproject where start_date < s_date and end_date > e_date and pid != 'BPDE-KER12' and employee_id = emp;
select allocation_percent into v_alo2 from employeeproject where start_date < s_date and end_date > e_date and pid = 'BPDE-KER12' and employee_id = emp;
select max(end_date) into v_date from employeeproject where employee_id=emp having max(end_date) <= S_DATE;
if v_alo < 100 then
return 1;
else if v_alo2 = 100 then
return 2;
else if v_date < s_date then
return 3;
else
return 4;
end if;
end if;
end if;
exception
when NO_DATA_FOUND then
return 5;
end;it is compiled correctly.
when executing the function with
select abc.a,new(a,'03-jan-2011','04-jan-2011') "status" from abc where new(a,'03-jan-2011','04-jan-2011') in (1,2,3,4);it is returning
A status
1 5
2 5
3 5
instead of
A status
1 1
2 2
3 3
and when i comment any two select statements then some part of my ans is correct.
unable to understand the behaviour.
can any pls help me understand it.
Thanks,
hariHi,
thanks for the reply, and sorry for my ugly code.
i am using Oracle database 10g express edition.
Case could be a option to use but i need to figure why my query is not returning any value when used together.
my requirement is to find
the employees who are have allocation percent sum < 100 for a defined period(excluding pid=BPDE-KER12) and
employee who is mapped to pid=BPDE-KER12 not in my first requirement in that period and
the employees whose latest end date is less than the new start date.
i have tried the new modified code as you said but this time it returns null, not even exceptions running.
i divide my requirement into three functions which will return value.
1. create or replace function "NEW4"
(emp in number,
s_date in DATE,
e_date in DATE)
return number
is
v_alo number default 0;
v_alo2 number default 0;
v_date date;
begin
--to check if the employee total percentage is <100 then return 1 else return 4
select sum(allocation_percent) into v_alo from pm_employee_project
where
start_date < s_date and end_date > e_date and pid !='BPDE-KER12' and employee_id = emp;
if v_alo < 100 then
return 1;
elsif v_alo2 = 100 then
return 2;
elsif v_date < s_date then
return 3;
else
return 4;
end if;
exception
when NO_DATA_FOUND then
return 5;
end;
then,
select abc.a,NEW4(a,'03-jan-2011','30-jan-2011') "STATUS" from abc
result,
A STATUS
1 *1*
2 4
3 4 2.create or replace function "NEW5"
(emp in number,
s_date in DATE,
e_date in DATE)
return number
is
v_alo number default 0;
v_alo2 number default 0;
v_date date;
begin
--To select employee who are in a specific pid.
select allocation_percent into v_alo2 from pm_employee_project where
start_date < s_date and end_date > e_date and pid = 'BPDE-KER12' and
employee_id = emp;
if v_alo2 = 100 then
return 2;
elsif v_alo < 100 then
return 1;
elsif v_date < s_date then
return 3;
else
return 4;
end if;
exception
when NO_DATA_FOUND then
return 5;
end;
then,
select abc.a,NEW5(a,'03-jan-2011','30-jan-2011') "STATUS" from abc
Result,
A STATUS
1 5
2 *2*
3 5 3. create or replace function "NEW6"
(emp in number,
s_date in DATE,
e_date in DATE)
return number
is
v_alo number default 0;
v_alo2 number default 0;
v_date date;
begin
--to select the employee whose project end date is less thann the new date.
select max(end_date) into v_date from pm_employee_project where
employee_id=emp having max(end_date) <= S_DATE;
if v_alo2 = 100 then
return 2;
elsif v_alo = 100 then
return 1;
elsif v_date < s_date then
return 3;
else
return 4;
end if;
exception
when NO_DATA_FOUND then
return 5;
end;
then,
select abc.a,NEW6(a,'03-jan-2011','30-jan-2011') "STATUS" from abc
Result,
A STATUS
1 5
2 5
3 *3* so my function works properly individually, but i want all the three conditions in a single function with same order as above 1 then 2 and then 3.
and when i try to do it that way i am not getting my result as
A STATUS
1 *1*
2 *2*
3 *3*
so how can i proceed.
my input table values,
select * from abc
A B C
1 2 2
2 1 3
3 1 2
select * from pm_employee_project
varchar2 varchar2 date date date varchar2
EMPLOYEE_ID PID START_DATE END_DATE ALLOCATION_PERCENT SUPERVISOR_ID
1 10 02-JAN-11 31-JAN-11 89 -
1 20 05-JAN-11 20-JAN-11 9 -
1 BPDE-KER12 21-JAN-11 31-JAN-11 11 -
2 BPDE-KER12 01-JAN-11 31-JAN-11 100 -
3 30 01-JAN-10 01-JAN-11 100 -
BULK COLLECT in select query inside a function
Hi All,
My query is :
SELECT col1,col2,col3 FROM table_a; --( consider this is a long running query with lot of joins)
Need to know how can i get the output of the above query from a function using BULK COLLECT.
and i tried this:
CREATE OR REPLACE TYPE tab_a_row
AS OBJECT (
col1 number(20),
col2 number(20),
col2 number(20)) ;
create or replace type tab_a_nt as table of tab_a_row;
create or replace function get_table_a
return sys_refcursor
is
tab_a_recs tab_a_nt;
rv sys_refcursor;
begin
SELECT tab_a_row(col1,col2,col3) BULK COLLECT INTO tab_a_recs FROM table_a;
open rv for select * from table(tab_a_recs);
return rv;
end;
Function created successfully. and i exec this from sql plus using
SQL> var rc refcursor;
SQL> exec :rc := get_table_a;
BEGIN :rc := get_table_a; END;
ERROR at line 1:
ORA-22905: cannot access rows from a non-nested table item
ORA-06512: at "GET_TABLE_A", line 12
ORA-06512: at line 1
Kindly share your ideas on how to use bulk collect and get set of outputs from a function.
Edited by: 887268 on Apr 18, 2013 3:10 AM>
If i use refcursor , then the JAVA code needs to be changed accordinglyto get the refcursor output.
>
Well, of course. Java has to know what the sql projection is. How else will it know how many columns there are and their datatypes.
But that is true no matter what method you use.
>
But if i use a PLSQL COLLECTION TYPE (nested tables ) , then i can get output as ,
select * from table(function_name(input1,input2));
>
No - using the 'table' function mean you are calling a PIPELINED function.
This is a sample of a PIPELINED procedure.
-- type to match emp record
create or replace type emp_scalar_type as object
(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)
-- table of emp records
create or replace type emp_table_type as table of emp_scalar_type
-- pipelined function
create or replace function get_emp( p_deptno in number )
return emp_table_type
PIPELINED
as
TYPE EmpCurTyp IS REF CURSOR RETURN emp%ROWTYPE;
emp_cv EmpCurTyp;
l_rec emp%rowtype;
begin
open emp_cv for select * from emp where deptno = p_deptno;
loop
fetch emp_cv into l_rec;
exit when (emp_cv%notfound);
pipe row( emp_scalar_type( l_rec.empno, LOWER(l_rec.ename),
l_rec.job, l_rec.mgr, l_rec.hiredate, l_rec.sal, l_rec.comm, l_rec.deptno ) );
end loop;
return;
end;
select * from table(get_emp(20))Or your function could return a collection like the example from this thread this morning.
Example of Collection as datatype of a function’s return value
CREATE OR REPLACE TYPE enamelist as VARRAY(20) of VARCHAR2(20)
/* Formatted on 4/18/2013 4:06:47 PM (QP5 v5.126.903.23003) */
CREATE OR REPLACE FUNCTION ename_fn
RETURN enamelist
AS
v_cursor_main enamelist := enamelist ();
BEGIN
SELECT ename
BULK COLLECT
INTO v_cursor_main
FROM emp;
RETURN v_cursor_main;
EXCEPTION
WHEN OTHERS
THEN
RETURN v_cursor_main;
END;
select * from table(ename_fn()) from dual;
COLUMN_VALUE
SMITH
ALLEN
WARD
JONES
MARTIN
BLAKE
CLARK
SCOTT
KING
TURNER
ADAMS
JAMES
FORD
MILLER -
Getting count function to return 0 if no results found
I'm trying to determine the count of how many records exist that match a certain criteria. The problem is that instead of getting a row with a value of 0 when no results match, I get no row at all. This is causing me a problem because I need to know when it's zero as well as non-zero.
Here's an example query:
select submissions.job_id, count(submissions.job_id) from submissions where submissions.job_id in (select jobs.job_id from jobs where jobs.parent_id = 53) group by job_id
I'm trying to get the number of submissions for each job with a parent_id of 53. The problem is that if a job has no submissions, I don't even get the job_id back to report that it has 0 submission.
I'm using Oracle 8.1.6.
Any help is greatly appreciated.
RichI tried your suggested query and it has the same problem. If there are any jobs that don't have submissions related to them, that job_id is not returned in the list.
Here's what the query returned:
job_id count()
523 2
527 2
645 1
653 1
816 1
820 1
824 1
It's missing job_id 1029 which has a parent_id of 53 but has no submissions.
I'd like something like the following returned:
job_id count()
523 2
527 2
645 1
653 1
816 1
820 1
824 1
1029 0
Rich -
Querying PL/SQL function which returns SYS_REFCURSOR
Hello:
I have a PL/SQL function with return type of SYS_REFCURSOR.
In SQLPlus, I can query it either as
var c refcursor
exec :c := func(...)
print c
or
select func(...) from dual;
Running the latter in Eclipse 3.3 with oracle DTP extensions installed gives me OracleResultSetImpl object in the SQL Results view.
Can the code be a little smarter and recognize that a sql query may return "indirect" resultset?
Regards,
ErnestThis is noted; will be the interface better to handle the return values. Thanks
-
SQL select query having more than 1000 values in 'IN' clause of predicate.
Hi,
We are executing a select query from a table and showing it through a front end screen. When the count of values given in the 'IN' clause of predicate are exceeding 1000 , it is throwing error.
eg. select * from Employees where emp.Id. in('111',123','121','3232',........1001 Ids)
We are using Oracle version 10.2.0.
Please suggest how to tackle such issue.
Regards,
Naveen Kumar.C.
Edited by: Naveen Kumar C on Aug 30, 2008 10:01 PMUse a nested table:
create or replace type numbertype
as object
(nr number(20,10) )
create or replace type number_table
as table of numbertype
create or replace procedure tableselect
( p_numbers in number_table
, p_ref_result out sys_refcursor)
is
begin
open p_ref_result for
select *
{noformat} from employees
, (select /*+ cardinality(tab 10) */ tab.nr
from table(p_numbers) tab) tbnrs
where id = tbnrs.nr;
end;
/{noformat}
Using nested tables will reduce the amount of parsing because the sql statement uses binded variables! The cardinality hint causes Oracle to use the index on employees.id. -
How to create a DB Adapter with select query having inner query
Hi All,
I am trying to create a DB Adapter with select query. The query has some inner queries in it. It is just like this select a, b, c, (select d from e) d, (select e from e) e from tablename.
The problem here is with the xsd generated for this query. Xsd is not getting generated properly for all the fields it is just getting generated till c element and when it encounters
the inner query it is stopping the generation of xsd. So for the above query the xsd is something similar to the below
<xs:complexType name="rewOutput">
<xs:sequence>
<xs:element name="a" type="xs:string" nillable="true"/>
<xs:element name="b" type="xs:string" nillable="true"/>
<xs:element name="c" type="xs:string" nillable="true"/>
<xs:element name="select_d" type="xs:string" nillable="true"/>
</xs:sequence>
</xs:complexType>
as shown above the xsd is just getting generated till the first inner query. What should be done to get the full fledged xsd. Should it be manually built ?? Please help me on this.
Thanks In Advance.
Edited by: 959766 on Nov 30, 2012 1:20 AMHi,
I don't think the parser will be able to understand your query properly... I would try building the xsd manually...
Cheers,
Vlad -
Confusion in Select query having a inner join on single table
Hi,
I was going through coding and came a accross a select query which has a inner join on a single table. I am getting confused while analysing this . Please someone can help me analysing this query.
select
m~MATERIAL
s~NUMERATOR s~DENOMINTR
m~GROSS_WT m~UNIT_OF_WT
into table itab
from ( table1as s
inner join table1 as m
on m~MATERIAL = s~MATERIAL
and m~MAT_UNIT = 'CS'
and m~SOURSYSTEM = s~SOURSYSTEM )
where s~MAT_UNIT = 'EA'
and s~SOURSYSTEM = 'LD'
and s~OBJVERS = 'A'
and s~MATERIAL IN ( Select mat_sales
from Table2 group by mat_sales ).
Thank you
KusumaI don't see any use of the INNER JOIN here.
But what's the meaning of the last selection clause?
s~MATERIAL IN ( Select mat_sales
from Table2 group by mat_sales ).
Is that native SQL or something?
Pushpraj -
SQL Query (PL/SQL function body returning SQL query) Error
I'm an ApEx newbie, not a PL/SQL developer (more of a Web application developer) and I'm getting an error that prevents me from saving some PL/SQL code. I've looked over it all afternoon, but can't tell what's wrong. I may even be trying to do something inappropriately, or really stupid.
The code is below. The error I get is - "Function returning SQL query: Query cannot be parsed within the Builder". Any help is appreciated, and thanks in advance. If you need more details of what I'm trying to do let me know.
= = = = = = =
DECLARE
v_ID NUMBER;
v_SITE_ID NUMBER;
v_SITE_CODE VARCHAR2(15);
v_ADDR1 VARCHAR2(240);
v_CITY VARCHAR2(25);
v_STATE VARCHAR2(150);
v_ZIP VARCHAR2(20);
v_ORG_ID VARCHAR2(10);
BEGIN
IF :G_ORG_ID = '' THEN
SELECT "VENDOR_ID", "VENDOR_SITE_ID", "VENDOR_SITE_CODE", "ADDRESS_LINE1", "CITY", "STATE", "ZIP", "ORG_ID"
INTO v_ID, v_SITE_ID, v_SITE_CODE, v_ADDR1, v_CITY, v_STATE, v_ZIP, v_ORG_ID
FROM "PO_VENDOR_SITES_ALL_V"
WHERE ("VENDOR_ID" = :P4_VENDOR_ID);
ELSE
SELECT "VENDOR_ID", "VENDOR_SITE_ID", "VENDOR_SITE_CODE", "ADDRESS_LINE1", "CITY", "STATE", "ZIP", "ORG_ID"
INTO v_ID, v_SITE_ID, v_SITE_CODE, v_ADDR1, v_CITY, v_STATE, v_ZIP, v_ORG_ID
FROM "PO_VENDOR_SITES_ALL_V"
WHERE (("VENDOR_ID" = :P4_VENDOR_ID) AND ("ORG_ID" = :G_ORG_ID));
END IF;
END;Denes,
Good question.
Before I answer that question I'll give some detail on the application. That may help too. The application is a supplier search which searches the Oracle vendor tables (po.vendors, po_vendor_sites_all, po_vendor_contacts). The vendor/vendor site relationship is one to many. The site is based on the Org_ID. The supplier search is built to work solo, or to be called by another application. If it is called by another application one of the values passed is the Org_ID, so that only the sites that pertain to the user's org_id are shown. If the appl is called solo the Org_ID is not known, so the SQL should return all sites.
I figured the easiest way to check if the program was running solo or was called was to check the G_ORG_ID value in my PL/SQL that builds the site report. You helped me with that code. (I am hiding buttons by checking if the G_ORG_ID field is null and they display/hide properly.)
So, how is G_ORG_ID populated? It is on Page Zero, and is populated via the URL when the appl is called. (That aspect works great.) If it is called by another application G_ORG_ID is populated and my PL/SQL works. But, if the appl is called solo the field is not populated. When the PL/SQL runs I cannot get it to run the code for when G_ORG_ID is not populated.
I am at the point that I don't know if I need to populate G_ORG_ID in some way when the appl is running solo (kinda tricky, because I need to use that field to determine if it is running solo), or if I need to check it differently in the PL/SQL IF.
I have experimented with both the default value, and have checked for different values in the PL/SQL IF, but nothing works.
Thanks for your help, and let me know if you have any other questions on this matter.
Thanks, Tony
Maybe you are looking for
-
CALL_FUNCTION_RECIEVE_ ERROR ISSUE
Dear All, In Transaction code st22 i m getting dump error from past 2 days..CALL_FUNCTION_RECIEVE_ERROR.. user name :-ddic client:000 Details are:- Error when receiving answer to a Remote Function Call. What happened? Error in the SAP kernel. The cur
-
Where Are You @ Audition 4+???
Hello I really need to speak to the makers of audition. Your product is so great i cannot for the life of me see why your letting this product slip away. I have been using Adobe Audition my entire life. Your product allwos me to work faster and m
-
Entity Impl find by attribute value (not primary key)
Hello to all! In database there are three tables: users (userId, userName), groups (groupId, groupName) and link (linkId, userId, groupId) - this table uses for "many to many" connection. In application i created entitys and associations for each tab
-
Merge contact and facebook faces in iphoto
When I go to tag a person in iPhoto I get two choces....One is from facebook and the other is a contact. The facebook name is labeled Mary J. Frank Owen while the contact one is just Mary Frank Owen. The contact also has an email but the facebook o
-
Bootcamp - 32 or 64 bit Win7 on this Macbook?
Hi everybody- I have a late 2008 Macbook 5,1 with a 2.0GHz Processor and 4GB RAM. I want to install Windows7 so I can install and play a video game that is windows-only. The game website states what the system requirements are and I just meet the bar