How tu update a column having type 'Long raw' in oracle table with an image
Hello,
I must change the image loading in a column with 'long raw' type in the table. I find an image data already in the table.
I have my new imgae in a file .bmp.
What SQL instruction I mut use to update this column to load my new image ?
I work in Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod.
thanks for your helps.
Regards.
Unless I'm missing something MSFT are making it unecessarily complex by not implementing the SQL/XML standard...
SQL> alter table emp add ( emp_xml xmltype)
2 /
Table altered.
SQL> update emp set emp_xml = XMLELEMENT("EMPLOYEE",xmlattributes(EMPNO as "id"), XMLElement("Name",ENAME))
2
SQL> /
14 rows updated.
SQL> set pages 0
SQL> select EMPNO, EMP_XML from EMP
2 /
7369
<EMPLOYEE id="7369">
<Name>SMITH</Name>
</EMPLOYEE>
7499
<EMPLOYEE id="7499">
<Name>ALLEN</Name>
</EMPLOYEE>
7521
<EMPLOYEE id="7521">
<Name>WARD</Name>
</EMPLOYEE>
7566
<EMPLOYEE id="7566">
<Name>JONES</Name>
</EMPLOYEE>
7654
<EMPLOYEE id="7654">
<Name>MARTIN</Name>
</EMPLOYEE>
7698
<EMPLOYEE id="7698">
<Name>BLAKE</Name>
</EMPLOYEE>
7782
<EMPLOYEE id="7782">
<Name>CLARK</Name>
</EMPLOYEE>
7788
<EMPLOYEE id="7788">
<Name>SCOTT</Name>
</EMPLOYEE>
7839
<EMPLOYEE id="7839">
<Name>KING</Name>
</EMPLOYEE>
7844
<EMPLOYEE id="7844">
<Name>TURNER</Name>
</EMPLOYEE>
7876
<EMPLOYEE id="7876">
<Name>ADAMS</Name>
</EMPLOYEE>
7900
<EMPLOYEE id="7900">
<Name>JAMES</Name>
</EMPLOYEE>
7902
<EMPLOYEE id="7902">
<Name>FORD</Name>
</EMPLOYEE>
7934
<EMPLOYEE id="7934">
<Name>MILLER</Name>
</EMPLOYEE>
14 rows selected.
SQL>
Similar Messages
-
Insert data 32K into a column of type LONG using the oracle server side jdbc driver
Hi,
I need to insert data of more than 32k into a
column of type LONG.
I use the following code:
String s = "larger then 32K";
PreparedStatement pstmt = dbcon.prepareStatement(
"INSERT INTO TEST (LO) VALUES (?)");
pstmt.setCharacterStream(1, new StringReader(s), s.length());
pstmt.executeUpdate();
dbcon.commit();
If I use the "standard" oracle thin client driver from classes_12.zip ("jdbc:oracle:thin:@kn7:1521:kn7a") every thing is working fine. But if I use the oracle server side jdbc driver ("jdbc:default:connection:") I get the exception java.sql.SQLException:
Datasize larger then max. datasize for this type: oracle.jdbc.kprb.KprbDBStatement@50f4f46c
even if the string s exceeds a length of 32767 bytes.
I'm afraid it has something to do with the 32K limitation in PL/SQL but in fact we do not use any PL/SQL code in this case.
What can we do? Using LOB's is not an option because we have client software written in 3rd party 4gl language that is unable to handle LOB's.
Any idea would be appreciated.
Thomas Stiegler
nullIn rdbms 8.1.7 "relnotes" folder, there is a "Readme_JDBC.txt" file (on win nt) stating
Known Problems/Limitations In This Release
<entries 1 through 3 omiited for brevity >
4. The Server-side Internal Driver has the following limitation:
- Data access for LONG and LONG RAW types is limited to 32K of
data. -
Copy Long raw from oracle table to table
Hi
I am wondering if someone help me to move (copy) long raw data from one table to another. I want to do:
select long_raw_data from table1;
insert into table2 values (previously selected long raw value).
I wrote the following small java code, but it doesn't work. I get the following exception:
java.sql.SQLException: ORA-00936: missing expression.
---------- Code: ---------
import java.net.URL;
import java.sql.*;
class myJDBC
public static void main (String args[])
try {
Class.forName ("oracle.jdbc.driver.OracleDriver");
String url = "jdbc:oracle:thin:@test:1521:devtest";
Connection con = DriverManager.getConnection (url, "test", "test");
Statement stmt = con.createStatement ();
Statement insStmt = con.createStatement ();
ResultSet res = stmt.executeQuery (
"SELECT resume_data FROM resume where rownum < 26 ");
while (res.next ()) {
byte[] bytes = res.getBytes(1);
insStmt.executeUpdate("INSERT INTO TMP_RESUME VALUES (" + bytes + ")");
// clean-up
stmt.close ();
con.close ();
catch (Exception e) {
System.out.println (e.getMessage ());
e.printStackTrace ();
------------ Code ends ---------------
Thanks for your help
V Prakashuse PreparedStatement :
PreparedStatement insStmt = connect.prepareStatement("INSERT INTO TMP_RESUME VALUES (?)");
while (res.next ())
byte[] bytes = res.getBytes(1);
insStmt.setBytes(1,bytes);
insStmt.executeUpdate();
I don't remember very querys with ORACLE,
but you may be do this in one time with
SELECT ...... INTO ....
or
INSERT ..... INTO ..... SELECT
One of this is valid for ORACLE and the other for SYBASE ... -
How to update ordered list having a constraint
hi friends,
I have to update a column for all the records in the table with a unique contraint
ex-- select rec_no from tablename;
9
8
7
6
5
now i have to update this like
select rec_no from tablename;
8
7
6
5
4
but when i am doing update tablename set rec_no=rec_no-1
i am getting unique constraint error
plz help medj wrote:
but when i am doing update tablename set rec_no=rec_no-1
i am getting unique constraint error
No you don't. Show us.
Oracle ensures "statement level constraint" consistency. If you do this in one update statement (which is what you state above), then Oracle will not give you a constraint error.
For if it did, then we all would have a serious problem: whether or not the update succeeds would then depend on the order in which Oracle (ie. the execution plan) happens to update the rows. And we can't have such 'undeterministic' behavior (similar to what we would have when Oracle did not provide us with the mutating table error...).
So just try it, or show us:
create table uk_test
(i number not null unique)
insert into uk_test values(4);
insert into uk_test values(3);
insert into uk_test values(2);
commit;Now try both of these:
update (select * from uk_Test order by i desc) set i=i-1;
update (select * from uk_Test order by i) set i=i-1;They both succeed. Oracle allows temporary constraint violations during/inside the execution of one statement. There is no need to set this constraint to deferred here.
I talk about statement level constraint consistency here too:
http://rulegen.blogspot.nl/2012/01/statement-level-constraint-validation.html -
Hi everyone, again landed up with a problem.
After trying a lot to do it myself, finally decided to post here..
I have created a form in form builder 6i, in which on clicking a button the data gets exported to excel sheet.
It is working fine with a single table. The problem now is that i am unable to do the same with 2 tables.
Because both the tables have same number of columns & column names.
Below are 2 tables with column names:
Table-1 (MONTHLY_PART_1)
Table-2 (MONTHLY_PART_2)
SL_NO
SL_NO
COMP
COMP
DUE_DATE
DUE_DATE
U-1
U-1
U-2
U-2
U-4
U-4
U-20
U-20
U-25
U-25
Since both the tables have same column names, I'm getting the following error :
Error 402 at line 103, column 4
alias required in SELECT list of cursor to avoid duplicate column names.
So How can i export the data to excel which has 2 tables with same number of columns & column names?
Should i paste the code? Should i post this query in 'SQL and PL/SQL' Forum?
Help me with this please.
Thank You.You'll have to *alias* your columns, not prefix it with the table names:
$[CHE_TEST@asterix1_impl] r
1 declare
2 cursor cData is
3 with data as (
4 select 1 id, 'test1' val1, 'a' val2 from dual
5 union all
6 select 1 id, '1test' val1, 'b' val2 from dual
7 union all
8 select 2 id, 'test2' val1, 'a' val2 from dual
9 union all
10 select 2 id, '2test' val1, 'b' val2 from dual
11 )
12 select a.id, b.id, a.val1, b.val1, a.val2, b.val2
13 from data a, data b
14 where a.id = b.id
15 and a.val2 = 'a'
16 and b.val2 = 'b';
17 begin
18 for rData in cData loop
19 null;
20 end loop;
21* end;
for rData in cData loop
ERROR at line 18:
ORA-06550: line 18, column 3:
PLS-00402: alias required in SELECT list of cursor to avoid duplicate column names
ORA-06550: line 18, column 3:
PL/SQL: Statement ignored
$[CHE_TEST@asterix1_impl] r
1 declare
2 cursor cData is
3 with data as (
4 select 1 id, 'test1' val1, 'a' val2 from dual
5 union all
6 select 1 id, '1test' val1, 'b' val2 from dual
7 union all
8 select 2 id, 'test2' val1, 'a' val2 from dual
9 union all
10 select 2 id, '2test' val1, 'b' val2 from dual
11 )
12 select a.id a_id, b.id b_id, a.val1 a_val1, b.val1 b_val1, a.val2 a_val2, b.val2 b_val2
13 from data a, data b
14 where a.id = b.id
15 and a.val2 = 'a'
16 and b.val2 = 'b';
17 begin
18 for rData in cData loop
19 null;
20 end loop;
21* end;
PL/SQL procedure successfully completed.
cheers -
How to insert data from file into long raw field using utl_file?
I try to insert binary data from a file (under AIX 4.3.3) into a LONG
RAW field (Oracle 8.1.6).
First, I retrieve the data from the file like this:
DECLARE
FileHandle = UTL_FILE.FILE_TYPE;
myVariable LONG RAW;
FileHandle := UTL_FILE.FOPEN ;('prj/oracle/admin/MARTIJN/udump',
'MyFile.ATT', 'R');
UTL_FILE.GET_LINE (FileHandle, myVariable);
UTL_FILE.FCLOSE(FileHandle);
INSERT INTO myTable(DUMMYFIELD) VALUES(myVariable);
Where DUMMYFIELD of table myTable is of type LONG RAW.
The GET_LINE statement crashes on Oracle Error ORA-6502: Numeric of
Value error: hex to raw conversion error.
What do I do wrong?
Do I use the right method to retrieve information from a file and put
it into a long raw field, should I try it another way?
Any help greatly appreciated,
Martijn RutteZarina,
To clarify your problem, you have a script node contaning your Matlab code. Are you then using the standard LV functions to load in your data from a file and pass it into the script node?
Regards
Tristan -
How to have Dynamic Columns based on Work centers in CRHD table?
i need to create dynamic internal table......based on the number of entries(work centers ) in CRHD table....this is number of work centers...like how many manufac unit....How to have the work center names at heading and how to fill values at rows...as the number of workcenters may differ dynamic.....how to fill the values...for a dynamic internal table
Hi Meena,
For Dynamic display ,go through it
REPORT yusmm_text1 NO STANDARD PAGE HEADING
LINE-SIZE 199.
T A B L E S
TABLES: MARA,
MAKT,
THEAD.
GLOBAL TYPE-POOLS
TYPE-POOLS : SLIS.
GLOBAL TYPES
TYPES : BEGIN OF TP_FINAL,
MATNR TYPE MARA-MATNR,
BEGRU TYPE MARA-BEGRU,
MTART TYPE MARA-MTART,
MAKTX TYPE MAKT-MAKTX,
SPRAS TYPE MAKT-SPRAS,
LTXT(2000) TYPE C ,
SRNO TYPE N ,
END OF TP_FINAL.
TYPES : BEGIN OF TP_T002,
SPRAS TYPE T002-SPRAS,
LAISO TYPE T002-LAISO,
SRNO TYPE N ,
END OF TP_T002.
TYPES : BEGIN OF TP_MARA_MAKT,
MATNR TYPE MARA-MATNR,
BEGRU TYPE MARA-BEGRU,
MTART TYPE MARA-MTART,
SPRAS TYPE MAKT-SPRAS,
MAKTX TYPE MAKT-MAKTX,
END OF TP_MARA_MAKT.
Types: BEGIN OF tp_matnr,
matnr TYPE mara-matnr,
END OF tp_matnr.
GLOBAL ELEMENTARY VARIABLES
DATA : gv_date TYPE sy-datum.
DATA : gv_repid TYPE sy-repid.
DATA : g_var1(10) TYPE C.
DATA : gv_index TYPE sy-tabix.
DATA: gv_strg TYPE string,
gv_strg1(2000) TYPE C.
DATA : gv_lang TYPE sy-langu.
DATA : g_v(3) TYPE N .
DATA : gv_lines(3) TYPE N .
DATA : gv_var(3) TYPE N .
DATA : gv_var1(3) TYPE N.
DATA: gv_str TYPE STRING.
DATA: gv_str1 TYPE STRING.
DATA : gv_li TYPE I,
gv_lit TYPE I,
gv_lin TYPE I.
DATA: g_var11(3) TYPE N,
gv_li1(3) TYPE N,
g_var2(3) TYPE N.
DATA : gv_i1 TYPE I.
DATA : gv_i TYPE I.
DATA: gl_lenght TYPE I.
GLOBAL STRUCTURES
DATA: T_NEWTABLE TYPE REF TO DATA,
T_NEWLINE TYPE REF TO DATA,
T_FLDCAT1 TYPE SLIS_T_FIELDCAT_ALV,
T_FLDCAT TYPE LVC_T_FCAT,
WA_IT_FLDCAT TYPE LVC_S_FCAT,
WA_IT_FLDCAT1 TYPE SLIS_FIELDCAT_ALV,
WA_COLNO(2) TYPE N,
WA_FLNAME(5) TYPE C,
L_LT TYPE SLIS_LAYOUT_ALV.
GLOBAL INTERNAL TABLES (WITH INCLUDE STRUCTURE)
DATA : IG_MARA_MAKT TYPE STANDARD TABLE OF TP_MARA_MAKT,
WG_MARA_MAKT TYPE TP_MARA_MAKT.
DATA : IG_T002 TYPE STANDARD TABLE OF TP_T002,
WG_T002 TYPE TP_T002.
DATA : IG_FINAL TYPE STANDARD TABLE OF TP_FINAL,
WG_FINAL TYPE TP_FINAL.
data : IG_MATNR TYPE STANDARD TABLE OF TP_MATNR WITH HEADER LINE,
WG_MATNR TYPE TP_MATNR.
DATA:BEGIN OF IG_THEAD OCCURS 0.
INCLUDE STRUCTURE THEAD .
DATA: END OF IG_THEAD.
DATA:BEGIN OF IG_TLINE OCCURS 0.
INCLUDE STRUCTURE TLINE .
DATA:END OF IG_TLINE.
FIELD-SYMBOLS
FIELD-SYMBOLS: <T_DYNTABLE> TYPE STANDARD TABLE,"Dynamic internal
"tablename
<FS_DYNTABLE>, "Field symbol to create work area
<FS_FLDVAL> TYPE ANY. " Field symbol to assign values
COMPULSORY
FIELD-SYMBOLS: <FS_DATA> TYPE REF TO DATA,
<FS_DATA1> TYPE REF TO DATA,
<FS_2> TYPE STANDARD TABLE,
<FS_22> TYPE STANDARD TABLE,
<FS_1>,
<FS_11>,
<F>,
<FA>,
<LWA_LINE_WA>,
<LWA_LINE_WA1>.
------- Create Dyn Table From FC
DATA: LT_DATA TYPE REF TO DATA,
LT_DATA1 TYPE REF TO DATA,
LWA_LINE TYPE REF TO DATA,
LWA_LINE1 TYPE REF TO DATA,
LI_FIELD_CAT TYPE LVC_T_FCAT,
LWA_FIELD_CAT TYPE LVC_S_FCAT.
PARAMETERS & SELECT-OPTIONS
SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : S_SPRAS FOR MAKT-SPRAS NO INTERVALS DEFAULT 'EN'
OBLIGATORY ,
S_MATNR FOR MARA-MATNR,
S_MTART FOR MARA-MTART.
PARAMETERS: GP_SIZE TYPE I DEFAULT '200'.
SELECTION-SCREEN : END OF BLOCK B1.
INITIALIZATION
INITIALIZATION.
gv_repid = sy-repid.
gv_date = sy-datum.
AT SELECTION-SCREEN
AT SELECTION-SCREEN.
IF GP_SIZE < 0.
MESSAGE E002(00).
ENDIF.
IF GP_SIZE > 50000.
MESSAGE W130(26) WITH TEXT-004.
SET CURSOR FIELD 'gp_size'.
ENDIF.
START-OF-SELECTION
START-OF-SELECTION.
PERFORM FIELDCAT.
PERFORM LAYOUT.
PERFORM DATA_FETCH.
PERFORM READ_DATA_TO_FINAL.
SORT ig_final BY matnr spras.
gv_lin = gv_li.
gv_li = gv_li - 2.
LOOP AT ig_final INTO wg_final.
ASSIGN COMPONENT 1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
<FA> = 'Material Number'.
ASSIGN COMPONENT 2 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
<FA> = 'Authorization Group'.
g_VAR11 = wg_final-srno + 2.
gv_li1 = gv_li1 + 2.
MOVE : g_var11 TO gv_i1.
ASSIGN COMPONENT g_var11 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
<FA> = 'MatDesc'.
g_var2 = g_var11 + gv_lines.
ASSIGN COMPONENT g_var2 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
<FA> = 'BasicData'.
APPEND <LWA_LINE_WA1> TO <FS_22>.
EXIT.
ENDLOOP.
LOOP AT ig_final INTO wg_final.
AT NEW matnr.
gv_index = sy-tabix.
ASSIGN COMPONENT 1 OF STRUCTURE <LWA_LINE_WA> TO <F>.
<F> = wg_final-matnr.
ENDAT.
AT NEW MATNR.
GV_INDEX = SY-TABIX.
ASSIGN COMPONENT 1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
<FA> = wg_final-matnr.
ENDAT.
ASSIGN COMPONENT 2 OF STRUCTURE <LWA_LINE_WA> TO <F>.
<F> = wg_final-begru.
ASSIGN COMPONENT 2 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
<FA> = wg_final-begru.
gv_var = wg_final-srno + 2.
gv_li = gv_li + 2.
MOVE : gv_var TO gv_i.
ASSIGN COMPONENT gv_var OF STRUCTURE <LWA_LINE_WA> TO <F>.
<F> = wg_final-maktx.
ASSIGN COMPONENT gv_var OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
<FA> = wg_final-maktx.
gv_var1 = gv_var + gv_lines .
ASSIGN COMPONENT gv_var1 OF STRUCTURE <LWA_LINE_WA> TO <F>.
<F> = wg_final-ltxt.
ASSIGN COMPONENT gv_var1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
<FA> = wg_final-ltxt.
AT END OF matnr.
APPEND <LWA_LINE_WA> TO <FS_2>.
CLEAR <LWA_LINE_WA>.
ENDAT.
AT END OF matnr.
APPEND <LWA_LINE_WA1> TO <FS_22>.
CLEAR <LWA_LINE_WA1>.
ENDAT.
ENDLOOP.
PERFORM display..
*& Form data_fetch
text
--> p1 text
<-- p2 text
FORM DATA_FETCH .
SELECT matnr
from mara up to gp_size rows
appending corresponding fields of table ig_matnr
where matnr in s_matnr
and mtart in s_mtart.
loop at ig_matnr.
SELECT MARA~MATNR
MARA~BEGRU
MARA~MTART
MAKT~SPRAS
MAKT~MAKTX FROM MARA INNER JOIN MAKT
ON MARAMATNR = MAKTMATNR
appending corresponding fields of TABLE ig_mara_makt UP TO GP_SIZE
ROWS
WHERE makt~spras IN s_spras
AND mara~matnr IN s_matnr
AND mara~mtart IN s_mtart
AND mara~matnr EQ ig_matnr-matnr.
endloop.
IF sy-subrc = 0.
SORT ig_mara_makt.
ENDIF.
ENDFORM. " data_fetch
*& Form read_data_to_final
text
--> p1 text
<-- p2 text
FORM READ_DATA_TO_FINAL .
LOOP AT ig_mara_makt INTO wg_mara_makt .
wg_final-MATNR = wg_mara_makt-MATNR.
wg_final-BEGRU = wg_mara_makt-BEGRU.
wg_final-MTART = wg_mara_makt-MTART.
wg_final-SPRAS = wg_mara_makt-SPRAS.
wg_final-MAKTX = wg_mara_makt-MAKTX.
READ TABLE ig_t002 INTO wg_t002 WITH KEY spras = wg_final-spras.
IF sy-subrc = 0.
wg_final-srno = wg_t002-srno.
ENDIF.
CLEAR ig_thead[].
ig_thead-TDOBJECT = 'MATERIAL'.
ig_thead-TDNAME = wg_final-matnr.
ig_thead-TDID = 'GRUN'.
ig_thead-TDSPRAS = wg_final-spras.
CALL FUNCTION 'TEXT_READ'
EXPORTING
I_HEADER = IG_THEAD
I_READONLY = 'X'
IMPORTING
E_HEADER = IG_THEAD
TABLES
T_LINES = IG_TLINE[]
EXCEPTIONS
NOTFOUND = 1.
IF sy-subrc EQ 0.
LOOP AT ig_tline.
gv_strg = ig_tline-tdline.
IF gv_strg1 <> ' '.
CONCATENATE gv_strg1 ';' gv_strg INTO gv_strg1.
ELSE.
gv_strg1 = gv_strg.
ENDIF.
ENDLOOP.
wg_final-ltxt = gv_strg1.
APPEND wg_final TO ig_final.
CLEAR wg_final.
gv_strg1 = ' '.
ELSE.
APPEND wg_final TO ig_final.
ENDIF.
ENDLOOP.
ENDFORM. " read_data_to_final
" read_data_to_final
*& Form layout
text
--> p1 text
<-- p2 text
FORM LAYOUT .
CLEAR L_LT.
L_LT-ZEBRA = 'X'.
L_LT-COLWIDTH_OPTIMIZE = 'X'.
L_LT-WINDOW_TITLEBAR = 'MATERIAL DETAILS'.
ENDFORM. " layout
*& Form fieldcat
text
--> p1 text
<-- p2 text
FORM FIELDCAT .
SELECT SPRAS
LAISO FROM t002 INTO CORRESPONDING FIELDS OF TABLE ig_t002
WHERE spras IN s_spras.
DESCRIBE TABLE ig_t002 LINES gv_lines.
LOOP AT ig_t002 INTO wg_t002.
g_v = g_v + 1.
Wg_t002-srno = g_v.
MODIFY ig_t002 FROM wg_t002 TRANSPORTING SRNO.
ENDLOOP.
LOOP AT ig_t002 INTO wg_t002.
CLEAR WA_IT_FLDCAT.
MOVE SY-INDEX TO WA_COLNO.
CONCATENATE 'MD-' wg_t002-LAISO
WA_COLNO
INTO WA_FLNAME.
WA_IT_FLDCAT-FIELDNAME = WA_FLNAME.
WA_IT_FLDCAT-DATATYPE = 'CHAR'.
WA_IT_FLDCAT-SELTEXT = WA_FLNAME.
WA_IT_FLDCAT-INTLEN = 250.
WA_IT_FLDCAT-TABNAME = '<FS_2>'.
APPEND WA_IT_FLDCAT TO T_FLDCAT.
CLEAR wg_t002.
ENDLOOP.
LOOP AT ig_t002 INTO wg_t002.
CLEAR WA_IT_FLDCAT.
MOVE SY-INDEX TO WA_COLNO.
CONCATENATE 'BD-' wg_t002-LAISO
WA_COLNO
INTO WA_FLNAME.
WA_IT_FLDCAT-FIELDNAME = WA_FLNAME.
WA_IT_FLDCAT-DATATYPE = 'CHAR'.
WA_IT_FLDCAT-SELTEXT = WA_FLNAME.
WA_IT_FLDCAT-INTLEN = 250.
WA_IT_FLDCAT-TABNAME = '<FS_2>'.
APPEND WA_IT_FLDCAT TO T_FLDCAT.
CLEAR wg_t002.
ENDLOOP.
MOVE 'MATNR' TO WA_FLNAME.
WA_IT_FLDCAT-FIELDNAME = WA_FLNAME.
WA_IT_FLDCAT-DATATYPE = 'CHAR'.
WA_IT_FLDCAT-SELTEXT = 'Material No'.
WA_IT_FLDCAT-INTLEN = 18.
WA_IT_FLDCAT-TABNAME = '<FS_2>'.
INSERT WA_IT_FLDCAT INTO T_FLDCAT INDEX 1.
MOVE 'BEGRU' TO WA_FLNAME.
WA_IT_FLDCAT-FIELDNAME = WA_FLNAME.
WA_IT_FLDCAT-DATATYPE = 'CHAR'.
WA_IT_FLDCAT-SELTEXT = 'Authorization Group'.
WA_IT_FLDCAT-INTLEN = 4.
WA_IT_FLDCAT-TABNAME = '<FS_2>'.
INSERT WA_IT_FLDCAT INTO T_FLDCAT INDEX 2.
DESCRIBE TABLE T_FLDCAT LINES gv_li.
ASSIGN LT_DATA TO <FS_DATA>.
Creating the Dynamic Internal Table
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = T_FLDCAT " Fieldcatalogue
IMPORTING
EP_TABLE = <FS_DATA> " Dynamic Internal Table
EXCEPTIONS
GENERATE_SUBPOOL_DIR_FULL = 1
OTHERS = 2.
Assign Dyn Table To Field Sumbol
ASSIGN <FS_DATA>->* TO <FS_1>.
Assigning the Internal Table TYPE ANY to Standard internal Table
ASSIGN <FS_1> TO <FS_2>.
Creating a Workarea
CREATE DATA LWA_LINE LIKE LINE OF <FS_2> .
Assigning the Content to the workares as a Pointer
ASSIGN LWA_LINE->* TO <LWA_LINE_WA>.
LOOP AT T_FLDCAT INTO WA_IT_FLDCAT.
WA_IT_FLDCAT1-FIELDNAME = WA_IT_FLDCAT-FIELDNAME.
WA_IT_FLDCAT1-TABNAME = WA_IT_FLDCAT-TABNAME.
WA_IT_FLDCAT1-SELTEXT_L = WA_IT_FLDCAT-SELTEXT.
WA_IT_FLDCAT1-REF_TABNAME = 'MARC'.
APPEND WA_IT_FLDCAT1 TO T_FLDCAT1.
CLEAR : WA_IT_FLDCAT,WA_IT_FLDCAT1.
ENDLOOP.
ASSIGN LT_DATA1 TO <FS_DATA1>.
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = T_FLDCAT " Fieldcatalogue
IMPORTING
EP_TABLE = <FS_DATA1> " Dynamic Internal table
EXCEPTIONS
GENERATE_SUBPOOL_DIR_FULL = 1
OTHERS = 2.
Assign Dyn Table To Field Sumbol
ASSIGN <FS_DATA1>->* TO <FS_11>.
Assigning the Internal Table TYPE ANY to Standard internal Table
ASSIGN <FS_11> TO <FS_22>.
Creating a Workarea
CREATE DATA LWA_LINE1 LIKE LINE OF <FS_22> .
Assigning the Content to the workares as a Pointer
ASSIGN LWA_LINE1->* TO <LWA_LINE_WA1>.
ENDFORM. " fieldcat
*& Form show
text
--> p1 text
<-- p2 text
FORM Display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = GV_REPID
I_CALLBACK_PF_STATUS_SET = 'PF_STATUS_SET'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT = L_LT
IT_FIELDCAT = T_FLDCAT1[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = <FS_2>
EXCEPTIONS
PROGRAM_ERROR = 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.
ENDFORM. " display
FORM PF_STATUS_SET USING RS_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'DISPLAY' .
ENDFORM. "PF_STATUS_SET
*& Form Name: user_command *
*& Form Desc: For Handling USER_COMMAND *
FORM USER_COMMAND USING IF_UCOMM TYPE SY-UCOMM
IS_SELFIELD TYPE SLIS_SELFIELD.
CASE IF_UCOMM.
WHEN 'DOWNLOAD'.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TITLEBAR = ' '
DIAGNOSE_OBJECT = ' '
TEXT_QUESTION = 'Data download to excel'
TEXT_BUTTON_1 = 'Ja'(001)
ICON_BUTTON_1 = ' '
TEXT_BUTTON_2 = 'Nein'(002)
ICON_BUTTON_2 = ' '
DEFAULT_BUTTON = '1'
DISPLAY_CANCEL_BUTTON = 'X'
USERDEFINED_F1_HELP = ' '
START_COLUMN = 25
START_ROW = 6
POPUP_TYPE =
IMPORTING
ANSWER =
TABLES
PARAMETER =
EXCEPTIONS
TEXT_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.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
FILENAME = 'C:\Material-Text.xls'
FILETYPE = 'ASC'
APPEND = ' '
WRITE_FIELD_SEPARATOR = 'X'
HEADER = '00'
TRUNC_TRAILING_BLANKS = 'X'
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = 'X'
IMPORTING
FILELENGTH = GL_LENGHT
TABLES
DATA_TAB = <FS_22>
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
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 GL_LENGHT NE 0.
MESSAGE S398(00) WITH 'DATA downloaded to EXCEL'.
ENDIF.
ENDCASE.
ENDFORM. "user_command
Thanks
Ankur SHarma -
How to import data from excel or csv files to Oracle table
hello everybody,
I am new here and new in Oracle. I would like to know the steps how to import data from excel or csv files to Oracle table.
Let say I already have table inside the Oracle. Then my user give me the sets of data inside the Excel Worksheet.
So, how can I import the excel data into Oracle table.
Thank you in advance.
cheers,
shimaEven easier. Download JDeveloper 11G from this site.
Set up the database connection, right click on the table, select Import->Excel and specify your file to load it. On the import pop-up, you must view and update each tab indicating Columns, Data Types, and DML.
Columns -- move the selected columns that you want to load to the box on the right
Data Types -- select column name from second column to which the data for each column of the import file should load
DML -- click this tab to generate the INSERT SQL
Once done click 'Insert' -
Updating an oracle table with data from an xml string
Hi - I need help with the following problem:
We have a table in the database with a field of xml type. We are going to take each string that gets inserted into the xml type field in the 'xml table' and parse the data into another oracle table with corresponding fields for every element.
once the record gets inserted into the 'real table' the user might want to update this record they will then insert another record into the 'xml table' indicating an update(with a flag) and then we need to update the 'real table' with the updated values that have been sent in.
The problem that I am having is that I do not know how to create this update statement that will tell me which fields of the table need to be updated.(only the fields that need to be updated will be in the xml string in the 'xml table').
Please help me with this - ASAP!Are you wanting to upload the file through an Oracle Form or just upload a file? If it isn't via forms, then you should probably post your question here: {forum:id=732}
You also should post the version of Forms, Database, etc...
As far as uploading files via a text file, I personally like to use Oracle External Tables even in Forms. You can Google that and there is plenty of information. If you search this forum, then you will see lots of people use UTL_FILE in forms, but you can Google that also for more information. -
Hello All :
I have been trying to figure out for a simple code I can use in my JSP to upload a file (of any format) into an Oracle table with a BLOB column type. I have gone through a lot of existing forums but couldnot find a simple code (that doesnot use Servlet, for eg.) to implement this piece.
Thanks a lot for your help !!Hi.
First of all to put a file into Oracle you need to get the array of bytes byte[] for that file. For this use for example FileInputStream.
After you get the byte array try to use this code:
try {
Connection conn = myGetDBConnection();
PreparedStatement pstmt = conn.prepareStatement("INSERT INTO table1 (content) VALUES(?)");
byte[] content = myGetFileAsBytes();
if (content != null) {
pstmt.setBinaryStream(0, new ByteArrayInputStream(content), content.length);
pstmt.close();
conn.close();
} catch (Exception ex) {
ex.printStackTrace();
}or instead of using ByteArrayInputStream try pstmt.setBinaryStream(0, new FileInputStream(yourFile), getFileSize());Hope this will help...
regards, Victor Letunovsky -
How to import your MS Active Directory users in an Oracle table
Hello,
I first tried to get a Heterogenous Connection to my MS Active Directory to get information on my Active Directory users.
This doesn't work so I used an alternative solution:
How to import your MS Active Directory users in an Oracle table
- a Visual Basic script for export from Active Directory
- a table in my database
- a SQL*Loader Control-file
- a command-file to start the SQL*Loader
Now I can schedule the vsb-script and the command-file to get my information in an Oracle table. This works fine for me.
Just to share my scripts:
I made a Visual Basic script to make an export from my Active Directory to a CSV-file.
'Export_ActiveDir_users.vbs 26-10-2006
'Script to export info from MS Active Directory to a CSV-file
' Accountname, employeeid, Name, Function, Department etc.
' Richard de Boer - Wetterskip Fryslan, the Nethterlands
' samaccountname Logon Name / Account
' employeeid Employee ID
' name name
' displayname Display Name / Full Name
' sn Last Name
' description Description / Function
' department Department / Organisation
' physicaldeliveryofficename Office Location Wetterskip Fryslan
' streetaddress Street Address Harlingerstraatweg 113
' l City / Location Leeuwarden
' mail E-mail adress
' wwwhomepage Web Page Address
' distinguishedName Full unique name with cn, ou's, dc's
'Global variables
Dim oContainer
Dim OutPutFile
Dim FileSystem
'Initialize global variables
Set FileSystem = WScript.CreateObject("Scripting.FileSystemObject")
Set OutPutFile = FileSystem.CreateTextFile("ActiveDir_users.csv", True)
Set oContainer=GetObject("LDAP://OU=WFgebruikers,DC=Wetterskip,DC=Fryslan,DC=Local")
'Enumerate Container
EnumerateUsers oContainer
'Clean up
OutPutFile.Close
Set FileSystem = Nothing
Set oContainer = Nothing
WScript.Echo "Finished"
WScript.Quit(0)
Sub EnumerateUsers(oCont)
Dim oUser
For Each oUser In oCont
Select Case LCase(oUser.Class)
Case "user"
If Not IsEmpty(oUser.distinguishedName) Then
OutPutFile.WriteLine _
oUser.samaccountname & ";" & _
oUser.employeeid & ";" & _
oUser.Get ("name") & ";" & _
oUser.displayname & ";" & _
oUser.sn & ";" & _
oUser.description & ";" & _
oUser.department & ";" & _
oUser.physicaldeliveryofficename & ";" & _
oUser.streetaddress & ";" & _
oUser.l & ";" & _
oUser.mail & ";" & _
oUser.wwwhomepage & ";" & _
oUser.distinguishedName & ";"
End If
Case "organizationalunit", "container"
EnumerateUsers oUser
End Select
Next
End SubThis give's output like this:
rdeboer;2988;Richard de Boer;Richard de Boer;de Boer;Database Administrator;Informatie- en Communicatie Technologie;;Harlingerstraatweg 113;Leeuwarden;[email protected];;CN=Richard de Boer,OU=Informatie- en Communicatie Technologie,OU=Afdelingen,OU=WFGebruikers,DC=wetterskip,DC=fryslan,DC=local;
tbronkhorst;201;Tjitske Bronkhorst;Tjitske Bronkhorst;Bronkhorst;Configuratiebeheerder;Informatie- en Communicatie Technologie;;Harlingerstraatweg 113;Leeuwarden;[email protected];;CN=Tjitske Bronkhorst,OU=Informatie- en Communicatie Technologie,OU=Afdelingen,OU=WFGebruikers,DC=wetterskip,DC=fryslan,DC=local;I made a table in my Oracle database:
CREATE TABLE PG4WF.ACTD_USERS
samaccountname VARCHAR2(64)
, employeeid VARCHAR2(16)
, name VARCHAR2(64)
, displayname VARCHAR2(64)
, sn VARCHAR2(64)
, description VARCHAR2(100)
, department VARCHAR2(64)
, physicaldeliveryofficename VARCHAR2(64)
, streetaddress VARCHAR2(128)
, l VARCHAR2(64)
, mail VARCHAR2(100)
, wwwhomepage VARCHAR2(128)
, distinguishedName VARCHAR2(256)
)I made SQL*Loader Control-file:
LOAD DATA
INFILE 'ActiveDir_users.csv'
BADFILE 'ActiveDir_users.bad'
DISCARDFILE 'ActiveDir_users.dsc'
TRUNCATE
INTO TABLE PG4WF.ACTD_USERS
FIELDS TERMINATED BY ';'
( samaccountname
, employeeid
, name
, displayname
, sn
, description
, department
, physicaldeliveryofficename
, streetaddress
, l
, mail
, wwwhomepage
, distinguishedName
)I made a cmd-file to start SQL*Loader
: Import the Active Directory users in Oracle by SQL*Loader
D:\Oracle\ora92\bin\sqlldr userid=pg4wf/<password>@<database> control=sqlldr_ActiveDir_users.ctl log=sqlldr_ActiveDir_users.logI used this for a good list of active directory fields:
http://www.kouti.com/tables/userattributes.htm
Greetings,
Richard de BoerI have a table with about 50,000 records in my Oracle database and there is a date column which shows the date that each record get inserted to the table, for example 04-Aug-13.
Is there any way that I can find out what time each record has been inserted?
For example: 04-Aug-13 4:20:00 PM. (For my existing records not future ones)
First you need to clarify what you mean by 'the date that each record get inserted'. A row is not permanent and visible to other sessions until it has been COMMITTED and that commit may happen seconds, minutes, hours or even days AFTER a user actually creates the row and puts a date in your 'date column'.
Second - your date column, and ALL date columns, includes a time component. So just query your date column for the time.
The only way that time value will be incorrect is if you did something silly like TRUNC(myDate) when you inserted the value. That would use a time component of 00:00:00 and destroy the actual time. -
Copying long raw to other table??
Hi everyone....
I'm using oracle 10g.
In my table i have a LONG RAW column to store images.
Now i need to copy the data in LONG RAW to another table...
Is this possible.. if yes then whats the procedure to copy the data from LONG RAW ??
please help me in this query.....
its very urgent.......
is it possible using oracle 8i ??
Thanks in advance....
Regards,
Santosh.Minupurey
Edited by: Santosh.minupurey on Feb 16, 2009 11:23 PMNo one could answer my query ?
very strange...... -
Column not found error while populatin a oracle table with ODI USer
Hi,
I am trying to populate a column in a oracle table with the ODI USER name using the function getUser("USER_NAME") in the Mapping column of the Interface, But the interface throwhing an error *Column not found : Supervisor in Statement [Select......]*. but it's working fine with getUser("I_USER') the column is populating the user identifier.
can any one help me out why user is not populating.
ThanksEnclose the call to the getUser api inside single quotes
'<%=getUser("USER_NAME")%>'ID being a number can be used directly but USER_NAME returns a string that needs to be quoted -
Updating Oracle table with info from Sybase query
I hope this is the correct forum for this question.
I am fairly new to Java and JDBC. I am trying to figure out what the best method for updating information in Oracle tables with data from a Sybase table. I would prefer to use Oracle’s transparent gateway but this is not an option my company will pay for so I am creating a java stored procedure and using JDBC to connect to the Sybase database.
The process I think I need to go thru is
1. Query an Oracle table to get the records that need to be updated and the “key” information to query the Sybase table with.
2. Use that result to query the Sybase database to get the fields that need to be updated in the Oracle table for those records.
3. Update the records on the Oracle table with the data from the Sybase query.
I know I can just do this procedurally, row-by-row, but I was wondering if anyone knows of a way to accomplish this with SQL and no loops. Is there a way to make a result set available as a “SQL table” for another JDBC query?
Basically what I would like to do is:
OraQuery = “ select sybinfo from sometable where updated_date = null”;
Statement orastmt1 = OraConn.createStatement();
ResultSet Orars1 = orastmt1.executeQuery (OraQuery);
SybQuery = “select update_date, sybinfo from sybtable where sybinfo = Orars1.sybinfo”;
Statement sybstmt = SybConn.createStatement();
ResultSet Sybrs = sybstmt1.executeQuery (SybQuery);
OraUpdate = “update (select update_date from sometable, Sybrs where sometable.sybinfo = Sybrs.sybinfo) set update_date = Sybrs.update_date”;
Statement orastmt2 = OraConn.createStatement();
ResultSet Orars2 = orastmt2.executeQuery (OraUpdate);
This may not be possible but if anyone has done something similar and wouldn’t mind sharing I would appreciate it. If there is a “better” way of accomplishing this I am open to suggestions.
Thanksyou can try using cachedRowSet() for the Oracle side query.
The rows in this could be populated using the sybase side query's resultset and then all of this could updated into Oracle in one shot. -
How to find the Column data type changes in table
Hi All,
I need to find out the column data type changes where made recently in table .
How do i check past changes in column data type. Any data dictionary are there to find out the data type changes in the column .
Thanks in advance..<FONT FACE="Arial" size=2 color="2D0000">
You have the answer on hand (user_arguments / all_arguments)!
SQL> desc user_arguments
Name Null? Typ
OBJECT_NAME VARCHAR2(30)
PACKAGE_NAME VARCHAR2(30)
OBJECT_ID NOT NULL NUMBER
OVERLOAD VARCHAR2(40)
ARGUMENT_NAME VARCHAR2(30)
POSITION NOT NULL NUMBER
SEQUENCE NOT NULL NUMBER
DATA_LEVEL NOT NULL NUMBER
DATA_TYPE VARCHAR2(30) --> Data Type
DEFAULT_VALUE LONG
DEFAULT_LENGTH NUMBER
IN_OUT VARCHAR2(9) -->Argument direction (IN,OUT,or IN/OUT)
DATA_LENGTH NUMBER
DATA_PRECISION NUMBER
DATA_SCALE NUMBER
RADIX NUMBER
CHARACTER_SET_NAME VARCHAR2(44)
TYPE_OWNER VARCHAR2(30)
TYPE_NAME VARCHAR2(30)
TYPE_SUBNAME VARCHAR2(30)
TYPE_LINK VARCHAR2(128)
PLS_TYPE VARCHAR2(30)
CHAR_LENGTH NUMBER
CHAR_USED VARCHAR2(1)
Look for Data_Type where IN_OUT say OUT. That will be the data type retruned by that function.
Edited :
or POSITION in argument list,or null for function return value
-SK
</FONT>
Maybe you are looking for
-
I have a few small dents in my MacBook
I bought it on Boxing day 2011 It had a small dent on the day but I ignored it (was too happy playing with it) After dishing out over $1200 on it, I treated it like gold and I do still to this day, I never ever dropped it or anything And now, I have
-
Want to Use Extended Receiver Determination
Dear All, As my last post I came to know that i was using invaild data in input payload so i now have tested with proper data. i am getting lot of invaild things in my input like space ,# and all from ECC side in first step of pipeline(Receiver Deter
-
How to use the Dekstop Action in desktop files.
I just recognized that desktop files can contain cool actions like e.g shutter: 20 [Desktop Action Redo] 21 Name=Redo last screenshot 22 Exec=shutter --redo 23 OnlyShowIn=Unity; 24 25 [Desktop Action Select] 26 Name=Capture an area of the screen 27 E
-
Hi everyone, by boss wants me to skype with video. I have an integrated webcam which works with usual software like cheese and so on. I can't get it to work with skype (webcam's led briefly light up - nothing more). I tried $ LD_PRELOAD=/opt/lib32/us
-
Problem with my itunes - programme path cannot be found - can't uninstall
Hi I was wondering if anyone can help me... I've got a problem with my itunes and I'm at a loss as to what to do! I recently went to open itunes and as I did a message came up to say that itunes has not been properly installed and that if I want to b