Assigning NULL in a select statement to a page item that doesn't exist? 2.2
Hi all,
Should the following raise an exception or cause an error? It does not in APEX 2.2.0. This is in a PL/SQL region at the "After Header" render point.
Using a value other that NULL causes an error.
Thanks!
BEGIN
SELECT
NULL
INTO
:NOT_AN_ITEM
FROM
DUAL;
END;
It probably should but it doesn't in any version. It's because before it tries to update session state it compares the old and new values. If they're the same it skips the update. Since v('NOT_AN_ITEM') is null and the bound value is null, no update is attempted and no exception is raised.
Scott
Similar Messages
-
Plsql procedure containing select statement to fill page items
I would like to fill items :P200_A and :P200_B and so on
with the result of a SELECT which depends on the different values of many select lists.
E.G. :P200_list_alpha with the list of values
STATIC:less than 10;less,equal than 10;equal,above 10;above,indifferent;indiff
:P200_list_beta with the list of values
STATIC:active;active,passiv;passiv,excluded;excluded
How do I write the select statement ? I think it has to be executed in an anonymous PLSQL Procedure (after submit).
What is a convenient way to write the select statement ?
I could imagine to use lots of IF , ELSIF, ELSE statements and in each branch (here 12 ) the whole/complet SELECT statement is written.
How to solve this problem in an elegant way ?
In my opinion the CASE statement could be helpful, but how to use it in the WHERE clause with this nested conditions ?I think I got it:
SELECT col1, col2, col3, ...
INTO :P200_A , :P200_B , ....
FROM mytable_1, mytable_2
WHERE mytable_1.col1 = mytable_2.col1
AND (
CASE
WHEN :P200_LIST_ALPHA = 'less' AND NVL(TO_COL_WITH_ALPHA, 0) < 10 THEN 1
WHEN :P200_LIST_ALPHA = 'equal' AND NVL(TO_COL_WITH_ALPHA, 0) = 10 THEN 1
WHEN :P200_LIST_ALPHA = 'above' AND NVL(TO_COL_WITH_ALPHA, 0) > 10 THEN 1
WHEN :P200_LIST_ALPHA = 'indiff' THEN 1
ELSE 0
END = 1 )
AND
( CASE
WHEN :P200_LIST_BETA = 'active' AND TO_COL_WITH_BETA IN ( 'a', 'A', 'akt', 'AKT' ) THEN 1
WHEN :P200_LIST_BETA = 'passive' AND TO_COL_WITH_BETA IN ( 'p', 'P' ) THEN 1
WHEN :P200_LIST_BETA = 'excluded' AND TO_COL_WITH_BETA = 'X' THEN 1
ELSE 0
END = 1 )
;Edited by: wucis on Oct 24, 2011 4:09 PM -
Can we use is null in our select statement in ABAP program
hi,
I want to use 'is nul' or 'not null' in select statement of my ABAP program for any field. I have written below query but I am getting sy-subrc = 4 and getting no data. Can anyone resolve this.Hi,
I think you've posted your question on the wrong forum. This is the SAP Business One development forum which is not part of ERP and doesn't include any ABAP or Netweaver programming.
For a list of forums please see here:
http://forums.sdn.sap.com/index.jspa
Kind Regards,
Owen -
Dynamically assigning table name in select statement
how can i assign the table name dynamically in Select statement?
i tried following code
create or replace procedure proc1
as
x varchar2(100);
y varchar2(10);
begin
x='UNIT_MASTER';
execute immediate 'select unit_code into y from x where
rownum=1';
dbms_output.put_line(y);
end;
the procedure is created but when i execute the procedure the
error is shown in the execute immediate statementDo the following :
Create or replace procedure pro1 as
x varchar2(100);
y varchar2(10);
begin
x := 'UNIT_MASTER';
EXECUTE IMMEDIATE 'select unit_code from '||x||' where rownum
= 1' INTO y;
dbms_output.put_line(y); -
How can I call a Page Process from the Select statement for Report Page
I'm able to call a javascript using the below:
img src="#IMAGE_PREFIX#add2.gif" border="0" alt="Icon 4" onClick="javascript:add_connect1('||CPORT.ID||')"
But Now,
I'd like to accomplish (2) New things:
1. instead of using,....... onClick="javascript:add_connect1,
I'd like to call a Page Process, onClick=
2. I'd like to be able to call two different processes onClick.
a. onClick="javascript:passBack('||ID||')"
b. onClick= <Please see my question #1 above>
Can someone please help me with the syntax for this,
If indeed it can even be done?
Thanks- GaryGreg.
It seems that my situation is the one you describe in you second paragraph, where you mention:
you could then add the ID column value as a parameter to the javascript functionBut,
I do not know how to reference the variable in my javascript nor how to use it in my on-demand process.
If you can hellp me past this last little bump, then I think I will be able to use these skills in Sooo many different areas of my design.
Here's what I've got so far:
A. In the select statement I identify the javascript as:
onClick="javascript:connect_port('<font color=blue>''||ID||''</font>')";
B. In my javascript I have this:
<script language="JavaScript" type="text/javascript">
function connect_port(ID)
var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=CONNECT_PORT',0);
gReturn = get.get();
get = null;
</script>
C. In my on demand function I have this:
BEGIN
INSERT INTO CCONNECTIONS_B
BLDG_ID,CLST_ID,PORT_ID,STRAND_ID
) VALUES
:P2004_BLDG_ID,:P2004_CLST_ID,:P2004_PORT_ID,:P2004_STRAND_ID1
END;
You can see that I dont know how to use the value for 'ID' in either the javascript or the On-Process function.
If you can help me out with this one, Then I can imitate it for the rest.
-Gary
Edited by: garyNboston on Apr 3, 2009 6:44 AM
Edited by: garyNboston on Apr 3, 2009 6:44 AM
Edited by: garyNboston on Apr 3, 2009 6:45 AM
Edited by: garyNboston on Apr 3, 2009 6:47 AM -
MySql select statement in jsp page
Ok,
I need help with this select statement.
<%
// Determine what option is set to.
if(option == null || "".equals(option) || "Verify1".equals(option)){
if("Verify1".equals(option)){
// Retrive query specific to submitted form.
try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://" + mysql_host + ":3306/" + mysql_database, mysql_login, mysql_password);
st = conn.createStatement();
rs= st.executeQuery("SELECT organization FROM tblevent_approval WHERE MAX (keyid))";
// Get query results.
while(rs.next()){
organization = rs.getString("organization");
finally {
if(rs != null){
rs.close();
if(st != null){
st.close()
if(conn != null){
conn.close();
%>THE ERROR I AM GETTING
Syntax error, insert ")" to complete ExpressionThis line has the closing bracket inside the closing quote for the statement...
> rs= st.executeQuery("SELECT organization FROM tblevent_approval WHERE MAX (keyid))";It should be:
rs= st.executeQuery("SELECT organization FROM tblevent_approval WHERE MAX (keyid)");A simple typo ;-)
Hope this helps... -
Passing values to OnDemandProcess from Select Statement on Reports Page
I think I'm just missing some of the proper syntax, Can somebody please help me.
As I've come to understand this process of passing the values,
I recognize it as (3) steps.
1. Referencing the "javascript" in the Select Statement of the Reports Page.
2. Including the "javascript" in the Page Header region.
3. Defining the Process as an OnDemand Application Process.
My problem is:
a. I can't seem to get the Value passed to the Application Process.
b. I don't know how to reference the Value passed once I get it passed.
Here's what I've got done so far:
1. (The Select Statement)
onClick="javascript:ORDER_CONNECT_SEQUENCE('||ID||')
{code}
2. (The javascript)
{code}
function ORDER_CONNECT_SEQUENCE('+ID+')
var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=ORDER_CONNECT_SEQUENCE',0);
get.add('+ID+');
gReturn = get.get('+ID+');
{code}
3. (The Application Process)
{code}
BEGIN
Select '+ID+' into THIS_CIRCUIT from dual;
{code}
I Know that the Application Process is being referenced and that the OnClick routine is working properly,
because if I plug a Value into the Application Process, instead of using '+ID+',
Then I get all of my desired results.
Any help you can give me here is greatly appreciated.
Thanks- GaryDimitri, Thanks for your efforts here, but its still not working for me.
Here's what I understand from your suggestions:
1. (changes to the javascipt)
a. replace function ORDER_CONNECT_SEQUENCE('+ID+')
with
function ORDER_CONNECT_SEQUENCE(pId)
b. replace get.add('+ID+')
with
get.addParam('x01',pId)
c. replace getReturn = get.get('+ID+')
with
getReturn = get.get()
get = null2. (chages to the Application Process)
a. add l_value varchar2(4000) to my list of declarations
b. add l_value := wwv_flow.g_x01 below the begin statement
c. I guess then I would reference the l_value like this:
Select l_value into THIS_CIRCUIT from dual* Also, You didn't mention any changes in my Select statement in the Reports region of the page.
FYI.
onClick="javascript:ORDER_CONNECT_SEQUENCE('||ID||')
{code}
The 'ID' which I'm referencing here is an ID from the table which I'm querying.
Am I misunderstanding you somewhere?
Thanks- gary -
SQL Insert and Select statements on same page
Newbie here.
Is it possible to insert data from a form to a database and then get data from the database using "select" from the same page.
I have a form that submits the authors details to an Access database but I need to get the AuthorID (which is an autonumber in the table) to show on the same page.
<%@ page language="java" contentType="text/html" import="java.sql.*" %>
<html>
<head>
<title>Confirm Details Submission</title>
</head>
</body>
<%
String title = request.getParameter("title");
String surname = request.getParameter("surname");
surname = surname.replaceAll("'", "''");
String forename = request.getParameter("forename");
forename = forename.replaceAll("'", "''");
String address = request.getParameter("address");
address = address.replaceAll("'", "''");
String address2 = request.getParameter("address2");
address2 = address2.replaceAll("'", "''");
String town = request.getParameter("town");
town = town.replaceAll("'", "''");
String postcode = request.getParameter("postcode");
String email = request.getParameter("email");
email = email.replaceAll("'", "''");
String dob = request.getParameter("dob");
String telephone = request.getParameter("telephone");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection Conn = DriverManager.getConnection("jdbc:odbc:Novbase","","");
Statement Stmt = Conn.createStatement();
String Query = ("INSERT INTO Author (Title, Surname, Forename, Address, Address2, Town, Postcode, EMail, DOB, TelNo) VALUES ('" + title + "', '" + surname + "', '" + forename + "', '" + address + "', '" + address2 + "', '" + town + "', '" + postcode + "', '" + email + "', '" + dob + "', '" + telephone +"')");
//Stmt.executeUpdate(Query) is where the records are inserted.
int SQLStatus = Stmt.executeUpdate(Query);
if(SQLStatus != 0)
%>
Thank you. Your Author ID number is ??
<%
else
%>
Error - Your details have not been submitted</font></h4>
<br>
Please click back on your browser and try again. If you experience further difficulties please go to our <a href ="help.html">help</a> pages.<br>
<%
Stmt.close(); Conn.close();
%>
</body>
</html>Hi,
You could execute queries as many times as you want using the same connection.
For ex;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection Conn = DriverManager.getConnection("jdbc:odbc:Novbase","","");
Statement Stmt = Conn.createStatement();
String Query = ("INSERT INTO Author (Title, Surname, Forename, Address, Address2, Town, Postcode, EMail, DOB, TelNo) VALUES ('" + title + "', '" + surname + "', '" + forename + "', '" + address + "', '" + address2 + "', '" + town + "', '" + postcode + "', '" + email + "', '" + dob + "', '" + telephone +"')");
//Stmt.executeUpdate(Query) is where the records are inserted.
int SQLStatus = Stmt.executeUpdate(Query);
if(SQLStatus != 0)
Query = "SELECT Forname FROM Author;";
ResultSet name = stmt.executeQuery(Query);
//Now name will have all the Forname fields in the database. You could retrieve that using the get methods.
%>
Thank you. Your Author ID number is ??
<%
else
%>
Error - Your details have not been submitted</font></h4>
<br>
Please click back on your browser and try again. If you experience further difficulties please go to our <a href ="help.html">help</a> pages.<br>
<%
Stmt.close(); Conn.close();
%>
I hope that can help you.
Rajesh -
How to get notified when ever I select any frame (any page item) ?
I have added a observer class in my plugin which derives from ActiveSelectionObserver.
But my observer constructor is not getting called when i select a page item. (In short, I am not getting notified about the selection)
below is my code:
class CSDTSelectionObserverImpl : public ActiveSelectionObserver
public:
CSDTSelectionObserverImpl(IPMUnknown *boss);
virtual ~CSDTSelectionObserverImpl();
protected:
virtual void HandleSelectionChanged (const ISelectionMessage*);
virtual void HandleSelectionAttributeChanged(const ISelectionMessage* selectionMessage);
CREATE_PMINTERFACE(CSDTSelectionObserverImpl, kCSDTSelectionObserverImpl)
CSDTSelectionObserverImpl::CSDTSelectionObserverImpl(IPMUnknown *boss) : ActiveSelectionObserver(boss,IID_ICSDTSELECTIONOBSERVER) { }
CSDTSelectionObserverImpl::~CSDTSelectionObserverImpl() { }
void CSDTSelectionObserverImpl::HandleSelectionChanged(const ISelectionMessage* selectionMessage) { }
void CSDTSelectionObserverImpl::HandleSelectionAttributeChanged(const ISelectionMessage* selectionMessage) {
if (selectionMessage && selectionMessage->WasSuiteAffected(IID_ILAYOUTSELECTION_ISUITE))
Also, In my .fr file, I have added below:
AddIn
kDocBoss,
kInvalidClass,
IID_ICSDTSELECTIONOBSERVER, kCSDTSelectionObserverImpl,
Do I need to implement the ILayoutSelectionSuite as well to get the notification on page item selection or implementing Observer via ActiveSelectionObserver is sufficient?
Please help.I tried below in debug mode , but it gave me error while execution (when the line of code was called by in-design)
InterfacePtr<ILayoutSelectionSuite> iLayoutSelectionSuite(fCurrentSelection, UseDefaultIID());
if (iLayoutSelectionSuite == nil)
break;
iLayoutSelectionSuite->SelectPageItems(selection,Selection::kReplace,Selection::kDontScrollLayoutSelection); // Error
So I was not able to get the UIDList of the selected page items, hence I used below code and this is working.
InterfacePtr<const IIntegratorTarget> iIntegratorTarget(iLayoutSelectionSuite, UseDefaultIID());
std::auto_ptr<IIntegratorTarget::TargetSuiteCollection> selectionSuites(iIntegratorTarget->GetTarget(ILayoutTarget::kDefaultIID));
for(IIntegratorTarget::TargetSuiteCollection::size_type i = 0; i < selectionSuites->size(); i++)
ILayoutTarget* target = (ILayoutTarget*)selectionSuites->at(i).get();
if(!target)
continue;
selection = target->GetUIDList(kDontStripStandoffs);
But it would have been much easier and logical if I can get it using IlayoutSelectionSuite or if there is some better approach ?
Please let me know.
ileleLayoutSelectio
Let me -
Well, it's pretty much what it says. I'm trying to edit a page item and remove the width and max width on the Element properties. When I remove them and hit apply it functions properly, and the page item shows up with no width or max width property set. However, if I go to edit the page item again, the Width and Max Width fields are populated (30 and 2000 respectively) again. Thus, any action which saves the item will save the unwanted values. I don't want a width and a max width on the item; it shouldn't put them back.
I think default values should only be used in a
situation where no value has previously been
provided.
How can I tell the difference between the case where
I fetch a null value from the column because a null
value was previously saved and the case where "no
value has previously been provided"?Well, I would assume that there is something unique about the initial creation of an item versus the editing thereof (e.g. the item does not exist in the database, yet). It's only on create that you would want to provide default values, that is, when no value has previously been provided by the user. Any other time the item is edited, it already exists and any values submitted should not be overridden or replaced. Off the top of my head, this could be done with table level defaults (if all item types were to share the same defaults for all properties), or via an insert trigger. Either way, the defaults would only be applied on create, and not on edit.
Message was edited by:
CaptSimian -
Hi,
I have recently been asked to generate a program that reports of payroll postings to FI. This involves creating a giant select statement from the ppoix table to gather all the postings. My select statement is as follows:
SELECT pernr "EE Number
seqno "Sequential number
actsign "Indicator: Status of record
runid "Number of posting run
postnum "Number
tslin "Line number of data transfer
lgart "Wage Type
betrg "Amount
waers "Currency
anzhl "Number
meins "Base unit of measure
spprc "Special processing of posting items
momag "Transfer to FI/CO:EE grouping for acct determi
komok "Transfer to FI/CO: Symbolic account
mcode "Matchcode search term
koart "Account assignment type
auart "Expenditure type
nofin "Indicator: Expenditure type is not funded
INTO CORRESPONDING FIELDS OF TABLE i_ppoix
FROM ppoix
FOR ALL ENTRIES IN run_doc_xref
WHERE runid = run_doc_xref-runid
AND tslin = run_doc_xref-linum
AND spprc <> 'A'
AND lgart IN s_lgart
AND pernr in s_pernr.
where s_pernr is a select option that holds personnel nummbers and s_lgart is a select option that holds wagetypes. This statement works fine for a certain amount of personnel numbers and a certain amount of wagetypes, but once you exceed a certain limit the Database does not allow you to perform a select statement this large. Is there a better way to perform such a large select such as this one) ie: FM, or some other method I am not aware of. This select statement comes from the standard SAP delivered cost center admin report and this report dumps as well when too much data is passed to it.
any ideas would be much appreciated.
thanks.The problem here is with the select-options.
For a select statement, you cannot have more that certain amount of data.
The problem with your select becomes complex because of the FOR ALL ENTRIES in and the huge s_pernr and the 40 million records :(.
I am guessing that the s_lgart will be small.
How many entries do you have in internal table "run_doc_xref"?
If there are not that many, then I would suggest this:
TYPES:
BEGIN OF ty_temp_ppoix,
pernr TYPE ppoix-pernr,
lgart TYPE ppoix-lgart,
seqno TYPE ppoix-seqno,
actsign TYPE ppoix-actsign,
runid TYPE ppoix-runid,
postnum TYPE ppoix-postnum,
tslin TYPE ppoix-tslin,
betrg TYPE ppoix-betrg,
spprc TYPE ppoix-spprc,
END OF ty_temp_ppoix.
DATA:
i_temp_ppoix TYPE SORTED TABLE OF ty_temp_ppoix
WITH NON-UNIQUE KEY pernr lgart
INITIAL SIZE 0
WITH HEADER LINE.
DATA:
v_pernr_lines TYPE sy-tabix,
v_lgart_lines TYPE sy-tabix.
IF NOT run_doc_xref[] IS INITIAL.
DESCRIBE TABLE s_pernr LINES v_pernr_lines.
DESCRIBE TABLE s_lgart LINES v_lgart_lines.
IF v_pernr_lines GT 800 OR
v_lgart_lines GT 800.
* There is an index on runid and tslin. This should be ok
* ( still bad because of the huge table :( )
SELECT pernr lgart seqno actsign runid postnum tslin betrg spprc
* Selecting into sorted TEMP table here
INTO TABLE i_temp_ppoix
FROM ppoix
FOR ALL ENTRIES IN run_doc_xref
WHERE runid = run_doc_xref-runid
AND tslin = run_doc_xref-linum
AND spprc <> 'A'.
* The sorted table should make the delete faster
DELETE i_temp_ppoix WHERE NOT pernr IN s_pernr
AND NOT lgart IN s_lgart.
* Now populate the actual target
LOOP AT i_temp_ppoix.
MOVE: i_temp_ppoix-pernr TO i_ppoix-pernr.
* and the rest of the fields
APPEND i_ppoix.
DELETE i_temp_ppoix.
ENDLOOP.
ELSE.
SELECT pernr seqno actsign runid postnum tslin lgart betrg spprc
* Selecting into your ACTUAL target here
INTO TABLE i_ppoix
FROM ppoix
FOR ALL ENTRIES IN run_doc_xref
WHERE runid = run_doc_xref-runid
AND tslin = run_doc_xref-linum
AND spprc <> 'A'
AND pernr IN s_pernr
AND lgart IN s_lgart.
ENDIF.
ELSE.
* Error message because of no entries in run_doc_xref?
* Please answer this so a new solution can be implemented here
* if it is NOT an error
ENDIF.
Hope this helps.
Regards,
-Ramesh -
I m trying to find if LIMIT is a part of the select statement and if works like
set rowcount 1 in sybase....if anyone can post the generic select statement with LIMIT in it that would be great!
any help or input will be greatly appreciated
Thanks!Hallo,
i don't know sybase, but it is probably rownum
select * from scott.emp
where rownum < 3
Regards
Dmytro -
HOW CAN I USE MULTIPLE INNERJOINS IN A SINGLE SELECT STATEMENT?
HI,
I AM SHABEER AHMED,
I AM GETTING AN ERROR WHILE I ATTEMPT TO EXECUTE A SELECT STATEMENT WITH MULTIPLE INNER JOINS . BECOZ I WANT TO FETCH ITEM DATA, PARTNER DATA BASED ON HEADER DATA .
THEN OF COURSE I HAVE FETCH DATA FROM VBAK VBAP VBKD SO LZ SEND ME THE SOLUTION.
BYEHi,
1.Just see this:
SELECT * INTO CORRESPONDING FIELD OF TABLE itab
FROM t1 INNER JOIN t2 ON t1f4 EQ t2f4
INNER JOIN t3 ON t2f5 EQ t3f5 AND
t2f6 EQ t3f6 AND
t2f7 EQ t3f7.
2.But better to use for all entries.It increases the performance.
FOR ALL ENTRIES
Tabular Conditions
The WHERE clause of the SELECT statement has a special variant that allows you to derive conditions from the lines and columns of an internal table:
SELECT ... FOR ALL ENTRIES IN <itab> WHERE <cond> ...
<cond> may be formulated as described above. If you specify a field of the internal table <itab> as an operand in a condition, you address all lines of the internal table. The comparison is then performed for each line of the internal table. For each line, the system selects the lines from the database table that satisfy the condition. The result set of the SELECT statement is the union of the individual selections for each line of the internal table. Duplicate lines are automatically eliminated from the result set. If <itab> is empty, the addition FOR ALL ENTRIES is disregarded, and all entries are read.
The internal table <itab> must have a structured line type, and each field that occurs in the condition <cond> must be compatible with the column of the database with which it is compared. Do not use the operators LIKE, BETWEEN, and IN in comparisons using internal table fields. You may not use the ORDER BY clause in the same SELECT statement.
You can use the option FOR ALL ENTRIES to replace nested select loops by operations on internal tables. This can significantly improve the performance for large sets of selected data.
Example for ALL ENTRIES
DATA: TAB_SPFLI TYPE TABLE OF SPFLI,
TAB_SFLIGHT TYPE SORTED TABLE OF SFLIGHT
WITH UNIQUE KEY TABLE LINE,
WA LIKE LINE OF TAB_SFLIGHT.
SELECT CARRID CONNID
INTO CORRESPONDING FIELDS OF TABLE TAB_SPFLI
FROM SPFLI
WHERE CITYFROM = 'NEW YORK'.
SELECT CARRID CONNID FLDATE
INTO CORRESPONDING FIELDS OF TABLE TAB_SFLIGHT
FROM SFLIGHT
FOR ALL ENTRIES IN TAB_SPFLI
WHERE CARRID = TAB_SPFLI-CARRID AND
CONNID = TAB_SPFLI-CONNID.
LOOP AT TAB_SFLIGHT INTO WA.
AT NEW CONNID.
WRITE: / WA-CARRID, WA-CONNID.
ENDAT.
WRITE: / WA-FLDATE.
ENDLOOP.
INNER JOINS
In a relational database, you normally need to read data simultaneously from more than one database table into an application program. You can read from more than one table in a single SELECT statement, such that the data in the tables all has to meet the same conditions, using the following join expression:
SELECT...
FROM <tab> INNER JOIN <dbtab> AS <alias> ON <cond> <options>
where <dbtab> is a single database table and <tab> is either a table or another join expression. The database tables can be specified statically or dynamically as described above. You may also use aliases. You can enclose each join expression in parentheses. The INNER addition is optional.
A join expression links each line of <tab> with the lines in <dbtab> that meet the condition <cond>. This means that there is always one or more lines from the right-hand table that is linked to each line from the left-hand table by the join. If <dbtab> does not contain any lines that meet the condition <cond>, the line from <tab> is not included in the selection.
The syntax of the <cond> condition is like that of the WHERE clause, although individual comparisons can only be linked using AND. Furthermore, each comparison must contain a column from the right-hand table <dbtab>. It does not matter on which side of the comparison it occurs. For the column names in the comparison, you can use the same names that occur in the SELECT clause, to differentiate columns from different database tables that have the same names.
The comparisons in the condition <cond> can appear in the WHERE clause instead of the ON clause, since both clauses are applied equally to the temporary table containing all of the lines resulting from the join. However, each join must contain at least one comparison in the condition <cond>.
Example for INNER JOINS
REPORT demo_select_inner_join.
DATA: BEGIN OF wa,
carrid TYPE spfli-carrid,
connid TYPE spfli-connid,
fldate TYPE sflight-fldate,
bookid TYPE sbook-bookid,
END OF wa,
itab LIKE SORTED TABLE OF wa
WITH UNIQUE KEY carrid connid fldate bookid.
SELECT pcarrid pconnid ffldate bbookid
INTO CORRESPONDING FIELDS OF TABLE itab
FROM ( ( spfli AS p
INNER JOIN sflight AS f ON pcarrid = fcarrid AND
pconnid = fconnid )
INNER JOIN sbook AS b ON bcarrid = fcarrid AND
bconnid = fconnid AND
bfldate = ffldate )
WHERE p~cityfrom = 'FRANKFURT' AND
p~cityto = 'NEW YORK' AND
fseatsmax > fseatsocc.
LOOP AT itab INTO wa.
AT NEW fldate.
WRITE: / wa-carrid, wa-connid, wa-fldate.
ENDAT.
WRITE / wa-bookid.
ENDLOOP.
Regards,
Shiva Kumar(Reward if helpful). -
How to return the result set of multiple select statements as one result set?
Hi All,
I have multiple select statements in my stored procedure that I want to return as one result set
for instance
select id from tableA
union
select name from table b
but union will not work because the result sets datatypes are not identical so how to go about this ?
ThanksYou have to CAST or CONVERT (or implicitly convert) the columns to the same datatype. You must find a datatype that both columns can be converted to without error. In your example I'm guessing id is an int and name is a varchar or nvarchar.
Since you didn't convert the datatypes, SQL will use its data precedence rules and attempt to convert name to an int. If any row contains a row that has a value in name that cannot be converted to an int, you will get an error. The solution is
to force SQL to convert the int to varchar. So you want something like
select cast(id as varchar(12)) from tableA
union
select name from tableb
If the datatypes are something other that int or varchar, you must find a compatable datatype and then convert one (or both) of the columns to that datatype.
Tom -
FETCHING VALUES IN MULTI RECORD BLOCK FROM ANOTHER TABLE USING SELECT STATEMENT.
Hi,
I have one multi record block in which i want to fetch values
(more then one record) from another table using select statement
IN KEY NEXT ITEM.I am getting following error.
ORA-01422: exact fetch returns more than requested number of rows
Thanks in advance.In your case I see no reason to use non-database block and to try to populate it from a trigger with a query, instead of using the default forms functionality where you can associate the block and the fields with table, create where clause using bind variables and simply use execute_query() build-in to populate the block. The power of the forms is to use their build-in functionality to interact with the database.
Also, you can base your block on a query, not on a table and you dynamically change this query using set_block_property() build-in. You can use any dynamic queries (based on different data sources) and you simply need to control the column's data type, the number of the columns and their aliases. Something like creating inline views as a block data source.
However, you can replace the explicit cursor with implicit one like
go_block('non_db_block_name');
first_record();
FOR v_tab IN (SELECT *
FROM tab
WHERE col_name = :variable)
LOOP
:non_db_block_name.field1 := v_tab.col1;
:non_db_block_name.field2 := v_tab.col2;
next_record();
END LOOP;
Maybe you are looking for
-
Latest Windows 8.1 update under Boot Camp loses my cursor
I was having no problems running Windows 8.1 under Boot Camp on my MacBook Pro Retina (2012) with the latest Boot Camp drivers until I tried downloading Microsoft's latest major update to Windows 8.1 (KB2919355). After installing the update, I lost m
-
Problem in deleting a file.
I have a text file. I want to delete last few lines of that file. Without using an intermediate file, can I do this in a Java program ? Thanks.
-
Business Activity Monitoring for BPEL Processes
Hello, IEP is capable of monitoring real time events, Real time business event collection and processing. In that case, can we use IEP to monitor BPEL process activities with activity data. One very big part, the ability to provide functionality for
-
Hi, I am trying to create an effect in System.in.read() or System.in.readLine() by not echoing the characters, if anyone knows please let me know, thanx!!!!
-
JTree: How to get the currently selected node
How do I get the currently selected node in JTree? getLastSelectedPathComponent() this method always return the last selected node and not the current one. Thanks in advance Sachin