'||' Operator in sql query
Hi All,
we are using the "||" operator in the sql query.At the terms of the performance,Is it beneficial or not?
Please suggest me.
Select * from emp
where (ename||empno) in ('xxx'||'yyyy')
Thanks in advance...
user00001 wrote:
Hi All,
we are using the "||" operator in the sql query.At the terms of the performance,Is it beneficial or not?
Please suggest me.
Select * from emp
where (ename||empno) in ('xxx'||'yyyy')
Thanks in advance...if you have any index on empno, it wont use it. So you need to use it as
select * from emp where (ename, empno) = (('xxx','yyyy'))Ravi Kumar
Similar Messages
-
hi Experts,
while running SQL Query i am getting an error as
The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator. for the query
select T1. Dscription,T1.docEntry,T1.Quantity,T1.Price ,
T2.LineText
from OQUT T0 INNER JOIN QUT1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN
QUT10 T2 ON T1.DocEntry = T2.DocEntry where T1.DocEntry='590'
group by T1. Dscription,T1.docEntry,T1.Quantity,T1.Price
,T2.LineText
how to resolve the issueDear Meghanath,
Please use the following query, Hope your purpose will serve.
select T1. Dscription,T1.docEntry,T1.Quantity,T1.Price ,
CAST(T2.LineText as nvarchar (MAX))[LineText]
from OQUT T0 INNER JOIN QUT1 T1 ON T0.DocEntry = T1.DocEntry LEFT OUTER JOIN
QUT10 T2 ON T1.DocEntry = T2.DocEntry --where T1.DocEntry='590'
group by T1. Dscription,T1.docEntry,T1.Quantity,T1.Price
,CAST(T2.LineText as nvarchar (MAX))
Regards,
Amit -
LIKE operator is not working in SQL Query in XML file
Hi Gurus,
LIKE operator is not working in SQL query in XML template.
I am creating a PDF report in ADF using Jdeveloper10g. The XML template is as follows
<?xml version="1.0" encoding="WINDOWS-1252" ?>
<dataTemplate name="catalogDataTemplate" description="Magazine
Catalog" defaultPackage="" Version="1.0">
<parameters>
<parameter name="id" dataType="number" />
<parameter name="ename" dataType="character" />
</parameters>
<dataQuery>
<sqlStatement name="Q1">
<![CDATA[
SELECT ename, empno, job, mgr from EMP where deptno=:id and ename LIKE :ename || '%']]>
</sqlStatement>
</dataQuery>
<dataStructure>
<group name="EmployeeInfo" source="Q1">
<element name="EmployeeName" value="ename" />
<element name="EMPNO" value="empno" />
<element name="JOB" value="job"/>
<element name="MANAGER" value="mgr" />
</group>
</dataStructure>
</dataTemplate>
if i pass the parameter value of :ename from UI, it doesn't filter. But if I give ename = :ename it retrieves the data. Can anyone help me why LIKE operator doesn't work here?
Appreciate your help,
Shyamal
email: [email protected]Hi
Well for a start, you are doing some very strange conversions there. For example...
and to_char(a.msd, 'MM/DD/YYYY') != '11/11/2030'
and to_char(a.msd, 'MM/DD/YYYY') != '10/10/2030'If a.msd is a date then you should e converting on the other side ie.
and a.msd != TO_DATE('11/11/2030', 'MM/DD/YYYY')
and a.msd != TO_DATE('10/10/2030', 'MM/DD/YYYY')Also, you may want to take into consideration nothing being input in :P2_ITEM_NUMBER like this...
AND INSTR(a.item_number,NVL(:P2_ITEM_NUMBER,a.item_number)) > 0Is item number actually a number or char field? If it's a number, you want to explicitly convert it to a string for using INSTR like this...
AND INSTR(TO_CHAR(a.item_number),NVL(TO_CHAR(:P2_ITEM_NUMBER),TO_CHAR(a.item_number))) > 0?
Cheers
Ben -
Using '(' and less than operator in an xsql page sql query
Dear All,
I tried to use left parenthesis '(' and less than operator in an sql query through an xsql page, it doesn't let to use them.
Do you know how to use those in an xsql page?
Thanks for your help.
MustafaFollowing is the xsql page that I tried to run:
<?xml version="1.0"?>
<xsql:query xmlns:xsql="urn:oracle-xsql" connection = "bib" rowset-element="bib" row-element="book">
(SELECT year,title,last,first,' ' as affiliation,publisher,price
FROM book,author
WHERE year=2001 and bookid=parentid
UNION
SELECT year,title,last,first,affiliation,publisher,price
FROM book,editor
WHERE year=2001 and bookid=parentid)
INTERSECT
(SELECT year,title,last,first,' ' as affiliation,publisher,price
FROM book,author
WHERE publisher='Publisher1' and bookid=parentid
UNION
SELECT year,title,last,first,affiliation,publisher,price
FROM book,editor
WHERE publisher='Publisher1' and bookid=parentid)
</xsql:query>
This is the error message generated after running:
<ERROR>java.sql.SQLException: ORA-01009: missing mandatory parameter</ERROR>
When I remove the parentheses it works but this results in a different result set.
Can anybody tell me the reason?
Thanks,
Mustafa
null -
Filter SharePoint list items using CAML query as same as Like operator in SQL Server.
Hi ,
I have filtered SharePoint list items based on Name using CAML query <Contains> . Now I have a new requirement is to filter list items using Like operator in SQL. But Like operator is not in CAML.
How do I filter list items using CAML as same as Like operator in SQL.
Please let me know.
Thanks in Advance.Did you try using <Contains>?
http://social.technet.microsoft.com/Forums/sharepoint/en-US/15766fd5-50d5-4884-82a1-29a1d5e38610/caml-query-like-operator?forum=sharepointdevelopmentlegacy
--Cheers -
Returning operation, table and column from a sql query
Hi,
I am working on Oracle 10g and i have to do achieve something like this.
i have to create procedure or functions which will accept a SQL query and will return following :
1). Operation like 'SELECT', 'INSERT', 'UPDATE', 'DELETE' etc.
2). Column names
3). Table involved.
One way to achieve this would be through hard parsing of string which might be time consuming. So do we have any in-built oracle package or function for the same job ?
Regards,
Vikas KumarCheck for DBMS_SQL package and DESCRIBE_COLUMNS procedure in that package.
You might need a combination of this package and Hard parsing of the input string.
For operation you can trim any space and brackets using TRIM function and then you can extrcat first 6 characters using SUBSTR for Operation.
I have not worked or used DBMS_SQL so wont be able to help you much on this.
Here is the link for DBMS_SQL
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sql.htm#i1026120
Regards
Arun -
Getting error SQL Error : ORA-14551: cannot perform a DML operation inside a query
Hi gurus ,
Your help is greatly appreciated ..
I am doing some changes in the fucntion for an existing package .Introducing the new below check , am updating one of the tables based on a if condition ..
IF numALLOWED_COUNT >= numLAST_COUNT_ADDED+1 THEN
blnGDS_Allowed :=True;
varSTMT := 'UPDATE PROD.TMS_PROCESS_COUNTER ';
varSTMT := varSTMT ||' SET last_count_added = last_count_added+1';
varSTMT := varSTMT ||' WHERE process_name = ''DAILY_GDS_COUNT''';
varSTMT := varSTMT ||' AND COUNTER_IND = ''750FD130''';
PROC_LOG('Update Tms_Process_counter varSTMT --' || varSTMT);
IF INSERT_BATCH(99,varSTMT) > 0 THEN
NULL;
END IF;
Function for insert_batch :
UNCTION INSERT_BATCH(numTABLE_ID IN NUMBER, varSQL_STATEMENT IN VARCHAR2) RETURN NUMBER IS
varINSERT_BATCH_STMT VARCHAR2(32767) := NULL;
varADD_REC_TYPE BATCH_TABLES.ADD_REC_TYPE%TYPE;
BEGIN
PROC_LOG( 'INSIDE INSERT_BATCH IRC : ' || varSQL_STATEMENT ); --IRC 9/20 UC
INSERT INTO BATCH_STATEMENT(QUEUE_ID,TABLE_ID,STATEMENT,QUEUE_SEQUENCE_ID)
VALUES (numQUEUE_ID,numTABLE_ID,varSQL_STATEMENT,1);
RETURN 1;
EXCEPTION WHEN OTHERS THEN
PROC_LOG('Failed in INSERT_BATCH');
PROC_LOG('SQL Error : ' || SUBSTR(SQLERRM,1,1000));
RETURN -1;
END INSERT_BATCH;
desc PROD.BATCH_STATEMENT
QUEUE_ID NUMBER(15) NOT NULL
TABLE_ID NUMBER(2) NOT NULL
STATEMENT VARCHAR2(4000 BYTE) NOT NULL
QUEUE_SEQUENCE_ID NUMBER(5) NOT NULL
Some how when its calling the insert_batch , its giving me the error in the logs as below:
04:01:41 - Update Tms_Process_counter varSTMT --UPDATE PROD.TMS_PROCESS_COUNTER SET last_count_added = last_count_added+1 WHERE process_name = 'DAILY_GDS_COUNT' AND COUNTER_IND = '750FD130'
04:01:41 - INSIDE INSERT_BATCH IRC : UPDATE PROD.TMS_PROCESS_COUNTER SET last_count_added = last_count_added+1 WHERE process_name = 'DAILY_GDS_COUNT' AND COUNTER_IND = '750FD130'
04:01:41 - Failed in INSERT_BATCH
04:01:41 - SQL Error : ORA-14551: cannot perform a DML operation inside a querySome how when its calling the insert_batch , its giving me the error in the logs as below:
04:01:41 - SQL Error : ORA-14551: cannot perform a DML operation inside a query
Yes - and the exception is telling you EXACTLY what the problem is. You have a query
IF INSERT_BATCH(99,varSTMT) > 0 THEN
And you are performing a DML operation inside that query:
INSERT INTO BATCH_STATEMENT(QUEUE_ID,TABLE_ID,STATEMENT,QUEUE_SEQUENCE_ID)
VALUES (numQUEUE_ID,numTABLE_ID,varSQL_STATEMENT,1);
Like the exception says: you can't do that.
You need to call the function using PL/SQL and capture the return value into a variable. Then test that variable:
myVar := INSERT_BATCH(99,varSTMT);
if myVar > 0 THEN -
How to create sql query for item master with operator LIKE with variables?
hi all,
How to create sql query for item master with
operator LIKE(Contains,Start With,End With) with variables using query generator in SAP B1 ?
JeyakanthanHi Jeyakanthan,
here is an example (put the like statement into the where field)
SELECT T0.CardCode, T0.CardName FROM OITM T0 WHERE T0.CardName Like '%%test%%'
The %% sign is a wildcard. If you need start with write 'test%%' and otherwise ends with '%%test'. For contains you need '%%test%%'. You also could combinate this statements like 'test%%abc%%'. This means starts with test and contains abc.
Regards Steffen -
MS SQL query to get Subscription list from Operations Manager
Hi Experts,
Is there anyway get Subscription list from Operations Manager DB using SQL query? I lost subscription list, and need to create subscription as it was. Very urgent.
Thanks in advance.
Regards
Karthick MHi,
Hope the powershell command Get-SCOMNotificationSubscription can be helpful for you:
Get-SCOMNotificationSubscription
Retrieves a list of notification subscriptions.
https://technet.microsoft.com/en-us/library/hh918490(v=sc.20).aspx
Regards,
Yan Li
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected] -
Help with SQL query invloving time operations
I have created 2 tables in my SQL. One is the user_info table which stores the time of login and timezone of login for each user. The other is the post_table which stores the postid, user who makes the post, time of post and timezone for each posts.
CREATE TABLE user_info
user_id VARCHAR(20),
login_date DATE,
login_time_zone VARCHAR(20),
PRIMARY KEY (user_id)
CREATE TABLE post_table
post_id VARCHAR(20),
user_id VARCHAR(20),
datepost DATE,
time_zone VARCHAR(20),
PRIMARY KEY (post_id),
FOREIGN KEY (user_id) REFERENCES user_info(user_id) ON DELETE CASCADE
) ;Some sample data for my tables is as below -
INSERT INTO user_info VALUES( 'u1', to_date('9/17/2009 20:00','MM/DD/YYYY mi:ss'), -2 );
INSERT INTO user_info VALUES( 'u2', to_date('9/17/2009 19:55','MM/DD/YYYY mi:ss'), -4 );
INSERT INTO post_table VALUES( 'p1', 'u1', to_date('9/17/2009 20:50','MM/DD/YYYY mi:ss'), 6 );
INSERT INTO post_table VALUES( 'p2', 'u2', to_date('9/17/2009 20:30','MM/DD/YYYY mi:ss'), -5 );
INSERT INTO post_table VALUES( 'p3', 'u2', to_date('9/18/2009 6:00','MM/DD/YYYY mi:ss'), 2 );
INSERT INTO post_table VALUES( 'p4', 'u1', to_date('9/17/2009 21:00','MM/DD/YYYY mi:ss'), -3 );I need to write an SQL query which - finds the user(s) whose time difference between the login time and the latest time when he/she writes a post is the smallest. I need to consider the timezones here as well.
I am unsure if time_zone should be of type VARCHAR or TIMESTAMP so have created it as VARCHAR in my tables.
Someone please help me form this query.
PS : How do I user <code> tags in this forum to write sql statements.
Edited by: user11994430 on Oct 9, 2009 5:59 PMI tried with the following test data
INSERT INTO user_info VALUES( 'u1', to_date('9/17/2009 20:00','MM/DD/YYYY mi:ss'), 1 );
INSERT INTO user_info VALUES( 'u2', to_date('9/16/2009 13:00','MM/DD/YYYY mi:ss'), 1 );
INSERT INTO user_info VALUES( 'u3', to_date('9/18/2009 15:00','MM/DD/YYYY mi:ss'), 0 );
INSERT INTO user_info VALUES( 'u4', to_date('9/20/2009 17:00','MM/DD/YYYY mi:ss'), 0 );
INSERT INTO user_info VALUES( 'u5', to_date('9/14/2009 3:00','MM/DD/YYYY mi:ss'), -3 );
INSERT INTO user_info VALUES( 'u6', to_date('9/15/2009 6:00','MM/DD/YYYY mi:ss'), -3 );
INSERT INTO user_info VALUES( 'u7', to_date('9/16/2009 7:00','MM/DD/YYYY mi:ss'), 0 );
INSERT INTO user_info VALUES( 'u8', to_date('9/17/2009 8:00','MM/DD/YYYY mi:ss'), -8 );
INSERT INTO user_info VALUES( 'u9', to_date('9/18/2009 9:00','MM/DD/YYYY mi:ss'), 0 );
INSERT INTO user_info VALUES( 'u10', to_date('9/19/2009 10:00','MM/DD/YYYY mi:ss'), 1 );
INSERT INTO user_info VALUES( 'u11', to_date('9/20/2009 11:00','MM/DD/YYYY mi:ss'), -5 );
INSERT INTO user_info VALUES( 'u12', to_date('9/21/2009 19:00','MM/DD/YYYY mi:ss'), -8 );
INSERT INTO user_info VALUES( 'u13', to_date('9/1/2009 4:00','MM/DD/YYYY mi:ss'), -3 );
INSERT INTO user_info VALUES( 'u14', to_date('9/22/2009 7:00','MM/DD/YYYY mi:ss'), 1 );
INSERT INTO user_info VALUES( 'u15', to_date('9/24/2009 23:00','MM/DD/YYYY mi:ss'), 1 );
INSERT INTO user_info VALUES( 'u16', to_date('9/25/2009 11:00','MM/DD/YYYY mi:ss'), 1 );
INSERT INTO user_info VALUES( 'u17', to_date('9/26/2009 18:00','MM/DD/YYYY mi:ss'), -4 );
INSERT INTO user_info VALUES( 'u18', to_date('9/27/2009 13:00','MM/DD/YYYY mi:ss'), -8 );
INSERT INTO user_info VALUES( 'u19', to_date('9/17/2009 18:00','MM/DD/YYYY mi:ss'), -5 );
INSERT INTO user_info VALUES( 'u20', to_date('9/29/2009 22:00','MM/DD/YYYY mi:ss'), -8 );
INSERT INTO user_info VALUES( 'u21', to_date('9/30/2009 5:00','MM/DD/YYYY mi:ss'), -8 );
INSERT INTO user_info VALUES( 'u22', to_date('9/15/2009 7:00','MM/DD/YYYY mi:ss'), -4 );
INSERT INTO user_info VALUES( 'u23', to_date('9/16/2009 17:00','MM/DD/YYYY mi:ss'), -8 );
INSERT INTO user_info VALUES( 'u24', to_date('9/17/2009 19:00','MM/DD/YYYY mi:ss'), 0 );
INSERT INTO user_info VALUES( 'u25', to_date('9/18/2009 22:00','MM/DD/YYYY mi:ss'), -5 );
INSERT INTO user_info VALUES( 'u26', to_date('9/19/2009 15:00','MM/DD/YYYY mi:ss'), 1 );
INSERT INTO user_info VALUES( 'u27', to_date('9/20/2009 23:00','MM/DD/YYYY mi:ss'), 1 );
INSERT INTO post_table VALUES('p1', 'u26', to_date('9/14/2009 18:00','MM/DD/YYYY mi:ss'), -5 ) ;
INSERT INTO post_table VALUES('p2', 'u2', to_date('7/1/2009 15:00','MM/DD/YYYY mi:ss'), 1 ) ;
INSERT INTO post_table VALUES('p3', 'u2', to_date('7/20/2009 20:00','MM/DD/YYYY mi:ss'), 1 );
INSERT INTO post_table VALUES('p4', 'u5', to_date('7/20/2009 22:00','MM/DD/YYYY mi:ss'), 1) ;
INSERT INTO post_table VALUES( 'p5', 'u2', to_date('7/21/2009 10:00','MM/DD/YYYY mi:ss'), 1 );
INSERT INTO post_table VALUES( 'p6', 'u8', to_date('8/1/2009 20:00','MM/DD/YYYY mi:ss'), -8 );
INSERT INTO post_table VALUES( 'p7', 'u10', to_date('5/3/2009 15:00','MM/DD/YYYY mi:ss'), -3 ) ;
INSERT INTO post_table VALUES( 'p8', 'u25', to_date('9/15/2009 20:00','MM/DD/YYYY mi:ss'), -5 ) ;
INSERT INTO post_table VALUES( 'p9', 'u6', to_date('9/7/2009 19:00','MM/DD/YYYY mi:ss'), -3 ) ;
INSERT INTO post_table VALUES( 'p10', 'u10', to_date('7/22/2009 10:00','MM/DD/YYYY mi:ss'), 1 ) ;
INSERT INTO post_table VALUES( 'p11', 'u9', to_date('7/7/2009 13:00','MM/DD/YYYY mi:ss'), 0) ;
INSERT INTO post_table VALUES( 'p12', 'u2', to_date('7/30/2009 11:00','MM/DD/YYYY mi:ss'), 1 );
INSERT INTO post_table VALUES( 'p13', 'u10', to_date('7/22/2009 8:00','MM/DD/YYYY mi:ss'), 1 );
INSERT INTO post_table VALUES( 'p14', 'u6', to_date('5/30/2009 23:00','MM/DD/YYYY mi:ss'), 1 );
INSERT INTO post_table VALUES( 'p15', 'u3', to_date('5/31/2009 2:00','MM/DD/YYYY mi:ss'), 0 ) ;
INSERT INTO post_table VALUES( 'p16', 'u12', to_date('6/20/2009 7:00','MM/DD/YYYY mi:ss'), -8 ) ;
INSERT INTO post_table VALUES( 'p17', 'u20', to_date('6/20/2009 9:00','MM/DD/YYYY mi:ss'), -8) ;
INSERT INTO post_table VALUES( 'p18','u27', to_date('9/15/2009 11:00','MM/DD/YYYY mi:ss'), -5 );
INSERT INTO post_table VALUES( 'p19','u26', to_date('7/1/2009 20:00','MM/DD/YYYY mi:ss'), 0 ) ;
INSERT INTO post_table VALUES( 'p20', 'u25', to_date('7/2/2009 17:00','MM/DD/YYYY mi:ss'), -5 );
INSERT INTO post_table VALUES( 'p21', 'u27', to_date('7/3/2009 20:00','MM/DD/YYYY mi:ss'), 1) ;
INSERT INTO post_table VALUES( 'p22', 'u2', to_date('9/15/2009 13:00','MM/DD/YYYY mi:ss'), 1 ) ;
INSERT INTO post_table VALUES( 'p23', 'u21', to_date('5/30/2009 17:00','MM/DD/YYYY mi:ss'), -8 );
INSERT INTO post_table VALUES( 'p24', 'u25', to_date('8/30/2009 20:00','MM/DD/YYYY mi:ss'), -5 );
INSERT INTO post_table VALUES( 'p25', 'u18', to_date('9/13/2009 18:00','MM/DD/YYYY mi:ss'), -8 );
INSERT INTO post_table VALUES( 'p26', 'u11', to_date('9/9/2009 13:00','MM/DD/YYYY mi:ss'), -8 );
INSERT INTO post_table VALUES( 'p27', 'u23', to_date('9/10/2009 1:00','MM/DD/YYYY mi:ss'), -5 );
INSERT INTO post_table VALUES( 'p28', 'u22', to_date('9/10/2009 14:00','MM/DD/YYYY mi:ss'), -4 );The output I get is
USER_ID
u25
u9
u20
u5
u27
u8
u21
u23
u22
u26
u10
USER_ID
u3
u12
u18
u2
u6
u11
17 rows selected. -
Need sql query for like operation.
Hi All,
i have table like name column and contain the data like
ibm 100
ibm 200
ibm 300
a2b
a
b
c
like this ....
but sql query need search using like or any regular expression---
select * from table where name like (ibm 200 and ibm 300).
and i don't want use like this select * from table where name like' ibm 200' or name like 'ibm 300').
can you please any body help to correct the above query...
Edited by: anbarasan on Oct 16, 2011 10:02 PMWITH t AS
(SELECT 'ibm 100' NAME
FROM DUAL
UNION ALL
SELECT 'ibm 200' NAME
FROM DUAL
UNION ALL
SELECT 'ibm 300' NAME
FROM DUAL
UNION ALL
SELECT 'a2b' NAME
FROM DUAL)
SELECT *from t where REGEXP_LIKE (name, 'ibm')
and REGEXP_LIKE (name, '100|200') -
I'm having trouble with an SQL query. I've created a simple logon page wherein a user will enter their user name and password. The program will look in an Access database for the user name, sort it by Date/Time modified, and check to see if their password matches the most recent password. Unfortunately, the query returns no results. I'm absolutely certain that I'm doing the query correctly (I've imported it directly from my old VB6 code). Something simple is eluding me. Any help would be appreciated.
private void LogOn() {
//make sure that the user name/password is valid, then load the main menu
try {
//open the database connection
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:LawOffice2000", "", "");
Statement select = con.createStatement();
String strTemp = "Select * From EMPLOYEES Where INITIALS = '" + txtUserName.getText() + "' Order By DATE Desc, TIME Desc";
ResultSet result = select.executeQuery(strTemp);
while(result.next()) {
if (txtPassword.getPassword().toString() == result.getString("Password")) {
MenuMain.main();
else {
System.out.println("Password Bad");
System.out.println(txtUserName.getText());
System.out.println(result.getString("Password"));
break; //exit loop
//close the connection
con.close(); }
catch (Exception e) {
System.out.println("LawOfficeSuite_LogOn: " + e);
return; }
}The problem is here: "txtPassword.getPassword().toString() == result.getString("Password"))"
Don't confuse String's equals() method with the equality operator '=='. The == operator checks that two references refer to the same object. If you want to compare the contents of Strings (whether two strings contain the same characters), use equals(), e.g. if (str1.equals(str2))...
Example:String s1 = "foo";
String s2 = new String("foo");
System.out.println("s1 == s2: " + (s1 == s2)); // false
System.out.println("s1.equals(s2): " + (s1.equals(s2))); // trueFor more information, check out Comparison operators: equals() versus == -
How to configure a sql query of 110 lines in a DB Adapter
Hi all,
I have a sql query which is 110 lines and i need to use "select"operation in DB Adapter.I dont understand where to put the query in DB Adapter.I worked on a sql query which is 3 or 4 lines but this is the first time iam working on a sql Query with 110 lines.
Please help me.Give me sme link or any document that i can refer.
Thanks,
KiranHI,
Please use the option of Custom Sql and paste it there.
it does not matter what operation are you using but the xsd will form accordingly.
If you need to do only via Select operation in the wizard, than select the tables and add pararmeters in the next screen and try to give the logic there.
I feel the best thing to do would be with the Custom Sql query.
And whatever variables you need to pass dyanamically.
Just put an # symbol before to the column name .
The variable will be formed.
Thanks,
Tirumala Dixit. -
I'm attempting to dynamically generate a rather large SQL query via the "PL/SQL function body returning SQL query" report region option. The SQL query generated will possibly be over 32K. When I execute my page, I sometimes receive the "ORA-06502: PL/SQL: numeric or value error" which points to a larger than 32K query that was generated. I've seen other posts in the forum related to this dynamic SQL size limitation issue, but they are older (pre-2010) and point to the 32K limit of the DNS (EXECUTE IMMEDIATE) and DBMS_SQL. I found this post (dynamic sql enhancements in 11g) which discusses 11g no longer having the 32K size limitation for generating dynamic SQL. Our environment is on 11gR2 and using ApEx 4.2.1. I do not know which dynamic SQL method -- DNS or DBMS_SQL -- ApEx 4.2.1 is using. Can someone clarify for me which dynamic SQL method ApEx uses to implement the "PL/SQL function body returning SQL query" option?
As a test, I created a page on apex.oracle.com with a report region with the following source:
declare
l_stub varchar2(25) := 'select * from sys.dual ';
l_sql clob := l_stub || 'union all ';
br number(3) := 33;
begin
while length ( l_sql ) < 34000 loop
l_sql := l_sql || l_stub || 'union all ';
end loop;
l_sql := l_sql || l_stub;
for i in 1 .. ceil ( length ( l_sql ) / br ) loop
dbms_output.put_line ( dbms_lob.substr ( l_sql, br, ( ( i - 1 ) * br ) + 1 ) );
end loop;
return l_sql;
end;
The dbms_output section is there to be able to run this code in SQL*Plus and confirm the size of the SQL is indeed larger than 32K. When running this in SQL*Plus, the procedure is successful and produces a proper SQL statement which can be executed. When I put this into the report region on apex.oracle.com, I get the ORA-06502 error.
I can certainly implement a work-around for my issue by creating a 'Before Header' process on the page which populates an ApEx collection with the data I am returning and then the report can simply select from the collection, but according to documentation, the above 32K limitation should be resolved in 11g. Thoughts?
Shane.What setting do you use in your report properties - especially in Type and in Region Source?
If you have Type="SQL Query", then you should have a SELECT statement in the Region Source. Something like: SELECT .... FROM ... WHERE
According to the ERR-1101 error message, you have probably set Type to "SQL Query (PL/SQL function body returning SQL query)". In this situation APEX expects you to write a body of a PL/SQL function, that will generate the text of a SQL query that APEX should run. So it can be something like:
declare
mycond varchar2(4000);
begin
if :P1_REPORT_SEARCH is not null THEN
mycond:='WHERE LAST_NAME like :P1_REPORT_SEARCH ||''%''';
end if;
return 'select EMPLOYEE_ID, FIRST_NAME, LAST_NAME from EMPLOYEES ' ||mycond;
end;
And for escaping - are you interested in escaping the LIKE wildcards, or the quotes?
For escaping the wildcards in LIKE function so that when the user enters % you will find a record with % and not all functions, look into the SQL Reference:
http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/conditions007.htm
(You would than need to change the code of your function accordingly).
If you are interested in escaping the quotes, try to avoid concatenating the values entered by the user into the SQL. If you can, use bind variables instead - as I have in my example above. If you start concatenating the values into the text of SQL, you are open to SQLInjection - user can enter anything, even things that will break your SQL. If you really need to allow users to choose the operator, I would probably give them a separate combo for operators and a textfield for values, than you could check if the operator is one of the allowed ones and create the condition accordingly - and than still use bind variable for inserting the filtering value into the query. -
ORA-01006 during report from SQL Query
We are running WebDB 2.2 against a 7.3.4.4 database. I have a report created from a SQL query which references 4 bind variables. During execution I receive the following, Failed to bind - :periodyr| |' with
ORA-01006: bind variable does not exist.
Anyone have any idea what causes this error, could it be because I reference a bind variable (:periodyr) more than once in the query? Is there a work around?
I have included the where clause as reference:
WHERE gcc.code_combination_id = gb.code_combination_id
AND gb.code_combination_id = gjl.code_combination_id
AND gjl.je_header_id = gjh.je_header_id
AND gb.budget_version_id =
(select budget_version_id
from gl.gl_budget_versions
where budget_name = :periodyr| |' OPERATING')
AND gjh.actual_flag = 'B'
AND gb.actual_flag = 'B'
AND gb.period_name = gjl.period_name
AND gb.period_year = nvl(:periodyr,gb.period_year)
and gcc.segment2 = nvl(:cstctr,gcc.segment2)
and ffvobj.attribute10 = nvl(:ctrlgrp,ffvobj.attribute10)
and gcc.segment3 = nvl(:objcode,gcc.segment3)
Thanks
MarkI think there is a bug in the procedure which picks up the bind variables from a SQL.
Workground: put a space between variable :periodyr and operator | | as:
where budget_name = :periodyr | |' OPERATING')
Hope this will work
null
Maybe you are looking for
-
Hey. Please help me understand what needs to be done to connect my TV to my G4 Power Book to see the project Im working on now in Final Cut Pro 5. I have attached the S video out to the TV and I am seeing the desktop image on the TV screen, but when
-
Hi! I have a signed applet which has to write a file to the server, but i still get permission exceptions. I guess I still have to add permissions to the applet but I realy can't find how to do that. Can anyone give me a short tutorial on how to add
-
Error in Running Synchronous HelloWorld Example
Hi All, I am new to Oracle business process manager so I am facing problem in running simple Synchronous HelloWorld example.When I build in an eclipse BPEL designer I got the following error : Buildfile: C:\Documents and Settings\dcb\workspace\SyncHe
-
My i pod touch screen is very slow and can't open the full page to close the voice over
my ipod4 touch sceen very slow and i can't open the full page can't scrow to close the voice over
-
HT5922 can i watch the dvd in my desktop on my apple tv?
can i watch the dvd in my desktop on my apple tv? What are the steps?