Can I retrieve cursor's value with variable columns?
I have a loop to check a bunch of columns in a cursor, I'd like to use a variable columns like following:
cursor cur
while ....
loop
cur.XXX
end loop;
here XXX are dynamical generated VARCHAR2.
Could you please tell me is it possible, or not?
Thanks alot
Thanks for reply, first. I have couple of columns like abc_1 to abc_100 in the table, I need to check their value one by one. I want to check them using something like abc_X, in the cursor. my thought is like below,
while i<= 100
loop
cur_name.abc_X
end loop
Just replace X with 1 to 100.
Similar Messages
-
How can I get the element value with namespace?
I tried to get a element value in xml has namespace but i can't.
I removed the namespace, i can get a element value.
How can i get a element value with namespace?
--1. Error ----------- xml ------------------------------
<?xml version="1.0" encoding="UTF-8"?>
*<TaxInvoice xmlns="urn:kr:or:kec:standard:Tax:ReusableAggregateBusinessInformation:1:0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:kr:or:kec:standard:Tax:ReusableAggregateBusinessInformation:1:0 http://www.kec.or.kr/standard/Tax/TaxInvoiceSchemaModule_1.0.xsd">*
<ExchangedDocument>
<IssueDateTime>20110810133213</IssueDateTime>
<ReferencedDocument>
<ID>318701-0002</ID>
</ReferencedDocument>
</ExchangedDocument>
<TaxInvoiceDocument>
<IssueID>201106294100</IssueID>
<TypeCode>0101</TypeCode>
<IssueDateTime>20110810</IssueDateTime>
<PurposeCode>02</PurposeCode>
</TaxInvoiceDocument>
<TaxInvoiceTradeLineItem>
<SequenceNumeric>1</SequenceNumeric>
<InvoiceAmount>200000000</InvoiceAmount>
<TotalTax>
<CalculatedAmount>20000000</CalculatedAmount>
</TotalTax>
</TaxInvoiceTradeLineItem>
</TaxInvoice>
--2. sucess ----------- xml ---------remove namespace---------------------
<?xml version="1.0" encoding="UTF-8"?>
<TaxInvoice>
<ExchangedDocument>
<IssueDateTime>20110810133213</IssueDateTime>
<ReferencedDocument>
<ID>318701-0002</ID>
</ReferencedDocument>
</ExchangedDocument>
<TaxInvoiceDocument>
<IssueID>201106294100</IssueID>
<TypeCode>0101</TypeCode>
<IssueDateTime>20110810</IssueDateTime>
<PurposeCode>02</PurposeCode>
</TaxInvoiceDocument>
<TaxInvoiceTradeLineItem>
<SequenceNumeric>1</SequenceNumeric>
<InvoiceAmount>200000000</InvoiceAmount>
<TotalTax>
<CalculatedAmount>20000000</CalculatedAmount>
</TotalTax>
</TaxInvoiceTradeLineItem>
</TaxInvoice>
---------- program ------------
procedure insert_table
l_clob clob,
wellformed out boolean,
error out varchar2
is
l_parser dbms_xmlparser.Parser;
xmldoc xmldom.domdocument;
l_doc dbms_xmldom.DOMDocument;
l_nl dbms_xmldom.DOMNodeList;
l_n dbms_xmldom.DOMNode;
l_root DBMS_XMLDOM.domelement;
l_node DBMS_XMLDOM.domnode;
l_node2 DBMS_XMLDOM.domnode;
l_text DBMS_XMLDOM.DOMTEXT;
buf VARCHAR2(30000);
xmlparseerror exception;
TYPE tab_type is Table of xml_upload%ROWTYPE;
t_tab tab_type := tab_type();
pragma exception_init(xmlparseerror, -20100);
l_node_name varchar2(300);
begin
l_parser := dbms_xmlparser.newParser;
l_doc := DBMS_XMLDOM.newdomdocument;
dbms_xmlparser.parseClob(l_parser, l_clob);
l_doc := dbms_xmlparser.getDocument(l_parser);
l_n := dbms_xmldom.makeNode(l_doc);
l_nl := dbms_xslprocessor.selectNodes(l_n, '/TaxInvoice/TaxInvoiceDocument');
FOR cur_tax In 0..dbms_xmldom.getLength(l_nl) - 1 LOOP
l_n := dbms_xmldom.item(l_nl, cur_tax);
t_tab.extend;
t_tab(t_tab.last).ed_id := '5000000';
dbms_xslprocessor.valueOf(l_n, 'IssueID/text()', t_tab(t_tab.last).tid_issue_id);
dbms_xslprocessor.valueOf(l_n, 'TypeCode/text()', t_tab(t_tab.last).tid_type_code);
END LOOP;
FORALL i IN t_tab.first .. t_tab.last
INSERT INTO xml_upload VALUES t_tab(i);
COMMIT;
dbms_xmldom.freeDocument(l_doc);
wellformed := true;
exception
when xmlparseerror then
--xmlparser.freeparser(l_parser);
wellformed := false;
error := sqlerrm;
end insert_table;l_nl := dbms_xslprocessor.selectNodes(l_n, '/TaxInvoice/TaxInvoiceDocument');try to change as follow
l_nl := dbms_xslprocessor.selectnodes(l_n,'/TaxInvoice/TaxInvoiceDocument','xmlns="urn:kr:or:kec:standard:Tax:ReusableAggregateBusinessInformation:1:0"');Edited by: AlexAnd on Aug 17, 2011 12:36 AM -
Is there a linear equation VI that I can use for inputting the coefficients with variables attached to them? I am currently studying elec engineering and am in the thick of transient analysis. It is very time consuming figuring the mesh and nodal analysis in the transform domain. With 3 branches in a mesh analysis the resistors, inductors and capacitors are represented with variable s in them. I need to determine in the transform domain then convert to the time domain. One equation goes like this: (3+2s+1/4s)i1s - (2s)i2s - (1/4s)i3s = 6/s -6. The other equations are similar. I must keep the variable s in the equation and solve it with s in the result. I made several VIs for determining simultaneous linear equations some for complex numbers and they work great. This one has me a little stumped. I thinking that maybe Labview doesn't have a VI for this. The other VIs were fine because you just plugged in the numbers and ran the VI and got your result. Any VIs that do LaPlace transform operations?
Thank you.
TomHello Tom,
You can find a VI for doing Laplace transforms in Functions->Analyze->Signal Processing->Frequency Domain (this VI is only available in the Full and Professional versions).
You may also find the following tutorial of help in working with linear systems in LabVIEW.
Linear Systems in LabVIEW
Keep up to date on the latest PXI news at twitter.com/pxi -
i lost my macbook pro and i just got a new one. how can i retrieve the pictures taken with photo booth(old laptop) to my new laptop?
Well if you don't have the laptop to get the storage drive out of it, and you don't have any previous backups how do you expect to get the photo's?
PhotoBooth is just a program, it stores the files on the computers storage drive, if the computer is lost so are your photo's.
There is nothing you can do to delete or retrieve them using your new computer unless you stored them online someplace.
DId you save them online? iDisk or something else?
I don't use such services because my data is mine and not theirs to snoop through, so if your looking for that sort of help I can't assist you any. -
Pivot table with variables columns
I need a helo to pivot table with variable columns,
I have a pivot table :
SELECT a.*
FROM (SELECT codigo_aluno,nome_aluno , id_curso,dia FROM c_frequencia where dia like '201308%') PIVOT (sum(null) FOR dia IN ('20130805' ,'20130812','20130819','20130826')) a
but I need to run the select with values for dia , getting from a other table :
SELECT a.*
FROM (SELECT codigo_aluno,nome_aluno , id_curso,dia FROM c_frequencia where dia like '201308%') PIVOT (sum(null) FOR dia IN (
select dia from v_dia_mes )) a
thank youThe correct answer should be "Use the Pivoted Report Region Plugin".
But, as far as I know, nobody has created/posted that type of APEX plugin.
You may have to use a Basic Report (not an IR) so that you can use "Function returning SELECT" for your Source.
You would need two functions:
One that dynamically generates the Column Names
One that dynamically generates the SELECT statement
These should be in a PL/SQL Package so that the later can call the former to ensure that the column data matches the column names.
i.e. -- no 'SELECT *'
MK -
How can I reference the last value in a column?
How can I reference the last value in a column? For example, today I want the value of A1 to appear in another cell. Tomorrow, I will add a row and want to reference A2, next day A3, and so forth.
Now I got it:
=OFFSET(A1,COUNT(A)-1,0) -
Oracle 10g database
I have 2 rows in table
at_id
emp_id
at_date
time_in
time_out
status
00041
14/06/2013
0925
02
25
00041
14/06/2013
1400
02
I want to select Min(time_in) value with all column.
if I write this query all row shows:-
select at_id,emp_id,at_date,min(time_in) timein,time_out,status from t
group by at_id,emp_id,at_date,time_out,status;
I need
at_id
emp_id
at_date
time_in
time_out
status
00041
14/06/2013
0925
02You could try analytics as well:
with xx as ( select at_id,emp_id,at_date,time_in,time_out,status,
row_number() over (partition by at_id, emp_id, at_date, status
order by time_in desc nulls last ) rnum
from t)
Select at_id, emp_id, at_date, time_in, time_out, status
from xx
where rnum = 1; -
Is there any way to spool with variable column size?
Hi, I'm spooling to a CSV file with the following script (the real SELECT is different but similar, Oracle 10.2.0.3.0):
SET COLSEP ';'
SET FEEDBACK OFF
SET LINESIZE 2000
SET PAGESIZE 0
SET TERMOUT OFF
SET TRIMSPOOL ON
SET VERIFY OFF
SPOOL test.csv REPLACE
SELECT 'COLUMN1', 'COLUMN2', 'COLUMN3' FROM dual UNION ALL
SELECT 'value1', NULL, NULL FROM dual UNION ALL
SELECT 'value2', NULL, NULL FROM dual;
SPOOL OFF
EXIT SUCCESS COMMITThis produces the following output:
COLUMN1;COLUMN2;COLUMN3
value1 ; ;
value2 ; ;Is there any way to get the following output with variable column size
COLUMN1;COLUMN2;COLUMN3
value1;;
value2;;I've tried SET NULL '' but I see no difference. Thanks in advance!
MarkusIn short, No, because SQL*Plus is laying out the data in columns.
You could either combine the data into a single column by concatenating as strings or use some other method e.g.
As sys user:
CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
/As myuser:
CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
,p_dir IN VARCHAR2
,p_header_file IN VARCHAR2
,p_data_file IN VARCHAR2 := NULL) IS
v_finaltxt VARCHAR2(4000);
v_v_val VARCHAR2(4000);
v_n_val NUMBER;
v_d_val DATE;
v_ret NUMBER;
c NUMBER;
d NUMBER;
col_cnt INTEGER;
f BOOLEAN;
rec_tab DBMS_SQL.DESC_TAB;
col_num NUMBER;
v_fh UTL_FILE.FILE_TYPE;
v_samefile BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
BEGIN
c := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
d := DBMS_SQL.EXECUTE(c);
DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
ELSE
DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
END CASE;
END LOOP;
-- This part outputs the HEADER
v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
FOR j in 1..col_cnt
LOOP
v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
END LOOP;
-- DBMS_OUTPUT.PUT_LINE(v_finaltxt);
UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
IF NOT v_samefile THEN
UTL_FILE.FCLOSE(v_fh);
END IF;
-- This part outputs the DATA
IF NOT v_samefile THEN
v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
END IF;
LOOP
v_ret := DBMS_SQL.FETCH_ROWS(c);
EXIT WHEN v_ret = 0;
v_finaltxt := NULL;
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
ELSE
v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
END CASE;
END LOOP;
-- DBMS_OUTPUT.PUT_LINE(v_finaltxt);
UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
END LOOP;
UTL_FILE.FCLOSE(v_fh);
DBMS_SQL.CLOSE_CURSOR(c);
END;This allows for the header row and the data to be written to seperate files if required.
e.g.
SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
PL/SQL procedure successfully completed.Output.txt file contains:
empno,ename,job,mgr,hiredate,sal,comm,deptno
7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10The procedure allows for the header and data to go to seperate files if required. Just specifying the "header" filename will put the header and data in the one file.
Adapt to output different datatypes and styles are required. -
How can I add cursor attribute values or change the size?
I am using the SetCursorAttribute and would like to create and add additional cursor attribute values insteasd of the current 24 that are available. In particular, I would like to number each cursor in my list to each cursor on a graph so it can be identified easily by the user. Making each cursor a different value from the available 24 Attribute Value's is not desired since they are not easily identified due to the size of the cursor. (it's hard to discern a square box to a square box with an X).
OR
Another possiblity could be to allow for modification of the current size of the Attribute Values, is this possible?Hi Dennis,
Unfortunately there is currently no way to change the size of a graph cursor, or to beyond the 24 point styles you mentioned. However, there are many other ways to differentiate cursors beyond point style. You can use differing crosshair styles and colors. Additionally, you can use "PlotBitmap(...)" to plot a bitmap image to the control using relative X and Y coordinates. With a little creative programming, you can use this function to simulate a graph cursor.
regards,
Eric Meyer
Applications Engineer
National Instruments -
Upload of Excel File with variable columns
Hi All,
I have a requirement where i have to upload xls file into SAP. This xls file has 10 rows fixed but the columns may vary from 20 to 400.
For Ex : My xls file has 10 rows and 27 columns filled at present. But in future columns can vary to 400 or more than that also.
So when i use ALSM_EXCEL_TO_INTERNAL_TABLE as
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = p_fname
I_BEGIN_COL = 1
I_BEGIN_ROW = 1
I_END_COL = 400
I_END_ROW = 10
TABLES
INTERN = itab1
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3
It throws SY_SUBRC = 2.
Please let me know how i can solve this issue.
Thanks,Hi Ashwani,
I will send a sample code for ur problem.Please the check the function modules i have used and procedure i followed.My function modules can work for any no.of rows and columns ok..check it once..
Along with my code i am sending a flat file.plz copy the code and execute it and debug it ok..i will attach flat file at the end of the program check it once ok...
code:
*& Report YBDC_UPLOAD_MM01_XLS *
*& DEVELOPER : KIRAN KUMAR.G *
*& PURPOSE : MAKE CHANGES TO DOWNLOADED FILE AND UPLOAD THE FILE *
*& CREATION DT: 3/12/2007 *
*& REQUEST : ERPK900035 *
REPORT YBDC_UPLOAD_MM01_XLS.
Tables
TABLES : mara. "General Material Data
Global BDCDATA Structure and MESSAGE Structure
DATA: gt_bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE,
gt_msgtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
Global Variables
DATA: gv_infile TYPE string,
gv_msg TYPE string,
gv_update VALUE 'A'.
Internal Table
DATA: BEGIN OF gt_data OCCURS 0,
matnr(20), "Material Number
mbrsh(20), "Account Group
mtart(20), "Material Type
meins(20), "Base Unit Of Measure
maktx(20), "Material Description
END OF gt_data.
Selection-screen
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_file LIKE rlgrap-filename,
p_mode.
SELECTION-SCREEN : END OF BLOCK b1.
Select the File
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM fetch_file.
START-OF-SELECTION.
Fetch Data From XLS File
PERFORM fetch_data.
Fetch Data From XLS File
PERFORM delete_headerinfo.
Fetch Data From XLS File
PERFORM place_data.
*& Form fetch_file
text
--> p1 text
<-- p2 text
FORM fetch_file .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
FIELD_NAME = ' '
IMPORTING
file_name = p_file.
gv_infile = p_file.
ENDFORM. " fetch_file
*& Form fetch_data
text
--> p1 text
<-- p2 text
FORM fetch_data .
refresh : gt_data. "Clear Body Of the Internal Table
clear : gt_data. "Clear Header Line
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = gv_infile
filetype = 'ASC'
has_field_separator = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
data_tab = gt_data
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
ENDFORM. " fetch_data
*& Form place_data
text
--> p1 text
<-- p2 text
FORM place_data .
LOOP AT gt_data.
PERFORM bdc_dynpro USING 'SAPLMGMM' '0060'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RMMG1-MATNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=AUSW'.
PERFORM bdc_field USING 'RMMG1-MATNR'
gt_data-matnr.
PERFORM bdc_dynpro USING 'SAPLMGMM' '0070'.
PERFORM bdc_field USING 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
PERFORM bdc_field USING 'MSICHTAUSW-KZSEL(01)'
'X'.
PERFORM bdc_dynpro USING 'SAPLMGMM' '4004'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BU'.
PERFORM bdc_field USING 'BDC_CURSOR'
'MAKT-MAKTX'.
PERFORM bdc_field USING 'MAKT-MAKTX'
gt_data-maktx.
PERFORM bdc_field USING 'MARA-MTPOS_MARA'
'NORM'.
CALL TRANSACTION 'MM02' USING gt_bdcdata MODE p_mode
UPDATE gv_update
MESSAGES INTO gt_msgtab.
*For Error Messages Handling.
LOOP AT gt_msgtab.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = sy-msgid
lang = sy-langu
no = sy-msgno
v1 = sy-msgv1
v2 = sy-msgv2
v3 = sy-msgv3
v4 = sy-msgv4
IMPORTING
msg = gv_msg
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF sy-tabix = 1.
WRITE: / 'Process Log' COLOR 3.
ENDIF.
WRITE:/ gv_msg.
ENDLOOP.
REFRESH gt_msgtab.
REFRESH gt_bdcdata.
ENDLOOP.
ENDFORM. " place_data
Start new screen *
FORM bdc_dynpro USING program dynpro.
CLEAR gt_bdcdata.
gt_bdcdata-program = program.
gt_bdcdata-dynpro = dynpro.
gt_bdcdata-dynbegin = 'X'.
APPEND gt_bdcdata.
ENDFORM. "BDC_DYNPRO
Insert field *
FORM bdc_field USING fnam fval.
CLEAR gt_bdcdata.
gt_bdcdata-fnam = fnam.
gt_bdcdata-fval = fval.
APPEND gt_bdcdata.
ENDFORM. "BDC_FIELD
*& Form delete_headerinfo
text
--> p1 text
<-- p2 text
FORM delete_headerinfo .
DELETE gt_data INDEX 1.
ENDFORM. " delete_headerinfo
FLAT FILE
*MATERIAL NUMBER INDUSTRY SECTOR MATERIAL TYPE BASE UNIT OF
*MEASURE MATERIAL DESCRIPTION
*806 M FERT CM IRON
*807 M HALB KG STEEL
*808 M HAWA KG IRON
Reward points if helpful
Kiran Kumar.G.A
Have a nice day... -
How can I define that the value of a column should always be in UPPER case
Hi,
I want to make sure that the value in a column is always in UPPER case.
Can we give this condition while creating or altering a table.
A trigger can do it easily, but I was wondering if we could define a column to have values with upper case all the time, independent of what values are inserted. I mean if we give a lower case value in the insert statement, it should be converted automatically to upper case & stored.
I want something like
Alter table MY_TABLE Modify ( col1_upper varchar2(25) default UPPER(Col1_upper));
But the above statement does not work as it references the col of the table.
Thanks
SunilWell, you can put a check constraint on to prevent someone from putting lowercase data in:
alter table my_table add constraint my_table_check_upper check (col1_upper = upper(col1_upper));However, I know of no way to modify the data being inserted/updated in a table without a trigger.
Richard -
Hi All,
I have to do a ALV with variable no. of columns. i.e Depending on the data , the columns should get populated.
Thanks in advance.
DnyaneshHi Dnyanesh,
If you know the no. of columns to be used in the ALV before hand then you can change the field catalog.
but if you dont know the no. of columns then you can create dynamic table.
eg:
1. Create your field catalog either manually or automatically using the function module, LVC_FIELDCATALOG_MERGE. Add more rows to the field catalog table (T_FIELDCAT) at run time.
2. Use the field catalog to create a table dynamically using the method below.
DATA: T_OUTPUT TYPE REF TO DATA
FIELD-SYMBOLS: <T_OUTPUT> TYPE TABLE
Call Method CL_ALV_TABLE_CREATE->CREATE_DYNAMIC_TABLE
Exporting
IT_FIELDCATALOG = T_FIELDCAT
Importing
EP_TABLE = T_OUTPUT
ASSIGN T_OUTPUT->* TO <T_OUTPUT>.
Now the field symbol <T_OUTPUT> is pointing to an output table of the structure that contains the fields which were determined at runtime. Now fill this table with the data and pass <T_OUTPUT> to the method SET_TABLE_FOR_FIRST_DISPLAY and the ALV grid should show the data properly.
Example:
*the content of itab will be fields of the new table
loop at itab1 into wa1.
Gs_FIELDCAT-TABNAME = 'itab2'.
GS_FIELDCAT-FIELDNAME = wa1-packid.
GS_FIELDCAT-OUTPUTLEN = 2.
GS_FIELDCAT-KEY = space.
GS_FIELDCAT-SELTEXT_L = wa1-packid.
GS_FIELDCAT-COL_POS = 1.
GS_FIELDCAT-JUST = 'L'.
APPEND GS_FIELDCAT TO GT_FIELDCAT.
endloop.
LOOP AT GT_FIELDCAT INTO GS_FIELDCAT.
MOVE-CORRESPONDING GS_FIELDCAT TO ls_fcat.
APPEND ls_fcat TO lt_fieldcat.
ENDLOOP.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING it_fieldcatalog = lt_fieldcat
IMPORTING ep_table = t_output.
you can refer the following link also.
ALV grid
hope this helps.
do get back if you need further clarification.
Regards,
Kinshuk -
SQL to align child values with parent columns
Hi everyone,
I'm stumped on how to develop an sql query that generates a report where my child values are aligned with my parent columns based on matching years. Here's the example...
create table test_yr (yr_id number primary key, yr_nb number);
insert into test_yr values (1,2013);
insert into test_yr values (2,2014);
insert into test_yr values (3,2015);
create table test_parent (parent_id number primary key, parent_yr_id_begin number, parent_title varchar2(100));
alter table test_parent add foreign key (parent_yr_id_begin) refererences test_yr (yr_id);
insert into test_parent values (1,1,'This rec starts in 2013');
create table test_child (
child_id number primary key,
child_parent_id number,
child_yr_id_begin number,
child_title varchar2(100),
child_yr1_val number, child_yr2_val number, child_yr3_val number, child_yr4_val number, child_yr5_val number
alter table test_child add foreign key (child_parent_id) references test_parent (parent_id);
alter table test_child add foreign key (child_yr_id_begin) references test_yr (yr_id);
insert into test_child values (1,1,3,'This rec starts in 2015',10,20,30,40,50);
insert into test_child values (2,1,3,'This rec starts in 2015',15,25,35,45,55);
The child can start at a different begin year than the parent, making yr1 for parent and yr1 for child different. So for this example, year 1 of the child (2015) = year 3 of the parent.
I can get the values strictly from the child using the following...
select child_yr1_val, child_yr2_val, child_yr3_val, child_yr4_val, child_yr5_val
from test_child
where child_parent_id = 1;
However, I need the report to be based off of the first five years of the parent. And since the child doesn't start until 2015, the first two years should be zero. Here is the expected result:
yr1 | yr2 | yr3 | yr4 | yr5
0 | 0 | 10 | 20 | 30
0 | 0 | 15 | 25 | 35
I'm trying to do this using plain sql without having to use pl/sql to derive a dynamic query. But I need to somehow match up and align the years... such as in this example, yr1(child) = yr3(parent), yr2(child) = yr4(parent), etc. I'm hoping some joins and case statements will do the trick, but I don't quite know how to utilize them to get the result I need. Can anyone help? Oracle 11gR2.
Thanks,
MarkHi,
oramark14 wrote:
Hi Frank,
Thanks so much for your reply! I'll try to digest this solution and implement it this weekend. I also agree completely about the table design... I know apps shouldn't drive database design, ...
If you get indigestion, feel free to ask questions here.
The SELECT ... PIVOT feature isn't very convenient for dealing with missing values. You may prefer to change the main query like this:
WITH unpivoted_child AS
SELECT child_id, child_parent_id
, child_yr_id_begin + child_yr - 1 AS column_num
, val
FROM test_child
UNPIVOT ( val
FOR child_yr IN ( child_yr1_val AS 1
, child_yr2_val AS 2
, child_yr3_val AS 3
, child_yr4_val AS 4
, child_yr5_val AS 5
WHERE child_parent_id = 1
SELECT NVL (SUM (CASE WHEN column_num = 1 THEN val END), 0) AS yr1
, NVL (SUM (CASE WHEN column_num = 2 THEN val END), 0) AS yr2
, NVL (SUM (CASE WHEN column_num = 3 THEN val END), 0) AS yr3
, NVL (SUM (CASE WHEN column_num = 4 THEN val END), 0) AS yr4
, NVL (SUM (CASE WHEN column_num = 5 THEN val END), 0) AS yr5
FROM unpivoted_child
GROUP BY child_parent_id
, child_id
ORDER BY child_parent_id
, child_id
Also, if you want to see how SELECT ... PIVOT works, this can help show you.
Having 5 separate columns for input can be very conveninet, just like having 5 separate columns for display. But, as you said, that shouldn't drive the table design. If necessary, you could create a view that has 5 separate val columns, like your current table, and write an INSTEAD OF trigger for user input. -
Question about creating a report with variable columns
Post Author: Archmage
CA Forum: General
Hi,
Is there a way to create a Crystal report based on the following situation?
Run a stored procedure with two date parameters:
If you run from 9/1/07 to 9/30/07, then the data result would be as follows: (example only) and the report format would follow
Cust Sept 07
AB100 2000
If run from 8/01/07 to 9/30/07
Cust Aug 07 Sept 07
AB100 1000 2000
if run from 7/01/07 to 9/30/07
Cust July 07 Aug 07 Sept 07
AB100 1000 1000 2000
So Basically, based on the parameters chosen, it could be a report with one, two, three, or even 40 columns, each column representing the month.
Thanks for any ideasPost Author: Archmage
CA Forum: General
Does this require that the stored procedure has already created the different columns by month first? Or can the raw data be a three column source
like
CUSTNO DATE AMT
AA100 8/1/07 1000
AA100 9/1/07 2000
AA100 10/1/07 2500
And checking the format with multiple columns will create the Crystal report like:
CustNo Aug 07 Sept 07 Oct 07
AA100 1000 2000 2500 -
How can I make a text box with 2 columns?
I can't figure out how to make a text box with two columns. I made one in pages and pasted it into iWeb but it seems to have turned it into an image when I published to a folder. I want to keep it text so the search engines will index it.
Any suggestions would be greatly appreciated.
Thanks, DavidYou will have to create two text boxes, configure them as columns and then paste into the first and cut where you want the columns to end and paste the remainder into the second column as on this page . I've tried saving a two column Word document as a web page and it just converts it to one column.
OT
Maybe you are looking for
-
QT Pro "Open Image Sequence" only grabs one image
QuickTime Pro: When I try to "Open Image Sequence" on a set of .png images, I don't get the request for a frame rate, and it only opens the first image. (Actually, the frame rate request window may be flashing by quickly.) I have the image files numb
-
Network in Finder vs Connect To
Hey guys, I was just wondering if there was any reason why I can go Finder > Connect To Server and then connect to the server, however in Finder > Network - that computer doesn't show up. I have my Rev C 2.1ghz iMac G5 as our base station at home, a
-
Backup Problem on Lifeblog 2.5
hi! my phone model is n70 and i've got all the data saved nicely in lifeblog 2.5.i'm changing my computer so i decided to backup all the data with the option backup data from lifeblog.the problem is that when saving object 509 from 2075 it stop and s
-
Can not copy links with firefox ...
I use Firefox to play a ton of games on Face Book. When ever I right click on a link to copy it and send to others, it doesn't work. This has been going on for several weeks. I thought it was my computer but have discovered that Safari lets me copy t
-
IPhone error message in iTunes, frozen iPhone
Bit of background, I have to iPhone 3GS with 4.1.something. The computer it's synced to is running windows XP. Two weeks ago my lock button stopped working, I now have to leave it out for a minute to lock (although the button still works when the pho