PL/SQL barcode function
Hi,
We need a free barcode function in PL/SQL.
Can anyone provide this for us?
Thanks in advance,
Juliano Triska <[email protected]>
You might get a better response by posting your question in the PL/SQL forum.
Regards,
-rh
Similar Messages
-
Logical Operations in SQL decode function ?
Hi,
Is it possible to do Logical Operations in SQL decode function
like
'>'
'<'
'>='
'<='
'<>'
not in
in
not null
is null
eg...
select col1 ,order_by,decode ( col1 , > 10 , 0 , 1)
from tab;
select col1 ,order_by,decode ( col1 , <> 10 , 0 , 1)
from tab;
select col1 ,order_by,decode ( col1 , not in (10,11,12) , 0 , 1)
from tab;
select col1 ,order_by,decode ( col1 ,is null , 0 , 1)
from tab;
Regards,
infan
Edited by: user780731 on Apr 30, 2009 12:07 AM
Edited by: user780731 on Apr 30, 2009 12:07 AM
Edited by: user780731 on Apr 30, 2009 12:08 AM
Edited by: user780731 on Apr 30, 2009 12:08 AM
Edited by: user780731 on Apr 30, 2009 12:09 AMexample:
select col1 ,order_by,case when col1 > 10 then 0 else 1 end
from tab;
select col1 ,order_by,case when col1 <> 10 then 0 else 1 end
from tab;
select col1 ,order_by,case when col1 not in (10,11,12) then 0 else 1 end
from tab;As for testing for null, decode handles that by default anyway so you can have decode or case easily..
select col1 ,order_by,decode (col1, null , 0 , 1)
from tab;
select col1 ,order_by,case when col1 is null then 0 else 1 end
from tab; -
How to Passing clob to PL/SQL pipeline function
I have a PL/SQL stored function which takes clob as input parameter and sends the results in a pipe line.
create or replace function GetIds(p_list clob, p_del varchar2 := ',') return ideset_t pipelined is
I am using ojdbc14.jar (Oracle 10g driver) with oracle 9i (9.2.0.1.0).
I want to use the following SQL Query select * from table(GetIds(clob))
Now the question is how can I pass the clob from JDBC?
Here is my client code
PreparedStatement stmt = con.prepareStatement("SELECT COLUMN_VALUE FROM TABLE(GETIDS(?, ','))");
stmt.setCharacterStream(1, new StringReader(str), str.length());
stmt.executeQuery();
I get the following error when I try to run the program. The same thing works fine if the chracter lenght is less than some chaaracters.
java.sql.SQLException: ORA-01460: unimplemented or unreasonable conversion requested
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:623)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:181)
at oracle.jdbc.driver.T4CPreparedStatement.execute_for_describe(T4CPreparedStatement.java:420)
at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:896)
at oracle.jdbc.driver.T4CPreparedStatement.execute_maybe_describe(T4CPreparedStatement.java:452)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:986)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2888)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:2960)
at Test.main(Test.java:42)
Exception in thread "main"
The setChracterStream works for any insert/update clob. Example when I tried the query (INSERT INTO CLOB_TEST VALUES(?)) setCharacterStream just works fine.
Please any one can help me how to solve this.
Thanks in advance.Hóla LuÃs,
when you pick the PL/SQL function body returning a boolean, it implicitly means that TRUE means OK, while FALSE means error, always.
In order to associate such error to a given form field, you have to go back to the page definiton / validations and specify the name of the item in the corresponding field.
When you first create the validation rule, this value is not present even if you ask for the error message inline with the field.
The error message text can be specified in the validation definition, if I am not wrong.
When you need to return special error messages, including dynamic content for instance, you can use the Function Returning Error Message type, which reports an error when the string returned by the function is not null. This comes in handy when you want to display an item's code, for example, rather than generic text.
Even in this case, you must go back to the validation and specify the name of the field if you want to see it inline.
Hope it helps,
Flavio -
Dear Sir/Mam
I want SQL query, function or SP which converts binary data to image (.jpg format).
I m able to convert image (.jpg format) to varbinary. But not able to convert vice versa.
thanks in advance.Binary data is binary data - "image" is only an intrepretation of binary data. Therefore your question makes little sense in the context of sql server since it does not have any facilities to utilize images. Since you provide no context, I'm
guessing that you are trying to retrieve an image stored in the database in a varbinary column and have your application use it as an image. If so, you should post your question to a forum that is specific to your development environment. -
Query of queries disallows SQL right() function
We're attempting to do a query of queries using the SQL
right() function like this:
select *
from getresults
where right([key],charindex('\',reverse([key]),1)-1) not in
(#quotedvaluelist(getexcluded.file_name)#)
We've even replaced that where clause with a much more simple
where right([key])='m'
just to make sure that it wasn't the nesting functions that
were causing the problem.
In either case, we get the error:
Query of Queries syntax error.
Encountered "right" at line 0, column 0. Incorrect
conditional expression,
Expected one of [like|null|between|in|comparison] condition,
What SQL functions are disallowed from query of queries?
Thanks,
KrisNasty stuff huh. Just happened to discover myself today that
Left doesn't work. I'd suspect that Aggregate functions are the
ONLY ones that will work. It would have been nice if they'd at
least allowed CF vs DB functions in their own "database" language.
BTW, also discovered that Count() returns Null rather than 0
when there aren't any per your WHERE clause. -
Incorrect syntax errors in sql server function. Please help.
This is my sql server function:
create function dbo.CleanTheStringAdv (@theString nvar
char(500), @CleanMode as int)
returns nvarchar(500)
begin
--define variables
declare @strAlphaNumeric nvarchar(500)
declare @i int
declare @strChar nvarchar(500)
declare @CleanedString nvarchar(500)
--initiate values
set @CleanedString =''
set @theString = @theString + ''
SET @i = 1
--Determine if we are looking for numeric values only or numbers and letters
return case @CleanMode
WHEN 1
THEN @strAlphaNumeric = '0123456789'
WHEN 2
THEN @strAlphaNumeric = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
WHEN 3
THEN @strAlphaNumeric = '|0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
else 0
end
--Search through chars in the string passed to the function
while (@i <= Len(@theString))
begin
@strChar = substring(@theString, @i, 1)
If (charindex(@strAlphaNumeric, @strChar) <>0)
--if the current char being reviewed is valid then add it to the new string
begin
@CleanedString = @CleanedString + @strChar
end
end
return @CleanedString
and below are the syntax errors I see when I press F5:
Msg 102, Level 15, State 1, Procedure CleanTheStringAdv, Line 24
Incorrect syntax near '='.
Msg 102, Level 15, State 1, Procedure CleanTheStringAdv, Line 39
Incorrect syntax near '@strChar'.
Msg 102, Level 15, State 1, Procedure CleanTheStringAdv, Line 43
Incorrect syntax near '@CleanedString'.
Any help is highly appreciated.....Here is the full code for the function:
create function dbo.CleanTheStringAdv (@theString nvarchar(500), @CleanMode as int)
returns nvarchar(500)
as
begin
--define variables
declare @strAlphaNumeric nvarchar(500)
declare @i int
declare @strChar nvarchar(500)
declare @CleanedString nvarchar(500)
--initiate values
set @CleanedString =''
set @theString = @theString + ''
SET @i = 1
--Determine if we are looking for numeric values only or numbers and letters
SET @strAlphaNumeric = case @CleanMode
WHEN 1
THEN '0123456789'
WHEN 2
THEN '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
WHEN 3
THEN '|0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
else 0
end
--Search through chars in the string passed to the function
while (@i <= Len(@theString))
begin
set @strChar = substring(@theString, @i, 1);
If (charindex(@strAlphaNumeric, @strChar) <>0) --if the current char being reviewed is valid then add it to the new string
begin
SET @CleanedString = @CleanedString + @strChar;
end
END
return @CleanedString;
END -
Problem with SQL Convert Function Junk Character
Hi All,
We have a database field that has a value of “2.020 OPERATOE’S CAB – GLASSES” on the front end of Oracle E-Business Suite. When we are spooling that column(in PLSQL) with the SQL covert function , one of the characters(’) in the string is not getting converted properly. It is displayed as a junk character in the spooled file.
We used CONVERT(p_column,'WE8ISO8859P1','UTF8') for converting the string and utl_file api for spooling the output file. Please note that converted string is passed to utl_file.fopen directly.
Following are the nls_parameters values.
NLS_CHARACTERSET ~~ UTF8
NLS_NCHAR_CHARACTERSET ~~ AL16UTF16
Any inputs are welcome.
Thanks
gt1942Hello All,
Sorry, If I am opening the blog in the wrong place as this is the first time.
my out looks as follows.
"02920Â "
but when i see in the application there is nuthing in the end.
so I used regexp_replace(p_vendor_dtl,'[^[!-~]]*',''), But this is removing spaces also. I don't want to remove space. I want to remove this character only.
Please help
Thanks. -
Sql like function in View Object for progammatically
Hi friends,
I used Jdeveloper 11.1.1.4.0 ,I need how to get the datas from database using sql like function(select * from tablename where name like 'p%') using viewCriteria by
programmatically.
Thanks & Regards,
Priya.
Edited by: priya on Apr 8, 2011 3:48 AM
Edited by: priya on Apr 8, 2011 3:49 AMCheck the docs: http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/bcadvvo.htm#sm0341
Timo -
Use of Pl/Sql and Function
Hi,
Can we use a PL/Sql package or a Function in a sql query. If yes How.??
Regards
SameerSameer8 wrote:
Can we use a PL/Sql package or a Function in a sql query. If yes How.??A function (whether declared in a package or a stand alone stored function) may be used in SQL providing it does not contain any OUT parameters...
SQL> create function testf(x OUT number) return number is
2 begin
3 x := 1;
4 return 2;
5 end;
6 /
Function created.
SQL> var my_x number
SQL> select testf(:my_x) from dual;
select testf(:my_x) from dual
ERROR at line 1:
ORA-06572: Function TESTF has out argumentsAnd it doesn't do any DML...
SQL> create table x (x number);
Table created.
SQL> ed
Wrote file afiedt.buf
1 create or replace function testf return number is
2 begin
3 insert into x values (1);
4 return 1;
5* end;
SQL> /
Function created.
SQL> select testf() from dual;
select testf() from dual
ERROR at line 1:
ORA-14551: cannot perform a DML operation inside a query
ORA-06512: at "SCOTT.TESTF", line 3 -
SQL Analytical Functions in 9i
Hi
I am trying to determine of the SQL Analytical Functions in Oracle 9i like LAG, NTILE, PERCENT_RANK etc are part of Enterprise without OLAP installed.
They will be very useful to a set of queries I am trying to build but I don't want to add OLAP to the mix if I can help it as the customer won't be OLAP enabled
CheersHi
I am trying to determine of the SQL Analytical Functions in Oracle 9i like LAG, NTILE, PERCENT_RANK etc are part of Enterprise without OLAP installed.
They will be very useful to a set of queries I am trying to build but I don't want to add OLAP to the mix if I can help it as the customer won't be OLAP enabled
Cheers -
Improve built in SQL MAX function
Hi
I am trying to improve the performance of the built in SQL max function. right now searching through over 500,000 rows takes lot of time which can be reduced. Can anyone suggest me something which would be helpful in this or may be give me a link if it has been discussed before?
Anything is appreciated.
ThanksTolls wrote:
Um...considering you were planning on improving on the MAX function, I sort of thought you might actually know how to use it. Otherwise how would you know it was running slowly?thanks Tolls i'd figured it out right after i posted it. i guess i was too excited after reading (you got it in milliseconds) that posted right away without doing anything myself..but yeah it did make it super fast..thanks a lot for your help and time..
cotton.m wrote:
d_khakh wrote:
hi tolls thanks for getting back
could u explain how did u do that? i found out how to create index..i have the following statement:
create index col on table2 (col2);
cud u tell me how to go from here and find the max in col2..thanks again for ur help?
sigh
Where to go from here? Just execute your damn query. If you really did create the index on the right column and your database isn't stupid and there isn't a lot more to this problem then you told us about like some where clauses then that's it. She's as fast as she's going to get.
And remember, it's impolite to converse in a public forum while chewing your cud. Unless of course you actually meant "could" but were just too lazy to type it. Don't be lazy, use full words. Thanks.like i said above..i figured it out after some time.
i wasn't being lazy ..thats msn talk..i thought people understood that..anyways your point noted too. -
PL/SQL Pipelined Function to Compare *ANY* 2 tables
I am trying to create a pipelined function in 10g R1 that will take the name of two tables, compare the the tables using dynamic SQL and pipe out the resulting rows using the appropriate row type. The pipelined function will be used in a DML insert statement.
For example:
create table a (f1 number, f2, date, f3 varchar2);
create table b (f1 number, f2, date, f3 varchar2);
create table c (f1 number, f2, date, f3 varchar2);
create or replace TYPE AnyCollTyp IS TABLE OF ANYTYPE;
create or replace TYPE CRowType IS c%ROWTYPE;
create or replace TYPE CRowTabType IS table of CRowType;
CREATE OR REPLACE FUNCTION compareTables (p_source IN VARCHAR2, p_dest IN VARCHAR2)
RETURN AnyCollTyp PIPELINED
IS
CURSOR columnCur (p_tableName IN user_tab_columns.table_name%TYPE)
IS
SELECT column_name, column_id
FROM user_tab_columns
WHERE table_name = p_tableName
ORDER BY column_id;
l_cur sys_refcursor;
l_rec ANYTYPE;
l_stmt VARCHAR2 (32767);
BEGIN
l_stmt := 'select ';
FOR columnRec IN columnCur (p_dest)
LOOP
l_stmt := l_stmt || CASE
WHEN columnRec.column_id > 1
THEN ','
ELSE ''
END || columnRec.column_name;
END LOOP;
l_stmt := l_stmt || ' from ' || p_source;
l_stmt := l_stmt || ' minus ';
l_stmt := l_stmt || ' select ';
FOR columnRec IN columnCur (p_dest)
LOOP
l_stmt := l_stmt || CASE
WHEN columnRec.column_id > 1
THEN ','
ELSE ''
END || columnRec.column_name;
END LOOP;
l_stmt := l_stmt || ' from ' || p_dest;
OPEN l_cur FOR l_stmt;
LOOP
FETCH l_cur
INTO l_rec;
PIPE ROW (l_rec);
EXIT WHEN l_cur%NOTFOUND;
END LOOP;
CLOSE l_cur;
RETURN;
END compareTables;
The pipelined function gets created without error. However, the testCompare procedure gets an error:
SQL> create or replace procedure testCompare is
begin
insert into c
select *
from (TABLE(CAST(compareTables('a','b') as cRowTabType)));
dbms_output.put_line(SQL%ROWCOUNT || ' rows inserted into c.');
end;
Warning: Procedure created with compilation errors.
SQL> show errors
Errors for PROCEDURE TESTCOMPARE:
LINE/COL ERROR
3/4 PL/SQL: SQL Statement ignored
5/47 PL/SQL: ORA-22800: invalid user-defined type
Does anyone know what I am doing wrong? Is there a better way to compare any two tables and get the resulting rows?904640 wrote:
Hi All,
Is it possible to post messages to weblogic JMS queue from pl/sql procedure/function?
From this Queue, message will be read by OSB interface.
Any help will be highly appreciated.
http://www.lmgtfy.com/?q=oracle+pl/sql+weblogic+jms+queue -
Calling SQL Server function in ODI
Hi All,
In the Target data store in the interface I have a column called COUNT_BY_CERTDATE column and in the mapping I have teh following syntax, which does not work.
SUM(CASE WHEN ((dbo.getcertdate(person_id,getdate()) >= current_timestamp) THEN 1 ELSE 0 END). The 'getcertdate' is a SQL Server function which returns a date.
I am getting a "Expression is not valid for this DBMS error" with the details as getcertdate is not a recognized built in function name. Please help on fixing this issue.
Thanks for your time and help.Its defined on the source.
I am getting the following error, when I execute it.
ODI-1228: Task Load_Fact_Table1 (Integration) fails on the target MICROSOFT_SQL_SERVER connection SQLSERVER_USAASC.
Caused By: java.sql.SQLException: [FMWGEN][SQLServer JDBC Driver][SQLServer]Cannot find either column "main" or the user-defined function or aggregate "main.dbo.getCertDate", or the name is ambiguous.
Edited by: ssk1974 on Dec 20, 2012 6:30 AM -
Pl-Sql Oracle Function Concurrency Issue
Hi All,
Issue - pl-sql Oracle Function performance issue, when muliple users are accessing the function
Detail -
Oracle 11g / Linux Server
I have developed a pl-sql oracle function to retrieve information from 3 tables, output as a particluar type array.
Single request is getting processed within 2.2 seconds, but when multiple request are sent concurrently <tested with 50>, time taken for each output is different.
BreakUp of Response times:-
8 messages took - 2.2 sec
+8 messages took - 4.4 sec
++8 messages took - 6.6 sec....etc
I'm looking for any DB tunning parameter, which will help to resolve this issue.
My only aim is to expose developed function to multiple users, who all can access it concurrently, but response should limit within 2.2 seconds.
Any thoughts + guidance is higly appreciated.
Thanks
Preetam SinghSupporting data insert statements:
=======================================================================================================================
REM INSERTING into EXPERTISE
Insert into EXPERTISE (USH_USER_NAME,USH_SKILL_SET1,USH_SKILL_SET2,USH_SKILL_SET3,USH_SKILL_SET4,USH_SKILL_SET5,USH_SKILL_SET6,USH_SKILL_SET7,USH_SKILL_SET8,USH_SKILL_SET9,USH_SKILL_SET10,USH_SKILL_SET11,USH_SKILL_SET12,USH_SKILL_SET13,USH_SKILL_SET14,USH_SKILL_SET15,USH_SKILL_SET16,USH_SKILL_SET17,USH_SKILL_SET18,USH_SKILL_SET19,USH_SKILL_SET20) values ('A','ENGLISH','FRENCH','HINDI',null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into EXPERTISE (USH_USER_NAME,USH_SKILL_SET1,USH_SKILL_SET2,USH_SKILL_SET3,USH_SKILL_SET4,USH_SKILL_SET5,USH_SKILL_SET6,USH_SKILL_SET7,USH_SKILL_SET8,USH_SKILL_SET9,USH_SKILL_SET10,USH_SKILL_SET11,USH_SKILL_SET12,USH_SKILL_SET13,USH_SKILL_SET14,USH_SKILL_SET15,USH_SKILL_SET16,USH_SKILL_SET17,USH_SKILL_SET18,USH_SKILL_SET19,USH_SKILL_SET20) values ('B',null,'GERMAN','CHINIESE','HINDI',null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into EXPERTISE (USH_USER_NAME,USH_SKILL_SET1,USH_SKILL_SET2,USH_SKILL_SET3,USH_SKILL_SET4,USH_SKILL_SET5,USH_SKILL_SET6,USH_SKILL_SET7,USH_SKILL_SET8,USH_SKILL_SET9,USH_SKILL_SET10,USH_SKILL_SET11,USH_SKILL_SET12,USH_SKILL_SET13,USH_SKILL_SET14,USH_SKILL_SET15,USH_SKILL_SET16,USH_SKILL_SET17,USH_SKILL_SET18,USH_SKILL_SET19,USH_SKILL_SET20) values ('C','ENGLISH',null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null);
=======================================================================================================================
==================================================================
REM INSERTING into WORKING
Insert into WORKING (NAME,WEEKDAY,DAYSTARTTIME,DAYENDTIME) values ('A','MON','09:00','18:00');
Insert into WORKING (NAME,WEEKDAY,DAYSTARTTIME,DAYENDTIME) values ('A','TUE','09:00','18:00');
Insert into WORKING (NAME,WEEKDAY,DAYSTARTTIME,DAYENDTIME) values ('A','WED',null,null);
Insert into WORKING (NAME,WEEKDAY,DAYSTARTTIME,DAYENDTIME) values ('A','THU','09:00','18:00');
Insert into WORKING (NAME,WEEKDAY,DAYSTARTTIME,DAYENDTIME) values ('A','FRI','09:00','12:00');
Insert into WORKING (NAME,WEEKDAY,DAYSTARTTIME,DAYENDTIME) values ('B','MON','09:00','18:00');
Insert into WORKING (NAME,WEEKDAY,DAYSTARTTIME,DAYENDTIME) values ('B','TUE','09:00','18:00');
Insert into WORKING (NAME,WEEKDAY,DAYSTARTTIME,DAYENDTIME) values ('B','WED','09:00','18:00');
Insert into WORKING (NAME,WEEKDAY,DAYSTARTTIME,DAYENDTIME) values ('B','THU','09:00','18:00');
Insert into WORKING (NAME,WEEKDAY,DAYSTARTTIME,DAYENDTIME) values ('B','FRI','09:00','18:00');
Insert into WORKING (NAME,WEEKDAY,DAYSTARTTIME,DAYENDTIME) values ('C','MON',null,null);
Insert into WORKING (NAME,WEEKDAY,DAYSTARTTIME,DAYENDTIME) values ('C','TUE','09:00','18:00');
Insert into WORKING (NAME,WEEKDAY,DAYSTARTTIME,DAYENDTIME) values ('C','WED','09:00','18:00');
Insert into WORKING (NAME,WEEKDAY,DAYSTARTTIME,DAYENDTIME) values ('C','THU','09:00','18:00');
Insert into WORKING (NAME,WEEKDAY,DAYSTARTTIME,DAYENDTIME) values ('C','FRI','09:00','12:00');
==================================================================
=====================================================================================================================
REM INSERTING into SCHEDULE
Insert into SCHEDULE (APPOINTMENTDATE,APPOINTMENTSTART,APPOINTMENTEND,STATUS,NAME) values (to_timestamp('11-FEB-12 10.00.00.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),to_timestamp('11-FEB-12 10.00.00.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),to_timestamp('11-FEB-12 11.00.00.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),'MEETING','A');
Insert into SCHEDULE (APPOINTMENTDATE,APPOINTMENTSTART,APPOINTMENTEND,STATUS,NAME) values (to_timestamp('11-FEB-12 10.00.00.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),to_timestamp('11-FEB-12 10.00.00.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),to_timestamp('11-FEB-12 11.00.00.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),'TRAINING','B');
Insert into SCHEDULE (APPOINTMENTDATE,APPOINTMENTSTART,APPOINTMENTEND,STATUS,NAME) values (to_timestamp('13-FEB-12 10.00.00.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),to_timestamp('11-FEB-12 10.00.00.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),to_timestamp('11-FEB-12 11.00.00.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),'MEETING','A');
Insert into SCHEDULE (APPOINTMENTDATE,APPOINTMENTSTART,APPOINTMENTEND,STATUS,NAME) values (to_timestamp('11-FEB-12 10.00.00.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),to_timestamp('11-FEB-12 11.00.00.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),to_timestamp('11-FEB-12 11.30.00.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),'MEETING','B');
=====================================================================================================================
Edited by: 910614 on Feb 10, 2012 9:29 AM -
Creating optional elements using SQL / XML functions
Hi,
I am struggling with some SQL / XML functionality in order to create some optional elements in a XMLType.
I have one table with data to be generated into an XML document. The table looks like this (only the attributes related to the problem are shown):
msg_id (pk)
geslacht_hoofdverzekerde
geboortedatum_hoofdverzekerde
geslacht_medeverzekerde
geboortedatum_medeverzekerde
I have to create an XML document that looks like this:
<ber:rekenparameters>
<ber:verzekerde>
<ber:codeRelatierol>HVZ</ber:codeRelatierol>
<ber:geslacht>M</ber:geslacht>
<ber:datumGeboorte>01-01-1960</ber:datumGeboorte>
</ber:verzekerde>
<ber:verzekerde>
<ber:codeRelatierol>MVZ</ber:codeRelatierol>
<ber:geslacht>V</ber:geslacht>
<ber:datumGeboorte>01-01-1961</ber:datumGeboorte>
</ber:verzekerde>
</ber:rekenparameters>
Where <ber:codeRelatierol> is hard coded: i.c. of hoofverzekerde 'HVZ' in case of medeverzekerde 'MVZ'.
Geslacht en datumGeboorte are taken form the table.
The element <ber:verzekerde> is obligatiry for hoofdverzekerde but optional for medeverzekerde: only in case geslacht_medeverzekerde and geboortedatum_medeverzekerde are not null this 2nd <ber:verzekerde> element has to be added.
I created the next SQL (I skipped some stuff in order to focus on the problem):
CREATE OR REPLACE
VIEW dps_v_berekening_berichten
AS
SELECT msg_id as msg_id
, XMLElement( "ber:berekening"
, XMLAttributes( 'http://www.w3.org/2001/XMLSchema-instance' AS "xmlns:xsi"
, 'http://www.mycompany.nl/berekenen' AS "xmlns:ber"
, 'http://www.mycompany.nl/berekenen http://www.mycompany.nl/berekenen/berekening.xsd' AS "xsi:schemaLocation"
, XMLElement( "ber:nummerRekenRegel"
, XMLAttributes( 'http://www.mycompany.nl/berekenen' AS "xmlns:ber" )
, 1
, XMLElement( "ber:rekenparameters"
, XMLAttributes( 'http://www.mycompany.nl/berekenen' AS "xmlns:ber" )
, XMLElement( "ber:codeEvolutie" ) -- Empty
, XMLElement( "ber:verzekerde"
, XMLForest ( 'HVZ' AS "ber:codeRelatierol"
, xoa.geslacht_hoofdverzekerde AS "ber:geslacht"
, xoa.geboortedatum_hoofdverzekerde AS "ber:datumGeboorte"
, XMLElement( "ber:verzekerde"
, XMLForest ( 'MVZ' AS "ber:codeRelatierol"
, xoa.geslacht_medeverzekerde AS "ber:geslacht"
, xoa.geboortedatum_medeverzekerde AS "ber:datumGeboorte"
-- Some more elements.
) AS bericht
FROM DST_UP1_XML_OUTDATA xoa
The problem is that the XMLForest always creates an <ber:verzekerde> element for medeverzekerde. I tried to create an inline view with just the "vezekerde"attributes and conditionally joining this inline view with the dst_up1_xml_outdata table. That didn't solve my problem. Because in case of a medeverzekerde available it returned two XML documenst: one that included the hoofdverzekerde and one that included the medeverzekerde. And obviously that's not what I want.
I imagine I have to juggle with some of these SQL / XML functions although I cannot put the finger on the exact differences between some of these (XMLElement, XMLForest, XMLAgg, XMLSequence). The examples shown in de XML DB Developer's Guide don't seem to adress my problem.
Help !Hi, are you talking about this part that you don't want to be there? I am not so clear about your requirements.
XMLElement( "ber:verzekerde"
, XMLForest ( 'MVZ' AS "ber:codeRelatierol"
, xoa.geslacht_medeverzekerde AS "ber:geslacht"
, xoa.geboortedatum_medeverzekerde AS "ber:datumGeboorte"
If you want to control certain subelements so they don't appear, do not use xmlforest. Use xmlelement instead so it is easier to control it using case when. Mark (of Oracle, he should be here soon since OOW is over) showed me this technique and it helps tremendously, because oftentimes XDB will return an empty tag even though your consumers don't like it!
try something like this,
(case when xoa.geboortedatum_medeverzekerde = 'MVZ' then
xmlelement("ber:verzekerde",
xmlelement("What you want", colname),
xmlelement("ber:codeRelatierol", 'MVZ'),
(case when colname is not null or = some other value then
xmlelement("Rest", colname))
end)
end),
You may have to twig some details there. But the key is to use the case when construct to get rid of unwanted elements or empty elements. So you should only have the elements if you have a value of 'MVZ'. Hope this helps.
Ben
Maybe you are looking for
-
Sound looping using Swiffy export to HTML5
I am facing a problem when I export my flash using Google SWIFFY to HTML5! It wont play my sound track layer as loop anymore. only play it once when luanching the page in HTML5 and then it stops! I changed the settings in my Flash sound properties fr
-
Need info on how to delete Contracts
Hi All, I am new to SAP R/3. Please provide me info on transactions to create and delete contract and info on FM to delete Contracts in R/3 System.. All helpful answers will be rewarded. Regards, Udaya
-
I draw a (fill only) shape at 50% with the pencil tool and when I go to draw another, the transparency jumps back to 100%. I would like it to stay at 50% for every mark I make, anyone know how? I wish to build up multiple semi-translucent vector shap
-
I'm having trouble figuring out how to add the user name in the menu bar. I used to have it showing along with the time & date etc. But i've looked everywhere trying to figure out how to do it. Any help would be gratefully appreciated. Thank you.
-
WLC 4404 Upgraded to 7.0.235.3 (WPA HandShake Timeout) not availbale
Greetings, Just upgraded my Cisco 4404 WLC's to 7.0.235.3, the upgrade went just fine. My problem is when I either Telnet or SSH to my Lightweight AP's and run the "DOT11 WPA Handshake Timeout 1000" command the AP doesn't recognized this command. Thi