From table hard coded in query
(1)The below query i have encounterd in the code for which i m handling CR.
kindly help me in understanding what does it means FROM TABLE inthe below
query..
select distinct transport_mode, orgp_id_2
into p_transport_mode, p_consignee_id
from packing_lists
where org_id = p_org_id
and id in(select * from table(pacc19.inlist(p_pal_ids)));
(2) In the below function i couldnt understand
typevar50 &
v_data.extend;
What could they be.?
FUNCTION inlist(
p_string IN VARCHAR2)
RETURN typevar50
IS
v_string LONG DEFAULT p_string || ',';
v_data typevar50 := typevar50();
v_position NUMBER;
BEGIN
LOOP
EXIT WHEN v_string IS NULL;
v_position := INSTR(v_string, ',');
v_data.extend;
v_data(v_data.COUNT) := LTRIM(RTRIM(SUBSTR(v_string, 1, v_position - 1)));
v_string := SUBSTR(v_string, v_position + 1);
END LOOP;
RETURN v_data;
END;
FUNCTION inlist(
p_string IN VARCHAR2,
p_delimeter IN VARCHAR2)
RETURN typevar50
IS
v_string LONG DEFAULT p_string || '~';
v_data typevar50 := typevar50();
v_position NUMBER;
BEGIN
LOOP
EXIT WHEN v_string IS NULL;
v_position := INSTR(v_string, '~');
v_data.extend;
v_data(v_data.COUNT) := LTRIM(RTRIM(SUBSTR(v_string, 1, v_position - 1)));
v_string := SUBSTR(v_string, v_position + 1);
END LOOP;
RETURN v_data;
END;
Kindly help
Reg.
AAK
Message was edited by:
460425
typevar50 is a Nested Table Type. The TABLE operator is used to treat this Nested Table Type as a regular table
SQL> create type nt as table of varchar2(10)
2 /
Type created.
SQL> declare
2 n nt;
3 begin
4 n := nt();
5 n.extend(3);
6 n(1) := 'Test1';
7 n(2) := 'Test2';
8 n(3) := 'Test3';
9 --
10 for rec in (select *
11 from table (cast (n as nt))
12 )
13 loop
14 dbms_output.put_line (rec.column_value);
15 end loop;
16 end;
17 /
Test1
Test2
Test3
PL/SQL procedure successfully completed.There's more information on Nested Tables here:
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_82a.htm#2064937
Message was edited by:
Alex Nuijten, changed the name of the nested table type
Similar Messages
-
User Logic for Conversion Type Instead of Hard coding in query.
Hello , Good response from SDN but thats all standard which I know. Please help me to resolve the problem as stated below. SDN friends are always best help.
Requirement: User will select the Target Currency; Will select the Exchange Rate like Monthly Avg 002M. Now there has to be a variable in Conversion which tells the logic to pick Conversion Type ZVHGR if Exchange Rate = 002M, but if Exchange Rate = 001, then Conversion Type ZVHMR.
<u><b>
Approach to solve abo</b></u>ve
1. I have created a Currency Translation Type " FiscperConversion" "ZVHGR" now this has Exchange Rate Type from Variable "ZVARN" (Which is a variable single value manual input on 0RTYPE Infoobject for exchange rate.)
2. Now Currency Tab: Target Currency is selected from Variable placed in the Report. ZRPVAR.
3. Now the Variable Time Reference is used. Standard Infoobject 0FISCPER
which is beginning of period.
Now all the above is done. Let go to the query and For Value of kEYFIGURE "Audit Balance" in Conversion Tab Conversion Type is specified is "FiscperConversion" ZVHGR"same as above and thats it. But the problem is here user want a variable that user can select the Conversion Type Instead of Hard coding.
<b>Please suggest how to create this variable for Conversion Type and specify in query designer since In Conversion Tab this is not allowed to have variable.</b>
Please help me very soon
Thanks
Soniya Kapoor
nullHello soniya
CTK ( currency translation key) includes
1. Exchange rate type - variable
2. Time base - Variable
3. Source abd TGT currency - variable
if all the things are given in variable why and what extra you need by selecting currency translation key from user input. I think you should ask business user again abt their requirement.
I can think of inputing CTK if say you have choosen time base as static ( Fix value)...say in one key u r using fiscal period as base and in other u r using calday as base...
Thanks
Tripple k -
Selecting all columns from table in a model query
I have written a model query which joins 4 tables, applies some rules and returns updated rows by selecting 4 columns out of this. Currently it works fine because all 4 columns are from MODEL aliases. Now I need to select 16 more columns in the same query but none of these columns is added in MODEL aliases. When I tried selecting these columns I got oracle error ORA - 32614. Can someone please guide me to include these columns in the same model query?
I tried couple of options but no luck. Here are those options for ready reference:
1. I cannot nest existing model query into another select because there are no columns avaiable to join in output of current query to map with other records.
2. I cannot include all 16 columns in MODEL aliases because some of these columns are actually output of user defined functions.
I am using Oracle database version 11g Release 11.2.0.1.0.
Edited by: Anirudha Dhopate on Jan 23, 2011 5:43 PMThank you Avijit for your reply. There is a syntax error on the ON in this part of the statement which I don't know how to fix - I tried messing around with another INNER JOIN but am not confident that I'm doing the right thing:
SENAlertType.SENAlertTypeIDONClassMember.ClassMemberStudentID
Thanks for your help! I will need to do some more bedtime reading on joins.
Daniel -
How could I replace hard coded value in my sql query with constant value?
Hi all,
Could anyone help me how to replace hardcoded value in my sql query with constant value that might be pre defined .
PROCEDURE class_by_day_get_bin_data
in_report_parameter_id IN NUMBER,
in_site_id IN NUMBER,
in_start_date_time IN TIMESTAMP,
in_end_date_time IN TIMESTAMP,
in_report_level_min IN NUMBER,
in_report_level_max IN NUMBER
IS
bin_period_length NUMBER(6,0);
BEGIN
SELECT MAX(period_length)
INTO bin_period_length
FROM bin_data
JOIN site_to_data_source_lane_v
ON bin_data.data_source_id = site_to_data_source_lane_v.data_source_id
JOIN bin_types
ON bin_types.bin_type = bin_data.bin_type
WHERE site_to_data_source_lane_v.site_id = in_site_id
AND bin_data.start_date_time >= in_start_date_time - numtodsinterval(1, 'DAY')
AND bin_data.start_date_time < in_end_date_time + numtodsinterval(1, 'DAY')
AND bin_data.bin_type = 2
AND bin_data.period_length <= 60;
--Clear the edr_class_by_day_bin_data temporary table and populate it with the data for the requested
--report.
DELETE FROM edr_class_by_day_bin_data;
SELECT site_to_data_source_lane_v.site_id,
site_to_data_source_lane_v.site_lane_id,
site_to_data_source_lane_v.site_direction_id,
site_to_data_source_lane_v.site_direction_name,
bin_data_set.start_date_time,
bin_data_set.end_date_time,
bin_data_value.bin_id,
bin_data_value.bin_value
FROM bin_data
JOIN bin_data_set
ON bin_data.bin_serial = bin_data_set.bin_serial
JOIN bin_data_value
ON bin_data_set.bin_data_set_serial = bin_data_value.bin_data_set_serial
JOIN site_to_data_source_lane_v
ON bin_data.data_source_id = site_to_data_source_lane_v.data_source_id
AND bin_data_set.lane = site_to_data_source_lane_v.data_source_lane_id
JOIN (
SELECT CAST(report_parameter_value AS NUMBER) lane_id
FROM report_parameters
WHERE report_parameters.report_parameter_id = in_report_parameter_id
AND report_parameters.report_parameter_group = 'LANE'
AND report_parameters.report_parameter_name = 'LANE'
) report_lanes
ON site_to_data_source_lane_v.site_lane_id = report_lanes.lane_id
JOIN (
SELECT CAST(report_parameter_value AS NUMBER) class_id
FROM report_parameters
WHERE report_parameters.report_parameter_id = in_report_parameter_id
AND report_parameters.report_parameter_group = 'CLASS'
AND report_parameters.report_parameter_name = 'CLASS'
) report_classes
ON bin_data_value.bin_id = report_classes.class_id
JOIN edr_rpt_tmp_inclusion_table
ON TRUNC(bin_data_set.start_date_time) = TRUNC(edr_rpt_tmp_inclusion_table.date_time)
WHERE site_to_data_source_lane_v.site_id = in_site_id
AND bin_data.start_date_time >= in_start_date_time - numtodsinterval(1, 'DAY')
AND bin_data.start_date_time < in_end_date_time + numtodsinterval(1, 'DAY')
AND bin_data_set.start_date_time >= in_start_date_time
AND bin_data_set.start_date_time < in_end_date_time
AND bin_data.bin_type = 2
AND bin_data.period_length = bin_period_length;
END class_by_day_get_bin_data;In the above code I'm using the hard coded value 2 for bin type
bin_data.bin_type = 2But I dont want any hard coded number or string in the query.
How could I replace it?
I defined conatant value like below inside my package body where the actual procedure comes.But I'm not sure whether I have to declare it inside package body or inside the procedure.
bin_type CONSTANT NUMBER := 2;But it does't look for this value. So I'm not able to get desired value for the report .
Thanks.
Edited by: user10641405 on May 29, 2009 1:38 PMDeclare the constant inside the procedure.
PROCEDURE class_by_day_get_bin_data(in_report_parameter_id IN NUMBER,
in_site_id IN NUMBER,
in_start_date_time IN TIMESTAMP,
in_end_date_time IN TIMESTAMP,
in_report_level_min IN NUMBER,
in_report_level_max IN NUMBER) IS
bin_period_length NUMBER(6, 0);
v_bin_type CONSTANT NUMBER := 2;
BEGIN
SELECT MAX(period_length)
INTO bin_period_length
FROM bin_data
JOIN site_to_data_source_lane_v ON bin_data.data_source_id =
site_to_data_source_lane_v.data_source_id
JOIN bin_types ON bin_types.bin_type = bin_data.bin_type
WHERE site_to_data_source_lane_v.site_id = in_site_id
AND bin_data.start_date_time >=
in_start_date_time - numtodsinterval(1, 'DAY')
AND bin_data.start_date_time <
in_end_date_time + numtodsinterval(1, 'DAY')
AND bin_data.bin_type = v_bin_type
AND bin_data.period_length <= 60;
--Clear the edr_class_by_day_bin_data temporary table and populate it with the data for the requested
--report.
DELETE FROM edr_class_by_day_bin_data;
INSERT INTO edr_class_by_day_bin_data
(site_id,
site_lane_id,
site_direction_id,
site_direction_name,
bin_start_date_time,
bin_end_date_time,
bin_id,
bin_value)
SELECT site_to_data_source_lane_v.site_id,
site_to_data_source_lane_v.site_lane_id,
site_to_data_source_lane_v.site_direction_id,
site_to_data_source_lane_v.site_direction_name,
bin_data_set.start_date_time,
bin_data_set.end_date_time,
bin_data_value.bin_id,
bin_data_value.bin_value
FROM bin_data
JOIN bin_data_set ON bin_data.bin_serial = bin_data_set.bin_serial
JOIN bin_data_value ON bin_data_set.bin_data_set_serial =
bin_data_value.bin_data_set_serial
JOIN site_to_data_source_lane_v ON bin_data.data_source_id =
site_to_data_source_lane_v.data_source_id
AND bin_data_set.lane =
site_to_data_source_lane_v.data_source_lane_id
JOIN (SELECT CAST(report_parameter_value AS NUMBER) lane_id
FROM report_parameters
WHERE report_parameters.report_parameter_id =
in_report_parameter_id
AND report_parameters.report_parameter_group = 'LANE'
AND report_parameters.report_parameter_name = 'LANE') report_lanes ON site_to_data_source_lane_v.site_lane_id =
report_lanes.lane_id
JOIN (SELECT CAST(report_parameter_value AS NUMBER) class_id
FROM report_parameters
WHERE report_parameters.report_parameter_id =
in_report_parameter_id
AND report_parameters.report_parameter_group = 'CLASS'
AND report_parameters.report_parameter_name = 'CLASS') report_classes ON bin_data_value.bin_id =
report_classes.class_id
JOIN edr_rpt_tmp_inclusion_table ON TRUNC(bin_data_set.start_date_time) =
TRUNC(edr_rpt_tmp_inclusion_table.date_time)
WHERE site_to_data_source_lane_v.site_id = in_site_id
AND bin_data.start_date_time >=
in_start_date_time - numtodsinterval(1, 'DAY')
AND bin_data.start_date_time <
in_end_date_time + numtodsinterval(1, 'DAY')
AND bin_data_set.start_date_time >= in_start_date_time
AND bin_data_set.start_date_time < in_end_date_time
AND bin_data.bin_type = v_bin_type
AND bin_data.period_length = bin_period_length;
END class_by_day_get_bin_data; -
Query runs slower when using variables & faster when using hard coded value
Hi,
My query runs slower when i use variables but it runs faster when i use hard coded values. Why it is behaving like this ?
My query is in cursor definition in a procedure. Procedure runs faster when using hard coded valus and slower when using variables.
Can anybody help me out there?
Thanks in advance.Hi,
Thanks for ur reply.
here is my code with Variables:
Procedure populateCountryTrafficDetails(pWeekStartDate IN Date , pCountry IN d_geography.country_code%TYPE) is
startdate date;
AR_OrgId number(10);
Cursor cTraffic is
Select
l.actual_date, nvl(o.city||o.zipcode,'Undefined') Site,
g.country_code,d.customer_name, d.customer_number,t.contrno bcn,
nvl(r.dest_level3,'Undefined'),
Decode(p.Product_code,'820','821','821','821','801') Product_Code ,
Decode(p.Product_code,'820','Colt Voice Connect','821','Colt Voice Connect','Colt Voice Line') DProduct,
sum(f.duration),
sum(f.debamount_eur)
from d_calendar_date l,
d_geography g,
d_customer d, d_contract t, d_subscriber s,
d_retail_dest r, d_product p,
CPS_ORDER_DETAILS o,
f_retail_revenue f
where
l.date_key = f.call_date_key and
g.geography_key = f.geography_key and
r.dest_key = f.dest_key and
p.product_key = f.product_key and
--c.customer_key = f.customer_key and
d.customer_key = f.customer_key and
t.contract_key = f.contract_key and
s.SUBSCRIBER_KEY = f.SUBSCRIBER_KEY and
o.org_id(+) = AR_OrgId and
g.country_code = pCountry and
l.actual_date >= startdate and
l.actual_date <= (startdate + 90) and
o.cli(+) = s.area_subno and
p.product_code in ('800','801','802','804','820','821')
group by
l.actual_date,
o.city||o.zipcode, g.country_code,d.customer_name, d.customer_number,t.contrno,r.dest_level3, p.product_code;
Type CountryTabType is Table of country_traffic_details.Country%Type index by BINARY_INTEGER;
Type CallDateTabType is Table of country_traffic_details.CALL_DATE%Type index by BINARY_INTEGER;
Type CustomerNameTabType is Table of Country_traffic_details.Customer_name%Type index by BINARY_INTEGER;
Type CustomerNumberTabType is Table of Country_traffic_details.Customer_number%Type index by BINARY_INTEGER;
Type BcnTabType is Table of Country_traffic_details.Bcn%Type index by BINARY_INTEGER;
Type DestinationTypeTabType is Table of Country_traffic_details.DESTINATION_TYPE%Type index by BINARY_INTEGER;
Type ProductCodeTabType is Table of Country_traffic_details.Product_Code%Type index by BINARY_INTEGER;
Type ProductTabType is Table of Country_traffic_details.Product%Type index by BINARY_INTEGER;
Type DurationTabType is Table of Country_traffic_details.Duration%Type index by BINARY_INTEGER;
Type DebamounteurTabType is Table of Country_traffic_details.DEBAMOUNTEUR%Type index by BINARY_INTEGER;
Type SiteTabType is Table of Country_traffic_details.Site%Type index by BINARY_INTEGER;
CountryArr CountryTabType;
CallDateArr CallDateTabType;
Customer_NameArr CustomerNameTabType;
CustomerNumberArr CustomerNumberTabType;
BCNArr BCNTabType;
DESTINATION_TYPEArr DESTINATIONTYPETabType;
PRODUCT_CODEArr PRODUCTCODETabType;
PRODUCTArr PRODUCTTabType;
DurationArr DurationTabType;
DebamounteurArr DebamounteurTabType;
SiteArr SiteTabType;
Begin
startdate := (trunc(pWeekStartDate) + 6) - 90;
Exe_Pos := 1;
Execute Immediate 'Truncate table country_traffic_details';
dropIndexes('country_traffic_details');
Exe_Pos := 2;
/* Set org ID's as per AR */
case (pCountry)
when 'FR' then AR_OrgId := 81;
when 'AT' then AR_OrgId := 125;
when 'CH' then AR_OrgId := 126;
when 'DE' then AR_OrgId := 127;
when 'ES' then AR_OrgId := 123;
when 'IT' then AR_OrgId := 122;
when 'PT' then AR_OrgId := 124;
when 'BE' then AR_OrgId := 132;
when 'IE' then AR_OrgId := 128;
when 'DK' then AR_OrgId := 133;
when 'NL' then AR_OrgId := 129;
when 'SE' then AR_OrgId := 130;
when 'UK' then AR_OrgId := 131;
else raise_application_error (-20003, 'No such Country Code Exists.');
end case;
Exe_Pos := 3;
dbms_output.put_line('3: '||to_char(sysdate, 'HH24:MI:SS'));
populateOrderDetails(AR_OrgId);
dbms_output.put_line('4: '||to_char(sysdate, 'HH24:MI:SS'));
Exe_Pos := 4;
Open cTraffic;
Loop
Exe_Pos := 5;
CallDateArr.delete;
FETCH cTraffic BULK COLLECT
INTO CallDateArr, SiteArr, CountryArr, Customer_NameArr,CustomerNumberArr,
BCNArr,DESTINATION_TYPEArr,PRODUCT_CODEArr, PRODUCTArr, DurationArr, DebamounteurArr LIMIT arraySize;
EXIT WHEN CallDateArr.first IS NULL;
Exe_pos := 6;
FORALL i IN 1..callDateArr.last
insert into country_traffic_details
values(CallDateArr(i), CountryArr(i), Customer_NameArr(i),CustomerNumberArr(i),
BCNArr(i),DESTINATION_TYPEArr(i),PRODUCT_CODEArr(i), PRODUCTArr(i), DurationArr(i),
DebamounteurArr(i), SiteArr(i));
Exe_pos := 7;
dbms_output.put_line('7: '||to_char(sysdate, 'HH24:MI:SS'));
EXIT WHEN ctraffic%NOTFOUND;
END LOOP;
commit;
Exe_Pos := 8;
commit;
dbms_output.put_line('8: '||to_char(sysdate, 'HH24:MI:SS'));
lSql := 'CREATE INDEX COUNTRY_TRAFFIC_DETAILS_CUSTNO ON country_traffic_details (CUSTOMER_NUMBER)';
execDDl(lSql);
lSql := 'CREATE INDEX COUNTRY_TRAFFIC_DETAILS_BCN ON country_traffic_details (BCN)';
execDDl(lSql);
lSql := 'CREATE INDEX COUNTRY_TRAFFIC_DETAILS_PRODCD ON country_traffic_details (PRODUCT_CODE)';
execDDl(lSql);
lSql := 'CREATE INDEX COUNTRY_TRAFFIC_DETAILS_SITE ON country_traffic_details (SITE)';
execDDl(lSql);
lSql := 'CREATE INDEX COUNTRY_TRAFFIC_DETAILS_DESTYP ON country_traffic_details (DESTINATION_TYPE)';
execDDl(lSql);
Exe_Pos:= 9;
dbms_output.put_line('9: '||to_char(sysdate, 'HH24:MI:SS'));
Exception
When Others then
raise_application_error(-20003, 'Error in populateCountryTrafficDetails at Position: '||Exe_Pos||' The Error is '||SQLERRM);
End populateCountryTrafficDetails;
In the above procedure if i substitute the values with hard coded values i.e. AR_orgid = 123 & pcountry = 'Austria' then it runs faster.
Please let me know why it is so ?
Thanks in advance. -
How to get the table name in the trigger definition without hard coding.
CREATE TRIGGER db.mytablename
AFTER UPDATE,INSERT
AS
INSERT INTO table1(col1)
SELECT InsRec.col1
FROM
INSERTED Ins
--Below i am calling one sp for which i have to pass the table name
EXEC myspname 'tablename'
In the above trigger,presently i am hard coding the tablename
but is it possible to get the table name dynamically on which the trigger is defined in order to avoid hard coding the table nameI really liked your audit table concept. You inspired me to modify it so that, the entire recordset gets captured and added a couple of other fields. Wanted to share my end result.
USE [YourDB]
GO
/****** Object: Trigger [dbo].[iudt_AutoAuditChanges] Script Date: 10/18/2013 12:49:55 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[iudt_AutoAuditChanges]
ON [dbo].[YourTable]
AFTER INSERT,DELETE,UPDATE
AS
BEGIN
SET NOCOUNT ON;
Declare @v_AuditID bigint
IF OBJECT_ID('dbo.AutoAudit','U') IS NULL BEGIN
CREATE TABLE [dbo].[AutoAudit]
( [AuditID] bigint identity,
[AuditDate] DateTime,
[AuditUserName] varchar(128),
[TableName] varchar(128) NULL,
[OldContent] XML NULL,
[NewContent] XML NULL
ALTER TABLE dbo.AutoAudit ADD CONSTRAINT
PK_AutoAudit PRIMARY KEY CLUSTERED
[AuditID]
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
CREATE NONCLUSTERED INDEX [idx_AutoAudit_TableName_AuditDate] ON [dbo].[AutoAudit]
( [TableName] ASC,
[AuditDate] ASC
)WITH (STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
END
Select * Into #AuditDeleted from deleted
Select * Into #AuditInserted from inserted
While (Select COUNT(*) from #AuditDeleted) > 0 OR (Select COUNT(*) from #AuditInserted) > 0
Begin
INSERT INTO [dbo].[AutoAudit]
( [AuditDate], [AuditUserName], [TableName], [OldContent], [NewContent])
SELECT
GETDATE(),
SUSER_NAME(),
[TableName]=object_name([parent_obj]),
[OldContent]=CAST((SELECT TOP 1 * FROM #AuditDeleted D FOR XML RAW) AS XML),
[NewContent]=CAST((SELECT TOP 1 * FROM #AuditInserted I FOR XML RAW) AS XML)
FROM sysobjects
WHERE
[xtype] = 'tr'
and [name] = OBJECT_NAME(@@PROCID)
Set @v_AuditID = SCOPE_IDENTITY()
Delete from AutoAudit
Where AuditID = @v_AuditID
AND Convert(varchar(max),oldContent) = Convert(varchar(max),NewContent)
Delete top(1) from #AuditDeleted
Delete top(1) from #AuditInserted
End
END -
SAP Query - Additional field that collects information from table RESB
Hello gurus. I have a question.
I want to create a SAP Query that shows me the stock level of a list of materials, and also show me the total quantity of order reservations in an additional field.
I created an InfoSet with table MARD, which is the one that holds the Stock information in a plant. Then I created an additional field which would read information from table RESB, the table that holds order reservations per material.
So I wrote this piece of code:
SELECT * FROM RESB
WHERE MATNR EQ MARD-MATNR and
WERKS EQ MARD-WERKS.
ENDSELECT.
if ( sy-dbcnt NE '0').
MOVE RESB-BDMNG to ZQTY.
ELSE.
MOVE '' to ZQTY.
ENDIF.
This works fine. However, this is currently just catching the first record in table RESB that matches my condition.
What I would like is to collect every instance of RESB-BDMNG and add them to field "ZQTY", have it loop in RESB until it finishes finding every record that match the MATNR and WERKS. With this I could get the total number of order reservations that this material has in that table.
Could someone share some coding that would help me achieve this?Yes! That did it. That's what I needed to do. Thank you so much.
While I'm at it, let me ask you a related question.
When I execute the query, in the first records of the query where there's no value from RESB to transfer, the value of field ZQTY appears empty. Once it finds the first record in RESB and it populates ZQTY with a value, then the rest of the records with no hit get the proper value of 0.
Do you know why the first records in the query appear empty and not with a 0? Is there anything I should add to the coding to fix this? -
Is is possible to avoid hard-coding the Item in a shared Select List Query?
I created a "Select List" in the Shared Components area as follows:
My goal is to create a shared select list that can be used on any form for a particular Field.
IF :P10_FK_RSTA_CODE is NULL THEN
RETURN
'select col_description, col_code_pk
from CODE_TABLE
where col_active_ind = ''Y''';
ELSE
RETURN
'select col_description, col_code_pk
from CODE_TABLE
where col_code_pk = :P10_FK_RSTA_CODE';
END IF
Which works great, but how can I make the select list work for the same column on a different form?
Because :P10_FK_RSTA_CODE is hard-coded in the function, I can't reuse this Function from a different form.
(I could rename the Field on every form to the same name, but I'm hoping there is a better way.)
Is there a way I can pass in a variable from the Field Item to make this dynamic where I can use it on any form?
Also, I am very new at this, so if there is a better way to do this, I would greatly appreciate any input.
Thanks in advance.
MF>
Welcome to the forum: please read the FAQ and forum sticky threads (if you haven't done so already), and update your profile with a real handle instead of "956902".
When you have a problem you'll get a faster, more effective response by including as much relevant information as possible upfront. This should include:
<li>Full APEX version
<li>Full DB/version/edition/host OS
<li>Web server architecture (EPG, OHS or APEX listener/host OS)
<li>Browser(s) and version(s) used
<li>Theme
<li>Template(s)
<li>Region/item type(s) (making particular distinction as to whether a "report" is a standard report, an interactive report, or in fact an "updateable report" (i.e. a tabular form)
With APEX we're also fortunate to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproducing things there is the best way to troubleshoot most issues, especially those relating to layout and visual formatting. If you expect a detailed answer then it's appropriate for you to take on a significant part of the effort by getting as far as possible with an example of the problem on apex.oracle.com before asking for assistance with specific issues, which we can then see at first hand.
I created a "Select List" in the Shared Components area as follows:
My goal is to create a shared select list that can be used on any form for a particular Field.
IF :P10_FK_RSTA_CODE is NULL THEN
RETURN
'select col_description, col_code_pk
from CODE_TABLE
where col_active_ind = ''Y''';
ELSE
RETURN
'select col_description, col_code_pk
from CODE_TABLE
where col_code_pk = :P10_FK_RSTA_CODE';
END IF
Which works great, but how can I make the select list work for the same column on a different form?
Because :P10_FK_RSTA_CODE is hard-coded in the function, I can't reuse this Function from a different form.
(I could rename the Field on every form to the same name, but I'm hoping there is a better way.)
Is there a way I can pass in a variable from the Field Item to make this dynamic where I can use it on any form?Reference the value of an application item rather than a page item in the LOV query, setting the value using a process or computation on each form page. -
Query to return list of all missing primary key ids from table T1
I found this query online that returns a start and stop for a range of all missing primary key id values from table T1. However i want to rewrite this query to return a whole list of all the missing primary key ids and not a start and stop range. any help plz?
select strt, stp
from (select m.id + 1 as strt,
(select min(id) - 1 from T1 x where x.id > m.id) as stp
from T1 m left outer join T1 r on m.id = r.id - 1 where r.id is null)x where stp is not nullwith t as
select 1 as id from dual union all
select 2 as id from dual union all
select 3 as id from dual union all
select 5 as id from dual union all
select 8 as id from dual union all
select 10 as id from dual union all
select 11 as id from dual union all
select 20 as id from dual
select id_start + level missing_id
from (
select id id_start,
nullif(lead(id) over(order by id) - 1, id) id_end
from t
start with id_end is not null
connect by prior id_start = id_start
and prior dbms_random.random is not null
and level <= id_end - id_start
MISSING_ID
4
6
7
9
12
13
14
15
16
17
18
MISSING_ID
19
12 rows selected.Or:
with t as
select 1 as id from dual union all
select 2 as id from dual union all
select 3 as id from dual union all
select 5 as id from dual union all
select 8 as id from dual union all
select 10 as id from dual union all
select 11 as id from dual union all
select 20 as id from dual
select id_start + level - 1 missing_id
from (
select min(id) id_start,
max(id) id_end
from t
connect by level <= id_end - id_start
minus
select id
from t
MISSING_ID
4
6
7
9
12
13
14
15
16
17
18
MISSING_ID
19
12 rows selected.SY. -
How can I filter a table from Data Control without enter query
I have a table from a web service data control based on WSDL.
I want to filter the table without input query at filter text box. Without filter text box, each would filter the table with a hardcoded query internally.
For example, when user click A menu button then it filters the table where type = '1' and B menu button filters the table by type='2' and C menu button filters the table by type=' ' .
How can I filter the table without enter query?
Could anyone point me to a solution please.
Thanks.
jdev 11.1.5
Edited by: 893364 on Oct 26, 2011 12:15 PM
Edited by: 893364 on Oct 26, 2011 12:21 PMHi,
when you created the table, did you try selecting the "filter" option. Select the table and go to the Property Inspctor. In the tool bar of the Property Inspector there is an icon to change the configuration. Its adding filter filter fields for the user to search in.
Option 2: The data of the Web Service actually is held in the iterators. If you wanted to filter the WebService query, I would not use the WS DC but a JAX-WS proxy in a POJO to fetch the WS Data. Then have the Data Control created from the POJO. You could have a method exposed on the POJO that allows you to filter the internally held data
Frank -
How to mention User specific fileshare as Hard coded value in DB table
I have a scenario like whenever the user clicks on Print, the application will generate a temp file Temp.txt and place it in fileshare location that is given in Database hard coded value as C:\Test, The problem here is when more than one user clicks on print button, the second user is getting error, as the same file is being used by first user.
To save the temp file, I want to mention a locaton something like "C:\Documents and Settings\<User Id>" where <user Id> will be '0001' for user one and '0002' for user two. (0001 and 0002 are suppose to be the user login name within the organisation). Is there anyway to specify the user id of the active user as a hard coded value?take the output of select user from dual; in a variable and then append that either with file name or with directory location..
-
How can i fetch records from 3 tables in a single query without using join
Hi.
Can any body please tell me <b>How can i fetch records from 3 tables with a single query without using joins</b>
Thanx
prabhuduttaHi Prabgudutta,
We can fetch the data by using the views concept.
Go throuth this info we can know the how to create view and same like database table only we can fetch the data.
Views conatin the data at runtime only.
Four different view types are supported. These differ in the
way in which the view is implemented and in the methods
permitted for accessing the view data.
Database views are implemented with an equivalent view on
the database.
Projection views are used to hide fields of a table (only
projection).
Help views can be used as selection method in search helps.
Maintenance views permit you to maintain the data
distributed
on several tables for one application object at one time.
step by step creation of Maintenance view:
With the help of the table maintenance generator, you are able to maintain the ENTRIES of the table in SM30 transaction.
It can be set in transaction SE11 - Tools - Table maintenance generator.
Table maintanance Generator is used to manually input values using transaction sm30
follow below steps
1) go to se11 check table maintanance check box under attributes tab
2) utilities-table maintanance Generator-> create function group and assign it under
function group input box. Also assign authorization group default &NC& .
3) select standard recording routine radio in table table mainitainence generator to move table
contents to quality and production by assigning it to request.
4) select maintaience type as single step.
5) maintainence screen as system generated numbers this dialog box appears when you click on create button
6) save and activate table
One step, two step in Table Maintenance Generator
Single step: Only overview screen is created i.e. the Table Maintenance Program will have only one screen where you can add, delete or edit records.
Two step: Two screens namely the overview screen and Single screen are created. The user can see the key fields in the first screen and can further go on to edit further details.
SM30 is used for table maintenance(addition or deletion of records),
For all the tables in SE11 for which Table maintenance is selected , they can be maintained in SM30
Sm30 is used to maintain the table ,i.e to delete ,insert or modify the field values and all..
It creates the maintenance screen for u for the aprticular table as the maintenance is not allowed for the table..
In the SE11 delivery and maintenance tab, keep the maintenance allowed..
Then come to the SM30 and then enter the table name and press maintain..,
Give the authorization group if necessary and give the function group and then select maintenance type as one step and give the screen numbers as system specified..
Then create,,,
Then u will able to see the maintenance view for the table in which u can able to insert and delete the table values...
We use SM30 transaction for entering values into any DB table.
First we create a table in SE11 and create the table maintenance generator for that Table using (utilities-> table maintenance generator) and create it.
Then it will create a View.
After that from SM30, enter the table name and Maintain, create new entries, change the existing entries for that table.
Hope this resolves your query.
Reward all the helpful answers.
Rgds,
P.Naganjana Reddy -
Hi,
I'm creating an ad hoc query to retrieve data from table PPDIT by filtering the transaction key. This is to get a list of amounts posted to the technical accounts(Transaction key HRA). However, the query output and the output from table PPDIT through SE16 are different. It seems like the query only picks up transaction key HRF. Anyone with any ideas why?Hi,
Than you add the additional field from extras option.
click on extras tab.
From there add table add field add structure.
If you want to add a field write the name of the field and continue.
suppose the field is matnr.
Long text = material number
header = material number
and in like reference = mara-matnr.
tablename-field name.
let me know if this helps you.
Regrds,
Nikhil. -
Query to conbine 2 lines from table
Hi all
I have a problem in constructing sql query to combine 2 lines from table in Oracle 11g database.
I will explain, i have one table containing call transactions loaded in one table from 2 different sources, one is from IN which is tagged IN and the other from MSC which is tagged MSC. One subscriber call is registered in IN and MSC and loaded in the table. The problem is the data from IN contains the call duration but not contains Cell information. I'm creating datamart to combine the two lines in one lines but i don't know how to do from query.
Here is an overview if my data:
Source Orig Dest startdate cellid duration
MSC 550000 220000 15/05/2012 02:03:29 235e
IN 550000 220000 15/05/2012 02:03:30 10
MSC 550000 220000 15/05/2012 02:04:00 235e
IN 550000 220000 15/05/2012 02:03:59 15
MSC 550000 220001 15/05/2012 02:06:18 235f
IN 550000 220001 15/05/2012 02:06:18 60
The line i want to have is for each line of IN source i sjhould have the cellid like below:
IN 550000 220000 15/05/2012 02:03:30 235e 10
IN 550000 220000 15/05/2012 02:03:59 235e 15
IN 550000 220001 15/05/2012 02:06:18 235f 60
The query should linked by Orig, Dest and date but for some rows there are difference in seconds.
Please help.
Lucienot.user13513449 wrote:
Hi
Thanks for the reply, here below the create table script and some insert data example:
CREATE TABLE TRANS
CALLTRANSTYPE NVARCHAR2(6),
ORIGANI NVARCHAR2(40),
TERMANI NVARCHAR2(40),
STARTTIME DATE,
STOPTIME DATE,
CELLID NVARCHAR2(10),
CONNECTSECONDS NUMBER,
SWITCHCALLCHARGE NUMBER
0 555283806 222591626 05/15/2012 00:10:04 05/15/2012 00:13:31 03e9:7565 O 207.00
Insert into trans values('MSG','555283806','222591626',to_date('05/15/2012 00:10:04','mm/dd/yyyy hh24:mi:ss'),to_date('05/15/2012 00:13:31','mm/dd/yyyy hh24:mi:ss'),'03e9:7565',10,null); ...It looks like there's some mistake at the end of the CREATE TABLE statement and before the first INSERT statement. Is that supposed to be another INSERT statement?
Test your code and, if necessary, correct it before you post it.
Is that sample data supposed to produce the results you posted originally?
If so, explain, step by step, ho9w you get them.
If not, post the results you want from that smaple data, formatted, between \ tags, as explained in the forum FAQ {message:id=9360002}
In my orioginal message, I said "ORDER BY" where I meant "GROUP BY". If you change that, and use your new table and column names, does the query I posted earlier do what you want? If not, point out where it is wrong, and show how you might get the right results in those places. -
Reason behind this query ,SELECT * FROM table WHERE 1 0
HEllo,
I would like to know the reason behind using this query ,
SELECT * FROM <table> WHERE 1 < 0
before executing the actual SQL query.
Is there any special reason or the JDBC receiver side is configured like that.
Is there any option to overcome this process like, can we remove this option or stop using this.
Why the JDBC adapter basically sending this query on the DB?
Thanks,
Soorya,Hi,
if you run this query, you wont be able to see any records of the table.
SELECT * FROM <table> WHERE 1 < 0
if you run this query you will see all records
SELECT * FROM <table> WHERE 0 < 1
same with SELECT * FROM <table> WHERE 1=1
So you can check this out that whats happening in your code before executing actual query. just try to co-relate.
regards
Aashish Sinha
PS : reward points if helpful
Maybe you are looking for
-
Hi srinivas bobbala, Thank you for your response.But I think my quesition was not clear.My ques... is for suppose there is one datafile for importing like.. "datafile_21" Here my intention is it takes file from datafile_21 only but it appears in impo
-
Ipad not sending email, forced to reboot for changes to apply
Hi all I was asked to look at a friends two week old iPad today. It was set up for them last week. Initially the person setting it up tried to add a Gmail account but found that it would receive but not send emails (using the native email app). They
-
How to create a foreign key for the table from two different tables?
Hi All, I have a three table like below. In the below table SAMPLE_CONS_CHECK and SAMPLE_CONS2_CHECK will be having the primary key for NAME column. The same SAMPLE_CONS3_CHECK table also having the primary key for NAME column and forieign key for SA
-
I can buy a 1T hd to store photos and videos to, but would need a second one to back that up as well? I guess I need to know how to get aperture and iphoto to keep my photos on a larger drive and how to keep both the imac and that larger hd backed u
-
I have a group of 3 Check Boxes for user to select their Work Shift: The check boxes are set up to be mutually exclusive (same name: "EMP_Shift", different Export Values: Day, Evening, Night). Form Field properties name: EMP_Shift (for all 3 ch