Help with select into please
Good morning everyone,
I have a problem with my function. I need to do the dynamic select with the SELECT INTO
create or replace function prueba (p_param IN VARCHAR2) RETURN VARCHAR2
IS
v_aux1 VARCHAR2(200);
v_aux2 VARCHAR2(200);
BEGIN
SELECT col1
INTO v_aux1
FROM my_table
WHERE col2 = p_param; --UNION SELECT '1233' FROM DUAL;
RETURN v_aux1;
EXCEPTION
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR(-20000,SQLERRM );
--RETURN v_aux2;
END;
When I try to call my function with the golden as follows:
select (prueba('''MON'' UNION SELECT '||chr(039)||'12'||chr(039)||' FROM DUAL')) from dual
OR
select (prueba(chr(039)||'MON'||chr(039)||' UNION SELECT '||chr(039)||'12'||chr(039)||' FROM DUAL')) from dual
I get the error: no data found
If I use the sentence in Golden or SQLPLUS as follows:
SELECT col1
-- INTO aux1
FROM my_table
WHERE despaise = 'MON' UNION SELECT '12' FROM DUAL
It ´s correct, and it return '1233'
The value 'MON' no exists in my_table.
If uncommented the sentence "UNION SELECT '1233' FROM DUAL" in my function an I use 'MON' as parameter it´s correct.
How I can do this using the parameter with the UNION?.
Thank you very much to all and sorry for my english
Hi,
welcome to the forum.
Please read SQL and PL/SQL FAQ
When you put some code or output please enclose it between two lines starting with {noformat}{noformat}
i.e.:
{noformat}{noformat}
SELECT ...
{noformat}{noformat}
you cannot pass static SQL as part of the string.
When you call the procedure in either wayselect (prueba('''MON'' UNION SELECT '||chr(039)||'12'||chr(039)||' FROM DUAL')) from dual
select (prueba(chr(039)||'MON'||chr(039)||' UNION SELECT '||chr(039)||'12'||chr(039)||' FROM DUAL')) from dual
This result in passing a whole string to your function as'MON' UNION SELECT '12' FROM DUAL
which translates in your code asSELECT col1
INTO v_aux1
FROM my_table
WHERE col2 = '''MON'' UNION SELECT ''12'' FROM DUAL'
So it is searching a rows having col2 with value '''MON'' UNION SELECT ''12'' FROM DUAL'
Please try to explain what you are trying to achieve and we may help you.
You could use dynamic SQL to do that but it is not clear what are your business requirement and the approach that you are using does not seem to be correct.
Regards.
Al
Similar Messages
-
Dynamic Pivot with Select Into
I have this Dynamic Pivot which works fine.
DECLARE @query VARCHAR(4000)
DECLARE @years VARCHAR(2000)
SELECT @years = STUFF(( SELECT DISTINCT'],[' + [factor_label]
FROM [TEMP_lacp_factors]
ORDER BY '],[' + [factor_label]
FOR XML PATH('')
), 1, 2, '') + ']'
SET @query =
'SELECT * FROM
SELECT [date_],[issue_id],[cusip],[Factor_value],[factor_label]
FROM [TEMP_lacp_factors]
)t
PIVOT (MAX([factor_value]) FOR [factor_label]
IN ('+@years+')) AS pvt'
EXECUTE (@query)
I'm trying to take the results of that and do a SELECT INTO, so I can move the results to another table. Is this possible? I didn't find a whole lot online.
The error that I'm getting is this.
Caused by: Column name or number of supplied values does not match table definition.
How can I do this? Is it even possible?
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.Sure, you can create a table with SELECT INTO, but it cannot be a #temptable. Well, it can be a #temptable, but it will disappear as soon as you exit the scope it was created it, that is the dynamic SQL.
The question is only, what would you do with this table later? Since you don't know the column names, about all work will have to be done through dynamic SQL.
A dynamic pivot is a non-relational operation. A SELECT statement produces a table, and a table describes a distinct entity, of which the column are distinct and well-defined attributes. Something which your dynamic pivot does not adhere to.
There is only one thing you can do with your dynamic pivot: returning the data to the client. I don't know what you want to do with that table, but probably you should do that manipulation before the dynamic pivot, because as I said: that is always your
last step.
Erland Sommarskog, SQL Server MVP, [email protected] -
Help with SELECT - selecting range of numbers
Hi,
I need a help with SELECT statement. I want to select Dates starting from today and ending 30 days back. So the result would be like:
TRUNC(SYSDATE)
TRUNC(SYSDATE) - 1
TRUNC(SYSDATE) - 2
TRUNC(SYSDATE) - 3
TRUNC(SYSDATE) - 30I was thinking to simply select truncated SYSDATE in first column, and in second column numbers 0, 1, 2, ... 30. Then I would simply do a difference first column - second column. But how to select such sequence of numbers? I don't want to select each number (date) in separate select statement and then unioning them.
Does anybody have an idea?
Thanks for help, DanSQL> select trunc(sysdate) - level + 1 as dt
2 from dual
3 connect by level <= 31
4 ;
DT
07/01/2013
06/01/2013
05/01/2013
04/01/2013
03/01/2013
02/01/2013
01/01/2013
31/12/2012
30/12/2012
29/12/2012
28/12/2012
27/12/2012
26/12/2012
25/12/2012
24/12/2012
23/12/2012
22/12/2012
21/12/2012
20/12/2012
19/12/2012
DT
18/12/2012
17/12/2012
16/12/2012
15/12/2012
14/12/2012
13/12/2012
12/12/2012
11/12/2012
10/12/2012
09/12/2012
08/12/2012
31 rows selected -
Help with access control please
So I'm trying to set up my brother's PSP to the wirless network through MAC address timed access. What I want to do is make it so that he can only access it through certain times in the day. I'm having troubles with actually getting it to work. Everytime I set it up, the PSP only show's up as a DHCP client and not a Wireless client. I tried the option panel with the add wireless clients through the first try access. Could I get some help with this issue please? Thanks!
Just to calm your fears... There is no conspiracy. If someone had an answer or a suggestion they would post it.
-
Hi, i really need some help with my pictures, I've only got a very basic understanding of how my phone works and have somehow put a load of albums on my phone when i plugged it into the computer-I want to delete some of them off the phone but cannot work out how to do it, when i plug my phone in i can find the photo tab but cannot actually see the pictures and can't see any delete button!!! Please can someone help me, basic explanations would be gratefully recieved xxxx
The photo sync is one way: computer to phone. To remove photos, synced to your phone, remove the check marks next to the albums/folders under the photos tab in itunes & hit the apply/sync button. They will be removed from your phone. You cannot delete photos that were synced to your phone, directly on your phone. The easiest way to manage photos synced to your phone is to create albums or folders on your computer. Move whatever photos you want on your phone into these albums/folders & then select them under the photos tab in itunes to sync to your phone. You can then remove or add photos to these various albums/folders on your computer & the itunes sync process will update your phone every time you sync.
-
Dynamic column name with SELECT INTO
I am trying to build a function that derives a pay amount from a set of business rules. There are about 40 columns that hold various pay amounts and their column names are variations of 4 indicators (day shift, vs night shift, etc.) that I have to dynamically look up, ie here is the ID number and a timecard, now figure out which of the 40 fields to look up to get the pay amount.
I can determine from the timecard and employee ID which field to look at, but I'm getting hung up with the syntax needed to construct and execute the statement inside the PL/SQL block. I need to RETURN the pay I extract using the function, and I can create the correct SQL statement, but the EXECUTE IMMEDIATE won't accept the SELECT INTO syntax.
Can someone please suggest a solution? Here is the function:
create or replace FUNCTION FN_GET_PAYRATE(tc in NUMBER, e in NUMBER, pc in VARCHAR2)
RETURN NUMBER
IS
e_id NUMBER;
tc_id NUMBER;
pl_cd VARCHAR2(7);
shft VARCHAR2(2);
lvl VARCHAR2(2);
typ VARCHAR2(2);
e_typ VARCHAR2(4);
proj NUMBER;
hrly VARCHAR2(4);
payrt NUMBER;
var_col VARCHAR2(10);
sql_select VARCHAR2(200);
sql_from VARCHAR2(200);
sql_where VARCHAR2(200);
sql_and1 VARCHAR2(200);
sql_and2 VARCHAR2(200);
sql_and3 VARCHAR2(200);
sql_orderby VARCHAR2(200);
var_sql VARCHAR2(2000);
BEGIN
e_id := e;
tc_id := tc;
pl_cd := pc;
SELECT NVL(SHIFT,'D') INTO shft
FROM TS_TIMECARD_MAIN
WHERE TIMECARD_ID = tc_id;
--DBMS_OUTPUT.PUT_LINE('SHIFT= ' || shft);
SELECT NVL(PAY_LVL, 1), NVL(PAY_TYPE, 'B'), NVL(RTRIM(EMP_TYPE), 'LHD'), NVL(PROJECT, 001)
INTO lvl, typ, e_typ, proj
FROM TS_EMPLOYEES
WHERE EMP_ID = e_id;
--DBMS_OUTPUT.PUT_LINE('Level= ' || lvl);
--DBMS_OUTPUT.PUT_LINE('PAY_TYPE= ' || typ);
--DBMS_OUTPUT.PUT_LINE('EMP_TYPE= ' || e_typ);
--DBMS_OUTPUT.PUT_LINE('PROJECT= ' || proj);
IF e_typ <> 'LHD' THEN
hrly := 'H';
ELSE
hrly := '';
END IF;
IF proj <> 001 THEN
var_col := shft || lvl || typ || hrly;
--DBMS_OUTPUT.PUT_LINE('RATE COLUMN= ' || var_col);
sql_select := 'SELECT NVL(' || var_col || ', .01) INTO payrt';
sql_from := ' FROM TS_PAYRATES';
sql_where := ' WHERE PROJECT_ID = ' || proj;
sql_and1 := ' AND ACTIVE = 1';
sql_and2 := ' AND JOB_TYPE = ' || CHR(39) || e_typ || CHR(39);
sql_and3 := ' AND PILE_ID = ' || CHR(39) || pl_cd || CHR(39);
var_sql := sql_select || sql_from || sql_where || sql_and1 || sql_and2 || sql_and3 || sql_orderby;
DBMS_OUTPUT.PUT_LINE('SQL: ' || var_sql);
EXECUTE IMMEDIATE var_sql;
DBMS_OUTPUT.PUT_LINE('RATE= ' || payrt);
RETURN payrt;
ELSE
DBMS_OUTPUT.PUT_LINE('ERROR');
RETURN 1;
END IF;
END;
I have alternately tried this:
SELECT NVL(var_col,.01) into payrt
FROM TS_PAYRATES
WHERE PROJECT_ID = proj AND ACTIVE = 1
AND JOB_TYPE = CHR(39) || e_typ || CHR(39)
AND PILE_ID = CHR(39) || pl_cd || CHR(39);
as a substitute for the EXECUTE IMMEDIATE block, but I can't seem to use a dynamic substitution for the column name.
Any help would be greatly appreciated.That's the most difficult part - the error messages seem to indicate a problem with the SQL statement in its execution context, because I can take the SQL string by itself and it executes perfectly.
Here are three variations:
SELECT INTO
select fn_get_payrate(21555, 30162, 15) from dual
ERROR at line 1:
ORA-00905: missing keyword
ORA-06512: at "PEOPLENETIF.FN_GET_PAYRATE", line 60
SQL: SELECT NVL(N4P , .01) INTO payrt FROM TS_PAYRATES WHERE PROJECT_ID = 701 AND ACTIVE = 1 AND JOB_TYPE = 'LHD' AND PILE_ID = '15'
Without SELECT INTO (returns NULL)
SQL> select fn_get_payrate(21555, 30162, 15) from dual;
FN_GET_PAYRATE(21555,30162,15)
SQL: SELECT NVL(N4P , .01) FROM TS_PAYRATES WHERE PROJECT_ID = 701 AND ACTIVE = 1 AND JOB_TYPE = 'LHD' AND PILE_ID = '15'
RATE=
EXECUTE IMMEDIATE USING
SQL> select fn_get_payrate(21555, 30162, 15) from dual;
select fn_get_payrate(21555, 30162, 15) from dual
ERROR at line 1:
ORA-01006: bind variable does not exist
ORA-06512: at "PEOPLENETIF.FN_GET_PAYRATE", line 61
SQL: SELECT NVL(N4P , .01) FROM TS_PAYRATES WHERE PROJECT_ID = 701 AND ACTIVE = 1 AND JOB_TYPE = 'LHD' AND PILE_ID = '15' -
Help with Keynote AppleScript, please
Hi,
I would like to make a Keynote 3 slideshow from a few pictures (Keynote has nicer transitions than iPhoto). I saw that there is an AppleScript command that should do that:
make image slides v : Make a series of slides from a list of image paths. Returns a list of paths from which new slides could not be made.
make image slides reference : the object for the command
paths Unicode text
[master master slide]
[set titles boolean]
Can someone show me how I would actually do that? E.g. with my pictures at /Users/andi/Pictures/ ?
That would be very nice! Thanks!
iBook G4 12" Mac OS X (10.4.4) 1.25 GB RAMAh, thanks a lot! Your remark about cropping got me on the right idea.
So now I have found a solution with Automator. Please be tolerant with the exact titles of the Actions as I write this on a german system and try to translate:
1. Keynote Actions > New Keynote Presentation (with e.g. Theme "Black", Size 1024 x 768 pixels)
2. iPhoto Actions > Ask for Photos (Note: You have to select some Photos and not just an Album)
3. Finder Actions > Copy Finder Objects (e.g. to "Pictures")
And now here comes the tricky part: I used the Photoshop CS2 Actions that can be found here: http://www.completedigitalphotography.com/index.php?p=389 to scale the images to 1024 x 768.
4. Photoshop CS2 Actions > Fit Image (Width: 1024, Height 768, DON'T check the box named "Save and close")
5. Photoshop CS2 Actions > Save as JPEG (Use the settings you like as long as you check the boxes "Close after saving" and "Pass saved files instead of originals")
6. Keynote Actions > Create Slide with Picture (Don't check "Set Titles")
That's all. Save it as a Programm or whatever you like. It asks you for Photos, corrects width and height to fit into the Keynote slide and puts everything in Keynote. You just have to select all the slides in Keynote and apply one of the gorgeous new transitions (like Reflections, my favourite!) to it and you're done.
Please correct me if a translation wasn't correct (and I bet some were).
iBook G4 12" Mac OS X (10.4.4) 1.25 GB RAM -
Help with Validation Problem Please
I don't understand this validation and don't know how to fix it. I have checked my other websites and they seem fine. I don't think I have done anything different The link for the website ishttp://www.greenpatchwebsites.com/pow/index.html
and the validator is http://validator.w3.org/check?uri=www.greenpatchwebsites.com%2Fpow%2Findex.html&charset=%2 8detect+automatically%29&doctype=Inline&group=0
Please can you help.
Thank you very much in advance.Thanks for that. I have tried it on a new page: http://www.greenpatchwebsites.com/pow/newtest.html and here is the validator :
http://validator.w3.org/check?uri=www.greenpatchwebsites.com%2Fpow%2Fnewtest.html&charset= %28detect+automatically%29&doctype=Inline&group=0&No200=1- unfortunately loads of errors
I also tried the recommended template:
Use the following markup as a template to create a new XHTML 1.0 document using a proper DOCTYPE. See the list below if you wish to use another document type.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>An XHTML 1.0 Strict standard template</title>
<meta http-equiv="content-type"
content="text/html;charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
</head>
<body>
<p>… Your HTML content here …</p>
</body>
</html>
but was getting errors with that. As you can tell, I need serious help with this. Which doc type should I be using
and why doesn't Dreamweaver just do it for you when you select one?
Thanks very much again in advance. -
A week ago I was on Option 1 but due to heavy use my speed was reduced to 15.7k/sec !.I was advised to upgrade to Option 3 which I promptly did and that was done on the 29th(last week).
My speed though is still 15k/sec and I cannot watch any streaming video or BBC News Channels etc
Would some kind gentleman please look into it for me and advise.......thankyou
Solved!
Go to Solution.Hi Pete,
I am sorry for the delay in getting back to you. I picked your email up this morning and have dropped you a reply. I am pleased that you managed to sort this out, if you need any further help just let me know.
Cheers
Sean
BTCare Community Manager
If we have asked you to email us with your details, please make sure you are logged in to the forum, otherwise you will not be able to see our ‘Contact Us’ link within our profiles.
We are sorry that we are unable to deal with service/account queries via the private message(PM) function so please don't PM your account info, we need to deal with this via our email account :-) -
I am stuck with a problem and I cannot figure it out. I need to be able to extract data based on the records in the BSIS table which do NOT have a corrosponding entries in the BSIK or the BSID table. I need only the GL records. I am trying the code below and I am not getting any data in the wt_bkpf table to use for selection the BSEG records. I have includedpart of my code that is relavant to this problem with hopes that someone could look at it and let me know what I am doing wrong
thanks in advance for the help.
REPORT y_tlh_extgl.
tables declaration
TABLES:
bkpf, " Accounting Document Header
bseg. " Accounting Document Segment
DATA: BEGIN OF t_upload_file OCCURS 0,
line(3000) TYPE c.
DATA: END OF t_upload_file.
variables declaration
DATA:
wv_index LIKE sy-index,
wv_item_index LIKE sy-index.
constants definition
DATA: BEGIN OF ws_bkpf,
belnr LIKE bkpf-belnr, " Reference
waers LIKE bkpf-waers, " Currency
bktxt LIKE bkpf-bktxt. " header text
INCLUDE STRUCTURE bkpf.
DATA: END OF ws_bkpf.
structures definition
DATA: BEGIN OF wt_bkpf OCCURS 0.
INCLUDE STRUCTURE ws_bkpf.
*INCLUDE STRUCTURE bkpf.
DATA: END OF wt_bkpf.
DATA: BEGIN OF wt_bkpf_hold OCCURS 0.
INCLUDE STRUCTURE ws_bkpf.
INCLUDE STRUCTURE bkpf.
DATA: END OF wt_bkpf_hold.
DATA: BEGIN OF ws_bseg,
belnr LIKE bseg-belnr, " Reference
hkont LIKE bseg-hkont, " G/L Account
bschl LIKE bseg-bschl,
wrbtr LIKE bseg-wrbtr,
dmbtr LIKE bseg-dmbtr,
dmbe2 LIKE bseg-dmbe2,
kostl LIKE bseg-kostl, " Cost center
sgtxt LIKE bseg-sgtxt, " Item text
aufnr LIKE bseg-aufnr, " Project
zuonr LIKE bseg-zuonr, " Assignment/Cntry of Dest
prctr LIKE bseg-prctr, " Profit center
vbund LIKE bseg-vbund, " Trading partner
umskz LIKE bseg-umskz, " Special G/L Indicator
mwskz LIKE bseg-mwskz. " Tax code
DATA: END OF ws_bseg.
DATA: BEGIN OF wt_bseg OCCURS 0.
INCLUDE STRUCTURE ws_bseg.
DATA: END OF wt_bseg.
DATA: BEGIN OF wt_gl_bsis OCCURS 0.
INCLUDE STRUCTURE bsis.
DATA: END OF wt_gl_bsis.
SELECTION-SCREEN BEGIN OF BLOCK blck WITH FRAME.
PARAMETERS:
p_bukrs LIKE bkpf-bukrs OBLIGATORY
DEFAULT wc_bukrs_5520.
SELECT-OPTIONS:
s_belnr FOR bkpf-belnr,
s_monat FOR bkpf-monat,
s_gjahr FOR bkpf-gjahr OBLIGATORY.
SELECTION-SCREEN SKIP 1.
PARAMETERS:
p_svfile LIKE rlgrap-filename
DEFAULT '/DEV/MFGPRO/TLH_EXTRACT_xx.txt'
NO-DISPLAY.
SELECTION-SCREEN END OF BLOCK blck.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-012 .
PARAMETERS:p_ipath TYPE rlgrap-filename OBLIGATORY." LOWER CASE.
SELECTION-SCREEN END OF BLOCK b2.
INITIALIZATION
INITIALIZATION.
PERFORM f_initialize_some_data.
AT SELECTION-SCREEN.
PERFORM f_preliminary_checks.
START-OF-SELECTION.
PERFORM f_get_data.
PERFORM f_split_data.
PERFORM f_transfer_data_to_server.
PERFORM write_data.
END-OF-SELECTION.
Routines definition
FORM f_initialize_some_data .
s_gjahr-option = 'BT'.
s_gjahr-sign = 'I'.
s_gjahr-low = '2005'.
s_gjahr-high = '2006'.
APPEND s_gjahr.
ENDFORM. " f_initialize_some_data
FORM f_get_data .
SELECT * INTO TABLE wt_GL_BSIS
FROM bsis
WHERE bukrs EQ p_bukrs
AND belnr IN s_belnr
AND gjahr IN s_gjahr.
IF sy-dbcnt IS INITIAL.
MESSAGE i208(00) WITH text-001.
STOP.
ENDIF.
loop at wt_GL_BSIS.
DATA: wa_bsik type bsik.
DATA: wa_bsid type bsid.
SELECT SINGLE * FROM BSIK
INTO CORRESPONDING FIELDS OF wa_bsik
WHERE bukrs EQ p_bukrs
AND belnr EQ wt_GL_BSIS-belnr
AND gjahr EQ s_gjahr.
if sy-subrc = 0.
exit.
ELSE.
SELECT SINGLE * FROM BSId
INTO CORRESPONDING FIELDS OF wa_bsid
WHERE bukrs EQ p_bukrs
AND belnr EQ wt_GL_BSIS-belnr
AND gjahr EQ s_gjahr.
if sy-subrc = 0.
exit.
ELSE.
write: / 'getting gl record'.
SELECT belnr waers bktxt
INTO TABLE wt_bkpf_hold
FROM bkpf
WHERE belnr EQ wt_gl_bsis-belnr
AND bukrs EQ wt_gl_bsis-bukrs
AND monat IN s_monat.
IF sy-dbcnt IS INITIAL.
MESSAGE i208(00) WITH text-001.
STOP.
ENDIF.
MOVE wt_bkpf_hold-belnr TO wt_bkpf-belnr.
MOVE wt_bkpf_hold-waers TO wt_bkpf-waers.
MOVE wt_bkpf_hold-bktxt TO wt_bkpf-bktxt.
APPEND wt_bkpf.
ENDIF.
ENDIF.
ENDLOOP.
SORT wt_bkpf BY belnr.
SELECT belnr hkont bschl wrbtr dmbtr dmbe2 kostl sgtxt aufnr zuonr
prctr vbund umskz mwskz
INTO TABLE wt_bseg
FROM bseg
FOR ALL ENTRIES IN wt_bkpf
WHERE bukrs EQ p_bukrs
AND belnr EQ wt_bkpf-belnr
AND gjahr EQ s_gjahr.
*ENDIF.
*ENDLOOP.
ENDFORM. " f_get_dataHi
If you want this:
SELECT * INTO TABLE wt_GL_BSIS
FROM bsis WHERE bukrs EQ p_bukrs
AND gjahr IN s_gjahr
AND belnr IN s_belnr
AND MONAT IS S_MONAT.
IF sy-dbcnt IS INITIAL.
MESSAGE i208(00) WITH text-001.
STOP.
ENDIF.
SORT WT_GL_BSIS BY BUKRS GJAHR BELNR.
LOOP AT WT_GL_BSIS.
u can have several items of the same document so u
should try to read BSEG and BKPF table once per every
document
IF WT_GL_BSIS-BUKRS <> OLDBUKRS OR
WT_GL_BSIS-BELNR <> OLDBELNR OR
WT_GL_BSIS-GJAHR <> OLDGJAHR.
Check if there're vendor or customer items
SELECT BUKRS FROM BSEG INTO WT_GL_BSIS-BUKRS
WHERE BUKRS = WT_GL_BSIS-BUKRS
AND BELNR = WT_GL_BSIS-BELNR
AND GJAHR = WT_GL_BSIS-GJAHR
Check vendor/customer item:
KOART = K ---> Vendor Item (BSIK)
KOART = D ---> Customer Item (BSID)
AND ( KOART = 'D' OR KOART = 'K' ).
EXIT.
ENDSELECT.
IF SY-SUBRC <> 0.
Get header data
SELECT SINGLE * INTO wt_bkpf_hold
FROM bkpf WHERE bukrs EQ wt_gl_bsis-bukrs
AND belnr EQ wt_gl_bsis-belnr
AND GJAHR EQ WT_GL_BSIS-GJAHR.
MOVE wt_bkpf_hold-belnr TO wt_bkpf-belnr.
MOVE wt_bkpf_hold-waers TO wt_bkpf-waers.
MOVE wt_bkpf_hold-bktxt TO wt_bkpf-bktxt.
APPEND wt_bkpf.
ENDIF.
OLDBUKRS = WT_GL_BSIS-BUKRS.
OLDBELNR = WT_GL_BSIS-BELNR.
OLDGJAHR = WT_GL_BSIS-GJAHR.
ENDLOOP. -
Case with select into and sub query
hi im trying to use case and select with sebqueries, but my beginer like understanding of syntax fails me. can someone point out what im doing wrong in the case select below. im using select into, as i ultimatly need to load a ref cursor for use with crystal reports.
thanks
james
ps if anyone is london based, and would like to spend a day or two teaching me how to be a bit better at PL/SQL (can aford to pay a little bit) please get in touch!!
SELECT
Case (select kind_code from event where
event.event_id = event.container_event_id)
when 1094006
then promo_name
end
into result
FROM promo, promo_plan , event_promotion
WHERE promo.promo_id = promo_plan.promo_id
AND promo_plan.promo_plan_id = event_promotion.promo_plan_id
AND event_promotion.detail_id = '33532282'
when blah then 'blah';Hello
AH i see what you are driveing at, yes i am just using case slect to determin which >routine to run, as the name is stored in a diferent location depending on the event kind >code. are are you saying i need multiple selects within the case statment? one for each >type of kind code?Well it depends really. If the select
select kind_code from event where
event.event_id = event.container_event_idIs going to return more than one row for any given run, you're going to need to take a bit of a different approach. Is it the case that this query will return more than one row which would mean that you want value X and value Y for each row?
Using the test data and everything from before:
SQL> CREATE OR REPLACE PROCEDURE p_GetStuff(ac_Result OUT sys_refcursor)
2 IS
3
4 BEGIN
5 /*
6 This uses a cartesian product i.e. repeat every row in
7 dt_test_data against every row in dt_test_event
8 */
9 OPEN Ac_Result FOR
10 SELECT
11 CASE dt_test_event.kind_code
12 WHEN 1 THEN
13 dt_test_data.object_name
14 WHEN 2 THEN
15 dt_test_data.object_type
16 END
17 FROM
18 dt_test_data,
19 dt_test_event;
20
21 END;
22 /
Procedure created.
SQL> var x refcursor
SQL> exec p_getstuff(:x)
PL/SQL procedure successfully completed.
SQL> print x
CASEDT_TEST_EVENT.KIND_CODEWHEN1THENDT_TEST_DATA.OBJECT_NAMEWHEN2THENDT_TEST_DAT
ABC
ABC4
AD1
AD2
ADHOC_CONTACT_LOG
AK_CD_CLAIM_VALIDATION_SOURCE
AK_CD_CLAIM_VALIDATION_TYPE
AK_CLAIM_ACTION_ROWSOURCE
APPROVAL_LIST_MEM_IE
APPROVE_GRP_HIST_IE
10 rows selected.
SQL> insert into dt_test_event values(2);
1 row created.
SQL> exec p_getstuff(:x)
PL/SQL procedure successfully completed.
SQL> print x
CASEDT_TEST_EVENT.KIND_CODEWHEN1THENDT_TEST_DATA.OBJECT_NAMEWHEN2THENDT_TEST_DAT
ABC
ABC4
AD1
AD2
ADHOC_CONTACT_LOG
AK_CD_CLAIM_VALIDATION_SOURCE
AK_CD_CLAIM_VALIDATION_TYPE
AK_CLAIM_ACTION_ROWSOURCE
APPROVAL_LIST_MEM_IE
APPROVE_GRP_HIST_IE
TABLE
CASEDT_TEST_EVENT.KIND_CODEWHEN1THENDT_TEST_DATA.OBJECT_NAMEWHEN2THENDT_TEST_DAT
TABLE
TABLE
TABLE
TABLE
INDEX
INDEX
INDEX
INDEX
INDEX
20 rows selected.Or an alternative to that would be, if you have a fixed number of event ids and they relate to a fixed number of attributes you could use something like:
CREATE OR REPLACE PROCEDURE p_GetStuff3(ac_Result OUT sys_refcursor)
IS
BEGIN
The SUBSTR
is just there to make sure the data fit on screen, my SQL*Plus
is a bit weird!
OPEN Ac_Result FOR
SELECT
SUBSTR(MAX(DECODE(dt_test_event.kind_code,1,dt_test_data.object_name,NULL)),1,30) attribute_1,
SUBSTR(MAX(DECODE(dt_test_event.kind_code,2,dt_test_data.object_type,NULL)),1,30) attribute_2
FROM
dt_test_data,
dt_test_event
GROUP BY
object_name;
END;
SQL> delete from dt_test_event where kind_code=2;
1 row deleted.
SQL> exec p_getstuff3(:x)
PL/SQL procedure successfully completed.
SQL> print x
ATTRIBUTE_1 ATTRIBUTE_2
ABC
ABC4
AD1
AD2
ADHOC_CONTACT_LOG
AK_CD_CLAIM_VALIDATION_SOURCE
AK_CD_CLAIM_VALIDATION_TYPE
AK_CLAIM_ACTION_ROWSOURCE
APPROVAL_LIST_MEM_IE
APPROVE_GRP_HIST_IE
10 rows selected.
SQL> insert into dt_test_event values(2);
1 row created.
SQL> exec p_getstuff3(:x)
PL/SQL procedure successfully completed.
SQL> print x
ATTRIBUTE_1 ATTRIBUTE_2
ABC TABLE
ABC4 TABLE
AD1 TABLE
AD2 TABLE
ADHOC_CONTACT_LOG TABLE
AK_CD_CLAIM_VALIDATION_SOURCE INDEX
AK_CD_CLAIM_VALIDATION_TYPE INDEX
AK_CLAIM_ACTION_ROWSOURCE INDEX
APPROVAL_LIST_MEM_IE INDEX
APPROVE_GRP_HIST_IE INDEX
10 rows selected.Message was edited by:
david_tyler
Oops, copy + pasted the wrong comments for the 2nd proc. -
Help with Required fields-PLEASE
I have been attempting to get help with a required field and one of the forum helpers said he got it to work for me but I cannot and I have not been able to get any more responses from him to help me further.
I am attempting to have a radio box when the YES is selected to require another field to be completed. The script I was provided with is:
getField("Location").required = (getField("Group1").value == "Yes");
Location being the field that I require to be filled in if Group 1 is Yes. The previous forum helper indicated that I had to have this script in both fields in Group 1 and when I do that, nothing different happens.
What am I doing wrong?
Please, I need to fix this right away and I will be using this java script on many other forms that I have so I need to get this done soon.
Thank you in advance.Wht you want can get somewhat complicated. One way to prevent subsequent fields from being used is to set them to read-only and/or hidden. You could then use the Validate event of the text field to validate the entry and enable the subsequent fields if it is filled-in adequately. In general, you should also reset the fields whenever you hide them, so they don't contain potentially invalid data from previously being filled-in. So you could initially have the fields set to be hidden, and only unhide them if No is selected, or if Yes is selected and the required text field is filled-in.
I realize this may not be as helpful as you had hoped for, but I can't suggest specific code without knowing more about the form. -
HELP with outgoing emails please
Hi there, I need a help with emails on my mac Air, outgoing emails are not working, everything is set OK (all works on my I phone), but when I try to send an email it says: The certificate for this server is invalid. what should I do?
Back up all data.
Launch the Keychain Access application in any of the following ways:
☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
☞ Open LaunchPad. Click Utilities, then Keychain Access in the icon grid.
Select My Certificates from the Category list in the sidebar. From the list of certificates shown, delete any that are marked with a red X as expired or invalid.
Quit and relaunch Mail. Test. If the problem isn't resolved, continue.
Export all remaining certificates, delete them from the keychain, and reimport. For instructions, select
Help ▹ Keychain Access Help
from the menu bar and search for the term "export" in the help window. Export each certificate as an individual file; don't combine them into one big file.
Test again. If the test fails, delete all the certificates again, then reinstall them from fresh copies. -
Hi experts!
I have a requirement and I need help with an abap routine.
I'm uploading a table from de ECC where each record contains one key figure per fiscal period (wlt01, wlt02,...wlt16). I need to have in a dso a unique key figure (called zwlt for instance) and the 0fiscper infoobject filled with the corresponding period, that is, for each record of the table, I need 16 records in the DSO with zwlt = wltXX and the fiscper = fiscyear&0&XX.
Any help please?
Thanks in advance.there are multiple ways to handle this.
one way is to use APD to unpivot the data.
or else you can use the following sample code to derive what you want...this code might just hint at the way to proceed.
TYPES:
BEGIN OF tys_SC_1,
wlt01 TYPE P LENGTH 8 DECIMALS 2,
wlt02 TYPE P LENGTH 8 DECIMALS 2,
wlt03 TYPE P LENGTH 8 DECIMALS 2,
wlt04 TYPE P LENGTH 8 DECIMALS 2,
wlt05 TYPE P LENGTH 8 DECIMALS 2,
wlt06 TYPE P LENGTH 8 DECIMALS 2,
wlt07 TYPE P LENGTH 8 DECIMALS 2,
wlt08 TYPE P LENGTH 8 DECIMALS 2,
wlt09 TYPE P LENGTH 8 DECIMALS 2,
wlt10 TYPE P LENGTH 8 DECIMALS 2,
wlt11 TYPE P LENGTH 8 DECIMALS 2,
wlt12 TYPE P LENGTH 8 DECIMALS 2,
END OF tys_SC_1.
DATA: ls_type TYPE tys_SC_1,
l_name TYPE string,
l_count Type n length 2.
FIELD-SYMBOLS:
<fs_type> TYPE tys_SC_1,
<result> TYPE P .
ls_type-wlt01 = '1.1'.
ls_type-wlt02 = '2.2'.
ls_type-wlt03 = '3.3'.
ls_type-wlt04 = '4.4'.
ls_type-wlt05 = '5.5'.
ls_type-wlt06 = '6.6'.
ls_type-wlt07 = '7.7'.
ls_type-wlt08 = '8.8'.
ls_type-wlt09 = '9.9'.
ls_type-wlt10 = '10.1'.
ls_type-wlt11 = '11.11'.
ls_type-wlt12 = '12.12'.
CLEAR: l_count , l_name.
l_count = '01'.
ASSIGN ls_type TO <fs_type> .
Write: / .
DO 12 TIMES.
clear: l_name.
Concatenate 'wlt' l_count into l_name.
ASSIGN COMPONENT l_name OF STRUCTURE <fs_type> TO <result> .
Write: / , l_name , ' = ' , <result>.
l_count = l_count + 1 .
ENDDO.
hope it helps.
Regards
Ashwin -
I would need help with saving some eamil messages to a disk to unclutter my email. How can I do this please?
Thanks.
ElisabethOpen the email and then from the File menu select Save As Rich Text Format. That'll save it to open in TextEdit. If you want a pdf then open the email and do command-p (Print) and then from the PDF drop down box lower left corner select Save as PDF.
Maybe you are looking for
-
MBP Freezes (have erased and installed, ran disk utility, and inc fan speed
Hi Guys, Any advice on this issue would be very much appreciated please. Have had an original mbp for about 2 and a half years. Last few weeks it's been freezing between 1 and 5 times a day. By freezing I mean that the screen freezes and there's no c
-
Can´t write in a Planning form as user "admin"
Hi! I can´t write in a new form that I create from a Planning Aplication. The option "read only" is not tilded and all dimensions in the form are level 0. I am connected as user admin and I can´t enter data from SmartView connected to Planning or Ess
-
Duplicate vendor creation blocking in XK01 Transaction
Hi all, I want to block the duplicate vendor creation in the vendor creation transaction XK01.If any solution kindly reply to this message. Jyoti
-
Make sure Webserver and Appserver are up. java.lang.NullPointerException
I redeployed PIA (websphere version 6.1.0.3) Aix 5.3 Webserver / Apps boot up fine and 3 tier login works perfect. While trying to login to the Apps (PIA) i get following Error Please make sure Webserver and Appserver are up. java.lang.NullPointerExc
-
NotificationServiceBean not found in ActivityManagerBean
Hi, I'm using Soa Suite 10.1.3, and I have a problem with a BPEL process sending Mail. I have deployed several processes that can send mail and it works. But sometimes the InvokeNotificationService fails and comes back with a Notificationservicefault