Pl/sql expression for default value
I'm trying to run this simple script as a default value using pl/sql expression, but I keep getting this error. THe select statement itself works fine as a sql statement source value, but will not work as a pl/sql exression as a default value. This (:P33_SYSUSERID_CREATED_BY ) is the field name on the form. Any ideas?
begin
select a.id || ', ' || A.NAME_LAST into :P33_SYSUSERID_CREATED_BY from S_USERSV a where a.name_last = 'HAMMAKER';
end;
Error ERR-9132 Error in PLSQL expression for item default code, item=P33_SYSUSERID_CREATED_BY
OK
ORA-06550: line 1, column 27: PLS-00103: Encountered the symbol "BEGIN" when expecting one of the following: ( - + case mod new not null avg count current exists max min prior sql stddev sum variance execute forall merge time timestamp interval date pipe
Sudha,
For a default value type of PL/SQL Expression, you could create a function that accepts an input and returns a value. If the function (not a procedure) is named GET_REFNO, you would call it using an expression in the default value field like:
get_refno(:P3_REFTYPE)
For a default value type of PL/SQL Function Body, you could call your existing procedure with a default value like:declare
l_value varchar2(32767);
begin
get_refno(:P3_REFTYPE, l_value);
return l_value;
end;Scott
Similar Messages
-
I'm trying to retrieve a file that is in the following format xxxxxxx_xxxxxx.YYYYMMDDHHMISS. I can't retrieve the file with the following sql command in the parameter "Expression for default for data" as
to_char(sysdate,'YYYYMMDDHHMISS') because my command is looking for a file that is transferred at that exact time, down to the second. I could pick up the file if it was named xxxxxxx_xxxxxx.YYYYMMDD and I used the command to_char(sysdate,'YYYYMMDD'). I can't use a wait event to pick up the file, because there is no scheduler associated with this server. When I try to use the wildcard * it cancels with an error and returns the name xxxxxx_xxxxxxx.YYYYMMDD*.
Do you know a command I could use in the "Expression for default for data" that would pick up the file in the following format: xxxxxxx_xxxxxxx.YYYYMMDDHHMISS.
Thanks,
Isaac BondsHi Isaac,
Well, the wait event obviously is the easiest, then you have the exact file name available from the event, even hours later still. But this does require a scheduler to be installed on that server indeed.
Given you do not use an event, how do you trigger this job now ? Do you use a polling mechanism ?
And what about the other side that is creating the file: can they send you an event or trigger file containing the actual file name that needs to be processed ?
Regards,
Anton Goselink. -
Account Creation - Badi for Default values for BP Role and Sales Area
Hi all,
my requirement regards the possibility to create a new prospect (a link should be available in the navigation bar or create section).
Logically, a bp role as "Prospect" and particoular sales area should be created automatically.
I created an implementation for the BADI definition "BADI_CRM_BP_UIU_DEFAULTS". But don't know how to create the default values for BP role and Sales area:
In my code
assign cr_me->('VIEW') to <lv_view_name>.
if sy-subrc ne 0.
exit.
endif.
lv_viewname = <lv_view_name>.
case lv_viewname.
when 'AccountDetails.htm'.
I obtain the viewname "AccountDetails" , the related context "Header". After I don't know how to proceed to obtain the related entities through the relationship BuilRolesRel and BuilSalesArrangementRel.
Am I following the right way? Is there another solution to prepare the output for default values?
Any kind of suggestion will be appreciated.
Regards, Robertogo to spro>cross-application components>sap busines partner>business partner> basic settings>field groupings>Configure Field Attributes per BP Role
Double click the business role which you want to customaze (e.g. 'A') and change the proper settings.
Regards. -
User Exit for default values in IW51
Hi All,
Can any suggest User Exit or BADI for default values like Cause code in IW51 Tcode.
Regards,
Samatha.Hi,
Please check these
Exits
IWO10026 User check on setting status 'Do not perform'
IWO10027 User exit: Generate user-defined settlement rule
IWOC0001 Create PM/SM notification: Determine reference object
IWOC0002 PM/SM notification: Check whether status change is allowed
IWOC0003 PM/SM authorization check of ref. object and planner group
IWOC0004 Change single-level list editing PM/QM/SM ALV settings
Business Add-in
IQS_MASS_CHANGE BadI for Mass Changes to Notifications
IQS0_STATUS_MAINTAIN Control of Changeability of User Status
NOTIF_AUTHORITY_01 Additional Authorization Checks for the Notification
WOC_FL_DETERMINE Determine Date for Determining Installation Loc. Equi.
IWOC_OBJECTINFO_CHNG Changes to Data of Object Info Screen
IWOC_LIST_TUNING Performance Tuning for Lists in PM/CS
IWO1_SUBSCREEN_0170 Display Additional Data on Object Screen 0170 PhysicalSample -
Please help me to stop my idea that Oracle is a Stupid Database.
I create a Table and I want to have a sequence for default value.
Oracle dont let me use the DEFAULT CONSTRAINT sentence to do that
and Oracle dont let me create a insert before trigger.
WHATS THE PROBLEM with Oracle.Oracle certainly allows you to create a BEFORE INSERT trigger on the table. There was Re: Auto generation of unique row ID a few days ago where I walked through setting this up.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Multiple single value for default value?!?
Hi guys,
by making a characteristic value variable how can I add more than one value (not interval) for default value? I cannot even add more value if the char. variable represents multiple single values...
Thx.Hi,
For that you can make use of customer exit variable.
else refer this link:[Variable with Multiple Default Values;
Regards,
Rajkandula -
Using expression in Default Value for Parameter in BI Publisher Model
Hi Everyone,
I have created a BI publisher data model with bind parameters. It works fine, however, I need to put a default value in the parameter that is the result of a query. I have a month and a year parameter and for month parameter, I want the default to be always the current month when the report is first opened. I put the sql query in the default column but it does not seem to work.
Any help is greatly appreciated,
Thanks,
DRLDid you get a resolution for this?
I might be able to use the solution -
How to dynamically create sql statement for Defaulting Segment Values?
Hi,
Navigation:
1) Descriptive/Segments
2) Query for DFF to be modified
3) Uncheck “Freeze Flexfield Definition”
4) (B) Segments
5) Segments Summary form opens
6) (B) open - Segments form opens
Now, here I want to specify Default type as "SQL Statement" and in the default value field I want to use SQL statement with parameters (to evaluate the default value).
The parameters should be pass at runtime from the form in which we have this DFF. The parameters value should be one of the values which get evaluated at runtime in the form window.
Please suggest how we can achieve this?
Or is there any alternative to achieve this?
Thanks!!
Regards,
Narender
Edited by: Narender Singh on Mar 30, 2010 7:47 AM
Edited by: Narender Singh on Mar 30, 2010 7:48 AMJason,
it is possible, though not so simple as with a report.
What you need to do is to create a pipelined function, that returns your date and count data. This pipelined function can be the base of a pseudo-table, which can be used in a select. For the pipelined function you need to define types for one row and a table to define the return-type for your function:
create or replace type calendar_row as object (date_time date, description varchar2(250));
create type calendar_table as table of calendar_row;
Then you can create the package with the function:
================================================
create or replace package dyn_calendar is
procedure set_query(i_query in varchar2);
function view_source return calendar_table pipelined;
end;
create or replace package body dyn_calendar is
v_query varchar2(100) := null;
procedure set_query(i_query in varchar2) is
begin
v_query := i_query;
end;
function view_source return calendar_table pipelined is
TYPE cursor IS REF CURSOR;
c_cal cursor;
v_date_time date := null;
v_description varchar2(100) := null;
r_cal calendar_row;
begin
open c_cal for v_query;
fetch c_cal into v_date_time, v_description;
loop
exit when c_cal%notfound;
r_cal := calendar_row(v_date_time, v_description);
pipe row(r_cal);
fetch c_cal into v_date_time, v_description;
end loop;
return;
end;
end;
================================================
Now you can set query in a PL/SL region before the calendar:
dyn_calendar.set_query(SELECT count(*), ' || :P8_SOURCE_DATE || ' FROM ' || :P8_SOURCE_TABLE || ' GROUP BY ' || :P8_SOURCE_DATE);
and you can base your calendar on the query:
select * from table(dyn_calendar(view_source))
Good luck,
Dik -
Displaying diff dates using PL/SQL expression for 'display only' item ?
Hi ,
I am having a display only item -- :P2_FROM_Date . If its Thu,Fri,Sat or Sun I want to set the date as the last Monday's date . If its Mon,Tue or Wed then it should be the present Monday's date .
E.g: Today is Friday and the last Monday was on 18th .
So for yesterday , today,tomorrow and Sunday , the date should be displayed as 18-JUN-2012.
From the coming Monday to Wednesday , the date should of be the coming Monday i.e , 24-JUN-2012
I tried it doing under 'Source ' of item using PL/SQL expression and PL/SQL function body. Not working
Can someone help ?
Thanks & Regards
UmerNice1 wrote:
declare
lv_date number;
begin
select to_char(sysdate,'D') into lv_date from dual;
if lv_date=2 then
:P2_FROM_DATE := to_char(sysdate-1);
end if;
end;I tried this under " PL/SQL function body " in "Source " tab of the item P2_FROM_DATE
When I run this , nothing is displayed corresponding to the item P2_FROM_DATEExactly as expected. This code will only set a value for <tt>P2_FROM_DATE</tt> when run on Mondays in territories where the first day of the week is Sunday, and when run on Tuesdays where Monday is the first day of of the week:
SQL> var P2_FROM_DATE varchar2(30)
SQL> alter session set nls_date_format='Dy DD-MON-YYYY';
Session altered.
SQL> select sysdate from dual
SYSDATE
Mon 25-JUN-2012
SQL> alter session set nls_territory='AMERICA';
Session altered.
SQL> declare
2 lv_date number;
3 begin
4 select to_char(sysdate,'D') into lv_date from dual;
5 if lv_date=2 then
6 :P2_FROM_DATE := to_char(sysdate-1);
7 end if;
8 end;
9 /
PL/SQL procedure successfully completed.
SQL> print p2_from_date
P2_FROM_DATE
Sun 24-JUN-2012
SQL> alter session set nls_territory='UNITED KINGDOM';
Session altered.
SQL> exec :p2_from_date := null
SQL> declare
2 lv_date number;
3 begin
4 select to_char(sysdate,'D') into lv_date from dual;
5 if lv_date=2 then
6 :P2_FROM_DATE := to_char(sysdate-1);
7 end if;
8 end;
9 /
PL/SQL procedure successfully completed.
SQL> print p2_from_date
P2_FROM_DATE
SQL>Hence the questions about language above.
>
I am having a display only item -- :P2_FROM_Date . If its Thu,Fri,Sat or Sun I want to set the date as the last Monday's date . If its Mon,Tue or Wed then it should be the present Monday's date .
E.g: Today is Friday and the last Monday was on 18th .
So for yesterday , today,tomorrow and Sunday , the date should be displayed as 18-JUN-2012.
From the coming Monday to Wednesday , the date should of be the coming Monday i.e , 24-JUN-2012
>
The coming Monday is 25-JUN-2012.
Aren't these rules equivalent to "Monday this week, where Monday is the first day of the week"? In which case the PL/SQL Expression you require is:
trunc(sysdate, 'iw')For example:
SQL> with t as (
2 select date '2012-06-21' + level d from dual connect by level <= 17)
3 select
4 d
5 , trunc(d, 'iw') monday
6 from
7 t;
D MONDAY
Fri 22-JUN-2012 Mon 18-JUN-2012
Sat 23-JUN-2012 Mon 18-JUN-2012
Sun 24-JUN-2012 Mon 18-JUN-2012
Mon 25-JUN-2012 Mon 25-JUN-2012
Tue 26-JUN-2012 Mon 25-JUN-2012
Wed 27-JUN-2012 Mon 25-JUN-2012
Thu 28-JUN-2012 Mon 25-JUN-2012
Fri 29-JUN-2012 Mon 25-JUN-2012
Sat 30-JUN-2012 Mon 25-JUN-2012
Sun 01-JUL-2012 Mon 25-JUN-2012
Mon 02-JUL-2012 Mon 02-JUL-2012
Tue 03-JUL-2012 Mon 02-JUL-2012
Wed 04-JUL-2012 Mon 02-JUL-2012
Thu 05-JUL-2012 Mon 02-JUL-2012
Fri 06-JUL-2012 Mon 02-JUL-2012
Sat 07-JUL-2012 Mon 02-JUL-2012
Sun 08-JUL-2012 Mon 02-JUL-2012
17 rows selected.
SQL> alter session set nls_territory='AMERICA';
Session altered.
SQL> alter session set nls_date_format='Dy DD-MON-YYYY';
Session altered.
SQL> with t as (
2 select date '2012-06-21' + level d from dual connect by level <= 17)
3 select
4 d
5 , trunc(d, 'iw') monday
6 from
7 t;
D MONDAY
Fri 22-JUN-2012 Mon 18-JUN-2012
Sat 23-JUN-2012 Mon 18-JUN-2012
Sun 24-JUN-2012 Mon 18-JUN-2012
Mon 25-JUN-2012 Mon 25-JUN-2012
Tue 26-JUN-2012 Mon 25-JUN-2012
Wed 27-JUN-2012 Mon 25-JUN-2012
Thu 28-JUN-2012 Mon 25-JUN-2012
Fri 29-JUN-2012 Mon 25-JUN-2012
Sat 30-JUN-2012 Mon 25-JUN-2012
Sun 01-JUL-2012 Mon 25-JUN-2012
Mon 02-JUL-2012 Mon 02-JUL-2012
Tue 03-JUL-2012 Mon 02-JUL-2012
Wed 04-JUL-2012 Mon 02-JUL-2012
Thu 05-JUL-2012 Mon 02-JUL-2012
Fri 06-JUL-2012 Mon 02-JUL-2012
Sat 07-JUL-2012 Mon 02-JUL-2012
Sun 08-JUL-2012 Mon 02-JUL-2012
17 rows selected.Also note that using the item source properties will only set the <tt>P2_FROM_DATE</tt> in the rendered page, not in session state. -
Best practice for default values in EO
I have and entity called AUTH_USER (a user table) within it has 2 TIMESTAMP WITH TIME ZONE columns like this ...:
EFF_DATE TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT current_timestamp,
TERM_DATE TIMESTAMP WITH TIME ZONE
Notice EFF_DATE has a default constraint and is not nullable.
In the EO, EFF_DATE is represented as a TIMESTAMPTZ and is checked as MANDATORY in its attribute properties. I cannot commit a NEW RECORD based on VO derived from this EO because of the MANDATORY constraint that is set in the EFF_DATE attribute's properties unless I enter a value. My original strategy was to have the field populated by a DEFAULT DATE if the user should attempt to leave this field null.
This is my deli ma.
1. I could have the database populate the value based on the default constraint in the table definition. Since EFF_DATE and TERM_DATE resemble the Effective Date (Start, End) properties that the framework already provides then I could set both fields as Effective Date (Start, End) and then check Refresh After Insert. But this still won't work unless I deselect the mandatory property on EFF_DATE.
2. The previous solution would work. However, I'm not sure that it is part of a "Best Practices" solution. In my mind if a database column is mandatory in the database then it should be mandatory in the Model as well.
3. If the first option is a poor choice, then what I need to do is to leave the attribute defined and mandatory and have a DEFAULT VALUE set in the RowImpl create method.
4. Finally, I could just force the user to enter a value. That would seem to be the common sense thing to do. I mean that's what calendar widgets and AJAX enabled JSF are for!
Regardless to what the correct answer is, I'd like to see some sample code of how the date can be populated inside the RowImpl create method and it pass to setEffDate(TimestampTZ dt). Keep in mind though that in this instance I need the timezone at the database server side and not the client side. I would also ask for advice on doing this with Groovy Scripting or expressions.
And finally, what is the best practice in this situation?
Thanks in advance.How about setting the default value property of the attribute in the EO to be adf.currentDate ?
(assuming you are using 11g).
This way there is a default date being set when the record is created and the user can change it if he wants to. -
ORA-01403: no data found for default value
I have the following pl/sql function body for setting the default value of a select list.
DECLARE
selected VARCHAR2(100);
BEGIN
select person_id into selected from ht_people
where :app_user=flow_user;
RETURN selected ;
END;
It works perfectly until the user who is logged in is not on the list and then I get:
ORA-01403: no data found
ERR-9131 Error in PLSQL function body for item default code, item=P7_IDENTIFIED_BY
Is there an item property I can set to handle this or must this be done in PL/SQL?This will throw no error if user not found:
DECLARE
selected VARCHAR2 (100);
BEGIN
FOR c IN (SELECT person_id
FROM ht_people
WHERE :app_user = flow_user)
LOOP
selected := c.person_id;
END LOOP;
RETURN selected;
END;Denes Kubicek
http://deneskubicek.blogspot.com/
http://www.opal-consulting.de/training
http://apex.oracle.com/pls/otn/f?p=31517:1
------------------------------------------------------------------- -
SQL Expression for date conversion - version XI
I am trying to convert a number field to a date field in order to use it in a date parameter in Infoview. The database field is in a 15 digit DTM format but is stored as a number. There is also a zero stored in the database field. When I try to create the date SQL Expression I get this error: Error in compiling SQL Expression: Failed to retrieve data from the database. Details: ORA-01840: input value not long enough for date format. How can I get the SQL Expression to not look at the zero? I tried putting a statement in my Record Selection to not pull any zero fields but that doesn't work. Any ideas? Thanks! Kelley
Hi Kelly,
It's been a while since I used Info View, so if it's about registering, etc. I won't know the
answer.
Did you link it ? Have you tested that it should even return data ?
Check the filtering, etc in a query builder to make sure.
Have you tested the sub report by running it by itself ? (just add a value to the parameter
field request)
Do you have suppression formulas in the sub report ?
Is the section of the main report that is holding the sub report
free of "suppresion" formulas ? -
Using a Sql Result in Default Value of Dashboard Prompt
Hi,
I Create a Dashboard Prompt, this have two dates, the initial and the last for a period to filter. I need to set the default value in the fist and last date of the previous month, for example, if today is 20th of november the default value of initial date has been 1th of October and the last date has been 31th of october.
I used in default the option 'SQL Results' and use the next sentences:
SELECT TRUNC(add_months(sysdate, -1), 'MM') FROM dual;
SELECT TRUNC(last_day(add_months(sysdate, -1))) from dual;
But when I try to use the dashboard prompt the result is:
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 27002] Near <(>: Syntax error [nQSError: 26012] . (HY000)
SQL Issued: SELECT TRUNC(add_months(sysdate,-1),'MM') FROM dual
When I try to use only select sysdate from dual; the result is:
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 27004] Unresolved table: "dual". (HY000)
Thanks for your help.Thanks for your help. Finally I solve this issue of
this form:
1. I Create a Initialization Block with the next
sentences:
SELECT TRUNC(add_months(sysdate, -1), 'MM')
INITIAL_DATE ,TRUNC(last_day(add_months(sysdate,
-1))) END_DATE, To_char(TRUNC(add_months(sysdate,
-1), 'MM'), 'YYYYMM') PERIOD FROM dual;
2. Then I Create three Repository Variables and
assign the Initialization Block to this
3. In the Dashboard Prompt I use the "Server
Variable" Option in the default and call the three
variables.
Thanks again
EdwinHi: How u access server variable with two fields of date. Actually, I am doing the same work. But I can not do this work. Because this is ok when the date is greater than or less than. When i use between, in default server variable button did not show any text area for reoository variable. I also made initailization block with 2 fields.
My Task is, I have to initialize the one date coloumn. From Date: and To Date. Pluzz help me in section
Ali Haroon Nawaz -
Help with an SQL Expression - Return field value where Datetime is Min or First datetime
Hello,
I'm extracting results for a patient population.
I have 6 SQL expressions that pull back the first date for specific procedures or Medications being ordered.
These Expressions work perfect - One of the expressions return the first time a lab was ordered.
I'm using SQL that return
Min(OrderDatetime)
From OrderTable
Where
LABCode = XXX
I've now been ask to return the value of this lab result.
Question: How do I write an SQL expression that return the Lab value of the Min(OrderDatetime)
Example Data
PATID* LABID * OrderDatetime * ResultValue
Pat1*133 * 12/12/2013 11:00:pm * 77
Pat1*145 * 12/12/2013 11:45:pm * 45
Pat1*147 * 12/13/2013 12:10:AM * 78
I was to return 77
Thanks
SteveHere is what I came up with but I'm getting an error -
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <,>,>= or when the subquery is used as an expression.
Any thoughts on what I'm doing wrong?
SELECT LABRESULTS.ORDER_VALUE as LabResult
FROM LABRESULTS, ORDERS_PROD, PATIENT_HSP
WHERE
"ORDERS_PROD"."CSN_ID" = "LABRESULTS"."CSN_ID" AND
"ORDERS_PROD"."ORDER_PROC_ID" = "LABRESULTS"."ORDER_PROC_ID" AND
ORDERS_PROD.ORDER_INST IN (
SELECT Min(ORDERS_PROD.ORDER_INST)
FROM ORDERS_PROD
WHERE "PATIENT_HSP"."CSN_ID" = "ORDER_PROD"."CSN_ID" AND
("ORDERS_PROD"."ORDER_STATUS_C"<>4 OR
"ORDERS_PROD"."ORDER_STATUS_C"<>9) AND
"ORDERS_PROD"."FUTURE_OR_STAND" IS NULL AND
"ORDERS_PROD"."REASON_FOR_CANC_C" IS NULL AND
("ORDERS_PROD"."PROC_CODE" = 'LAB7764' OR
"ORDERS_PROD"."PROC_CODE" = 'LAB7765' OR
"ORDERS_PROD"."PROC_CODE" = 'LAB7766' OR
"ORDERS_PROD"."PROC_CODE" = 'LAB7767') -
User-exit for default values in service order
Hi,
i use EXIT QQMA0025 (EXIT_SAPLIQS0_017) to set some default values by creating
a service notification.
Is there some exit or badi to do the same for service orders. I don't want to use TPMUS.
Regards, DieterI create this thread in SD, because
i don't get any answers.
Regards, Dieter
Maybe you are looking for
-
Window Memory usage even after closing windows
I've included links to a test app that does nothing but launch a window, play a sound, close window / repeat. When application launches it uses about 20mb of memory. When you click on the only button, it will launch a secondary window that will simpl
-
How to download Adobe Edge Inspect?
It maybe weekend woes, but I find it impossible to download Adobe Edge Inspect. For starters, I would like to test the free version. This is what I'm doing 1 )install the Edge Inspect Extension on Chrome 2) sign up for Adobe Create Cloud 3) go to app
-
Need help in HR - CATS enhancements
Hello everyone, I have a requirement where in i have to use a field that is not availaable in cats0003 enhancement's fuction exit import/table fields.The field is catsd-day# 's.I have to validate on these catsd-day01....fileds which are not available
-
I'm trying to set up a mobile accordion menu with sub menus for my site using the widgets in muse. When I click on the top menu button it brings up another accordion menu it looks like. It is on the right side of the button not under the button where
-
Select multple rows in ALV without pressing pressing CTRL key
Hi experts, Is there any way that I can select multple rows in an ALV without pressing pressing CTRL key? I am using set_table_for_first_display method for displaying the ALV. I tried different options of sel_mode, but none of them works without the