Normal select statement error!??
Hello All,
I have a table with primary key (antrag_nr, beladeflag, stempel)
Desc test88
Name Null? Type
ANTRAG_NR NOT NULL NUMBER
A_PROZESS NUMBER
STEMPEL NOT NULL DATE
BELADEFLAG NOT NULL VARCHAR2(1)
desc test99
Name Null? Type
ANTRAG_NR NOT NULL NUMBER
A_PROZESS NUMBER
STEMPEL NOT NULL DATE
BELADEFLAG NOT NULL VARCHAR2(1)
select * from test99;
ANTRAG_NR A_PROZESS STEMPEL B
1 3 04-JAN-05 m
2 4 04-JAN-05 m
1 4 05-JAN-05 m
select * from test88;
ANTRAG_NR A_PROZESS STEMPEL B
1 1 01-JAN-05 m
1 2 02-JAN-05 m
1 2 03-JAN-05 m
1 3 04-JAN-05 m
2 1 01-JAN-05 m
2 2 02-JAN-05 m
2 3 04-JAN-05 m
I am writing this query now and getting the below answer.
select a.antrag_nr, a.a_prozess, a.stempel, a.beladeflag from test88 a, test99 b where a.antrag_nr = b.antrag_nr and a.a_prozess <> b.a_prozess and a.stempel = (select max(stempel) from test88);
ANTRAG_NR A_PROZESS STEMPEL B
2 3 04-JAN-05 m
1 3 04-JAN-05 m
according to my query I have a a.a_prozess <> b.a_prozess but why do I get 1 3 04-jan-05 m
Please let me know where have I gone wrong!!
RGds
Karhtik krishna
The way your initial query was designed, checks all a_prozess available for each antrag_nr. If I change your query around I can demonstrate.
select a.antrag_nr
, b.a_prozess
, a.stempel
, a.beladeflag
from test88 a
, test99 b
where a.antrag_nr = b.antrag_nr
and a.a_prozess <> b.a_prozess
and a.stempel = ( select max(stempel)
from test88
ANTRAG_NR A_PROZESS STEMPEL BELADEFLAG
1 4 4-JAN-2005 m
2 4 4-JAN-2005 m
Similar Messages
-
Select statement error.
Hi all,
I have a select statement which will join 4 tables as shown below. Something is not working right in the select statement and caused the shortdump.
I really cannot figure out where is not right.
Please help.
TYPES:
BEGIN OF t_lips,
matnr TYPE matnr,
lfimg TYPE lfimg,
meins TYPE meins,
vbeln TYPE vbeln_vl,
lfart TYPE lfart,
vstel TYPE vstel,
maktx TYPE maktx,
werks TYPE werks_d,
exnum TYPE exnum,
posnr TYPE posnr_vl,
uecha TYPE uecha,
netwr TYPE netwr,
waerk TYPE waerk,
vgbel TYPE vgbel,
END OF t_lips.
DATA: lt_lips TYPE TABLE OF t_lips.
SELECT lips~matnr lfimg lips~vrkme lips~vbeln lfart
vbap~vstel lips~arktx lips~werks exnum
vbap~netwr vbap~waerk lips~vgbel
lips~posnr lips~uecha
INTO TABLE lt_lips
FROM lips INNER JOIN vttp
ON vttp~vbeln = lips~vbeln
INNER JOIN likp
ON lips~vbeln = likp~vbeln
INNER JOIN VBAP
ON lips~vgbel = vbap~vbeln
WHERE vttp~tknum = ps_vttk-tknum
AND lfimg <> 0.
Error analysis
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_OPEN_SQL_DB', was not caught
in
procedure "GET_DATA" "(FORM)", nor was it propagated by a RAISING clause.
Since the caller of the procedure could not have anticipated that the
exception would occur, the current program is terminated.
The reason for the exception is:
In a SELECT access, the read file could not be placed in the target
field provided.
Either the conversion is not supported for the type of the target field,
the target field is too small to include the value, or the data does not
have the format required for the target field.Hi,
In the below code, where are you picking up value for LFIMG and LFART. Give the alias/table name for them also.
for ex. lips~lfimg....
SELECT lips~matnr lfimg lips~vrkme lips~vbeln lfart
vbap~vstel lips~arktx lips~werks exnum
vbap~netwr vbap~waerk lips~vgbel
lips~posnr lips~uecha
INTO TABLE lt_lips
FROM lips INNER JOIN vttp
ON vttp~vbeln = lips~vbeln
INNER JOIN likp
ON lips~vbeln = likp~vbeln
INNER JOIN VBAP
ON lips~vgbel = vbap~vbeln
WHERE vttp~tknum = ps_vttk-tknum
AND lfimg 0.
Hope this is useful.
Also selection of records should be same as declared in table lt_lips otherwise use 'INTO CORRESPONDING TABLE LT_LIPS'
Regards,
Saba
Edited by: Saba Sayed on Oct 24, 2008 9:30 AM -
Global profile select statement error
Hello,
I try to set up profiles to personalize reports for users.
When I use global profile with profile value of first kind (on a profile value screen i choose "value", type, my formula "="my variable", and click add) and attatch it to the publication, it doesn't work properly. No matter what i use inside formula field, BO environment doesn't personalize report in accordance to it.
I've noticed that there is something wrong with select statement created by BO. After sending a publication, report instance received by user has "description" field like "(and (equal null "my variable")). No matter what i put inside formula box in profile "equal null" statement is always added.
When i use second type profile value (filter expression) everythig seems to be fine.
Is this some kind of bug inside global profile mechanism
I have BO XI R 3.1 without any fixpacks.
Thanks in advance for any help
best regards
WojtekHi,
In the Values option one can only use fixed values no formulas. Hence the formulas will not work.
In my case the expression option does not work. Have you tried using a formual =CurrentUser in the expression field. -
Hi
i am trying to use the below statement . its giving error . pls have a look
*SELECT(%YEAR%,"[YEAR]","T_TIME",u201D[ID]=%T_TIME_SET%u201D)
*SELECT(%PYEAR%,"[YEAR]-1","T_TIME",u201D[ID]=%T_TIME_SET%u201D)
*RUNALLOCATION
*FACTOR=1
*DIM T_MOVEMENTS WHAT = CB; WHERE=OB;
*DIM T_TIME WHAT=MAR.%PYEAR%; WHERE=BAS(TOTAL.%YEAR%)
*ENDALLOCATION
*COMMIT
The resule
Validation status of executable file: Failed
- Incorrect syntax near 'u201D'. in:select [YEAR] from mbrT_TIME where u201D[ID]=%T_TIME_SET%u201D
Validation status of syntax: Failed
- Invalid syntax found; see statements in red
Bud if specify the year its running properly. pls advice me whare i was wrong
ThanksHi Narsi,
You can use the below instruction:
*SELECT(%YEAR%,"[YEAR]","T_TIME",u201DID='%T_TIME_SET%'u201D)
*SELECT(%PYEAR%,"[YEAR]-1","T_TIME",u201DID='%T_TIME_SET%'u201D)
I have just added single quote before and after %T_TIME_SET% and %T_TIME_SET%
Please try this!!
Thanks,
Rohit -
Hello,
I want to print user from my database, this is the code:
System.out.println("user:\n"); user = sc.next(); System.out.println("password:\n"); psw = sc.next(); Statement s = conn.createStatement (); s.executeQuery("SELECT usr, pass FROM log WHERE usr=''"+user+" AND pass=''"+psw); ResultSet rs = s.getResultSet (); if (s.getMoreResults()){ System.out.println("works"); } else if (!s.getMoreResults()){ System.out.println("doesn't"); System.exit(1); } while (rs.next ()) { String nameVal = rs.getString ("user"); String catVal = rs.getString ("pass"); System.out.println ( "name = " + nameVal + " pass = " + catVal); ++count; }
the connection is established, but it doesn't print anything when I enter data in it [ admin "1234" which exists in the db ], any idea what could be wrong? I have to mentioned that I'm a little bit fresh in Java databases.hey I sorted out! = )
ResultSet rs = s.getResultSet ();
if (rs.next()) {
do {
String nameVal = rs.getString ("lnum");
String catVal = rs.getString ("passwd");
System.out.println (
"name = " + nameVal
+ " password = " + catVal);
// System.out.println("Full access granted ");
JOptionPane.showMessageDialog(frame,
"Welcome in LYITstorage",
"Welcome",
JOptionPane.INFORMATION_MESSAGE);
Desktop.getDesktop().browse(new java.net.URI("www.google.com"));
} while (rs.next());
else{
JOptionPane.showMessageDialog(frame,
"Username or password are incorrect\n " +
"If You don't have an account please\n press the regestration link",
"Regestration problem",
JOptionPane.ERROR_MESSAGE);
}= ), thanks for help right now, but its not a end of my problems = ). I wanted to use it with INSERT, but it doesn' work as good as I want, as a matter of fact it's not working at all :), this is the code, any help would be nice :).
try
System.out.println("try");
Statement s = conn.createStatement ();
System.out.println("statement");
int count =0;
boolean temp;
String query = "INSERT INTO log (passwd, name,surname,lnum) VALUES ('"+pa+"', '"+n+"', '"+sn+"','"+nu+"')" ;
System.out.println("test");
count= s.executeUpdate(query);
System.out.println(query);
System.out.println(count);
ResultSet rs = s.getResultSet ();
if(rs.next()){
JOptionPane.showMessageDialog(frame,
"Welcome ",
"Welcome",
JOptionPane.INFORMATION_MESSAGE);
else {
JOptionPane.showMessageDialog(frame,
"User already exists","error",
JOptionPane.ERROR_MESSAGE);
} -
Urgent , abap select statement error ...
Hi all ,
here i attached my code , has anyone can tell me where is the error ???
when i active this code , it showed :
"comma without preceding colon(after select?)"
thanks a lot !
SELECT LIPSERDAT LIPSVBELN LIPSPOSNR LIPSVGPOS LIPS~LFIMG
LIPSVRKME LIKPWADAT_IST LIKPKUNAG LIKPKUNNR LIKP~VBELN
VBAPVBELN VBAPMATNR VBAPNETWR VBAPWAERK VBAPMWSBP VBAPNETPR
VBAPPOSNR VBUPKOSTA VBUPWBSTA VBUPFKSTA VBUPPOSNR VBUPVBELN
VBPAPARVW VBPAVBELN VBUKCMGST VBUKVBELN VBAKAUART VBAKVBELN
INTO (
WASTATUS-ERDAT , WASTATUS-VBELN , WASTATUS-POSNR ,
WASTATUS-VGPOS , WASTATUS-LFIMG , WASTATUS-VRKME ,
WASTATUS-WADAT_IST , WASTATUS-KUNAG ,WASTATUS-KUNNR ,
WASTATUS-LIKPVBELN , WASTATUS-VBAPVBELN , WASTATUS-MATNR ,
WASTATUS-NETWR , WASTATUS-WAERK , WASTATUS-MWSBP ,
WASTATUS-NETPR , WASTATUS-POSNR , WASTATUS-KOSTA , WASTATUS-WBSTA ,
WASTATUS-FKSTA , WASTATUS-VBUPPOSNR , WASTATUS-VBUPVBELN ,
WASTATUS-PARVW , WASTATUS-VBPAVBELN , WASTATUS-CMGST ,
WASTATUS-VBUKVBELN , WASTATUS-AUART , WASTATUS-VBAKVBELN )
FROM ( LIPS inner join LIKP
on LIKPVBELN = LIPSVBELN
inner join VBAP
on VBAPVBELN = LIPSVGBEL
and VBAPPOSNR = LIPSVGPOS
inner join VBUP
on VBUPPOSNR = LIPSPOSNR
and VBUPVBELN = LIPSVBELN
inner join VBPA
on VBPAVBELN = LIPSVBELN
inner join VBUK
on VBUKVBELN = LIPSVBELN
inner join VBAK
on VBAKVBELN = VBAPVBELN )
WHERE
LIPS~VBELN in P_SVBELN
and LIPS~ERDAT in P_ERDAT
and LIKP~KUNAG in P_KUNAG
and LIKP~KUNNR in P_KUNNR
and VBAP~VBELN in P_PVBELN
and VBUP~KOSTA in P_KOSTA
and VBUP~WBSTA in P_WBSTA
and VBUP~FKSTA in P_FKSTA
and VBPA~PARVW in P_PARVW
and VBUK~CMGST in P_CMGST .sorry all ,
i already removed the space on my code like that :
but it still displayed the error .
SELECT LIPS~ERDAT
<b>*LIPSVBELN LIPSPOSNR LIPSVGPOS LIPSLFIMG
*LIPSVRKME LIKPWADAT_IST LIKPKUNAG LIKPKUNNR LIKP~VBELN
*VBAPVBELN VBAPMATNR VBAPNETWR VBAPWAERK VBAPMWSBP VBAPNETPR
*VBAPPOSNR VBUPKOSTA VBUPWBSTA VBUPFKSTA VBUPPOSNR VBUPVBELN
*VBPAPARVW VBPAVBELN VBUKCMGST VBUKVBELN VBAKAUART VBAKVBELN</b> FROM ( LIPS inner join LIKP
on LIKPVBELN = LIPSVBELN
inner join VBAP
on VBAPVBELN = LIPSVGBEL
and VBAPPOSNR = LIPSVGPOS
inner join VBUP
on VBUPPOSNR = LIPSPOSNR
and VBUPVBELN = LIPSVBELN
inner join VBPA
on VBPAVBELN = LIPSVBELN
inner join VBUK
on VBUKVBELN = LIPSVBELN
inner join VBAK
on VBAKVBELN = VBAPVBELN )
INTO (WASTATUS-ERDAT)
<b>*WASTATUS-VBELN, WASTATUS-POSNR, WASTATUS-VGPOS,WASTATUS-LFIMG)
*WASTATUS-VRKME,
*WASTATUS-WADAT_IST, WASTATUS-KUNAG,WASTATUS-KUNNR,
*WASTATUS-LIKPVBELN, WASTATUS-VBAPVBELN, WASTATUS-MATNR,
*WASTATUS-NETWR, WASTATUS-WAERK, WASTATUS-MWSBP,
*WASTATUS-NETPR, WASTATUS-POSNR, WASTATUS-KOSTA, WASTATUS-WBSTA,
*WASTATUS-FKSTA, WASTATUS-VBUPPOSNR, WASTATUS-VBUPVBELN,
*WASTATUS-PARVW, WASTATUS-VBPAVBELN, WASTATUS-CMGST,
*WASTATUS-VBUKVBELN, WASTATUS-AUART, WASTATUS-VBAKVBELN )</b> WHERE
LIPS~VBELN in P_SVBELN
and LIPS~ERDAT in P_ERDAT
and LIKP~KUNAG in P_KUNAG
and LIKP~KUNNR in P_KUNNR
and VBAP~VBELN in P_PVBELN
and VBUP~KOSTA in P_KOSTA
and VBUP~WBSTA in P_WBSTA
and VBUP~FKSTA in P_FKSTA
and VBPA~PARVW in P_PARVW
and VBUK~CMGST in P_CMGST . -
Urgent , abap select statement error VBPA ...
hi gurus,
please tell me what is the wrong in the following select statment:
it returns 4 dispite that the data is there in the table VBPA
like this :
VBPA
Cl. : 200
Document : 0010002449
Item :
Funct : PE
Pers.No. : 100820
SELECT SINGLE
pernr
INTO w_pernr
FROM vbpa
WHERE VBELN EQ '0010002449'
and kunnr EQ 'PE'.hi
good
wrong one ->
SELECT SINGLE
pernr
INTO w_pernr
FROM vbpa
WHERE VBELN EQ '0010002449'
and kunnr EQ 'PE'.
SELECT SINGLE
pernr
INTO w_pernr
FROM vbpa
WHERE VBELN EQ 0010002449
and kunnr EQ PE.
change like this and check the difference.
thanks
mrutyun^ -
SELECT statement comparing 2 fields in a table.
Hi,
Can someone help me out in making a efficient SELECT statement for the follwing requirement.
Say, I want to select all the records from a database table where the field, PLANT is equal to field SALESORG in the table (i.e., when both fields are equal select that record).
Thanks & regards,
SreeHello,
I think this is the answer to your question... if you explain a bit more we can formulate a query.
Subquery
Variants:
1. ( select )
2. ALL ( select )
3. ANY ( select )
4. SOME ( select )
Effect
A subquery is a SELECT statement select that occurs within a
SELECT,
OPEN CURSOR,
UPDATE, or
DELETE statement
in the WHERE clause or HAVING clause, to check whether data from database tables or views meets certain criteria.
Subqueries have a restricted syntax in comparison to the normal SELECT statement:
SELECT result FROM source [WHERE where] [GROUP BY fields] [HAVING having].
Variant 1
( select )
If the subquery returns a single value, you can use any relational operator except LIKE and BETWEEN.
Example
Selecting the flights with the most passengers:
DATA: WA TYPE SFLIGHT.
SELECT * FROM SFLIGHT
INTO WA
WHERE SEATSOCC = ( SELECT MAX( SEATSOCC ) FROM SFLIGHT ).
WRITE: / WA-CARRID, WA-CONNID, WA-FLDATE.
ENDSELECT.
Note
If you use a subquery with a relational operator instead of EXISTS, you may only specify one column in the SELECT clause. This can be either a field from the database table or an aggregate expression. Subqueries of this kind are referred to as scalar subqueries.
Variant 2
ALL ( select )
If the subquery returns several lines, each containing one value, you specify that the comparison should apply for all of the values it returns.
Example
This example shows how to use ALL. It displays a list of the customer IDs of the customer (or customers) who have made the most bookings:
DATA: ID TYPE SBOOK-CUSTOMID, CNT TYPE I.
SELECT CUSTOMID COUNT( * ) AS C FROM SBOOK
INTO (ID, CNT)
GROUP BY CUSTOMID
HAVING COUNT( * ) >=
ALL ( SELECT COUNT( * ) FROM SBOOK GROUP BY CUSTOMID ).
WRITE: / ID, CNT.
ENDSELECT.
Variant 3
ANY ( select )
Variant 4
SOME ( select )
If the subquery returns several lines each containing one value, this variant specifies that the comparison should apply to at least one of the values returned. The IN operator is the same as the combination = ANY.
&ABAP_HINT
If you use a subquery with the EXISTS operator, the expression is true if the subquery selects at least one line. You can useuse * in the SELECT clause of subqueries that use EXISTS.
Example
Selecting all flights from Frankfurt to New York between 1.1.1999 and 31.3.1999 that are not yet full:
DATA: WA_SFLIGHT TYPE SFLIGHT.
SELECT * FROM SFLIGHT AS F INTO WA_SFLIGHT
WHERE SEATSOCC < F~SEATSMAX
AND EXISTS ( SELECT * FROM SPFLI
WHERE CARRID = F~CARRID
AND CONNID = F~CONNID
AND CITYFROM = 'FRANKFURT'
AND CITYTO = 'NEW YORK' )
AND FLDATE BETWEEN '19990101' AND '19990331'.
WRITE: / WA_SFLIGHT-CARRID, WA_SFLIGHT-CONNID,
WA_SFLIGHT-FLDATE.
ENDSELECT.
Subqueries such as the one in this example, in which the WHERE clause uses fields from the main query, are known as correlated subqueries. Subqueries can be nested, and a given subquery may contain any fields from other, hierarchically-superior subqueries.
In a correlated subquery, the subquery is executed for each line r returned by the main query. In the above example, the main query finds all flights in table SFLIGHT that are not full and that have a date that meets the selection criterion. The statement then performs the subquery for each of the records returned by the main query, using the corresponding values of CARRID and CONNID, to check whether the relevant flight operates between Frankfurt and New York.
Additional help
Subqueries -
How do you include static text in select statement in Dynamic pl/sql
I want to include some atatic text and get the output of 4 columns joined with a ":" delimiter within them in a select statement built using Dynamic PL/SQL. How do I build it.
e.g.
Normal select statement would be
select 'MY SKU IS : ', col1||':'||col2||':'||col3||':'||col4 from table1 where ....where condition
and output looks like :
MY SKU IS A:B:C:D
MY SKU IS a:b:c:d
Dynamically I have -
SQL_Stmt := 'select 'MY SKU IS : ', col1||':'||col2||':'||col3||':'||col4 from table1 where '|| wherecondition;
I understand that this does not work because the single quote terminates the string. But my question is how do I achieve the same result with dynamic PL/SQL ? How do I include the static strings and the delimiters. I have tried using double quote, '\'....
????SQL_Stmt := 'select ''MY SKU is ' || col1 || '':'' ||
col2 || '':'' ||
col3 || '':'' ||
col4 ||
' from table1 where ' || wherecondition; -
Tuning Select Statement . field sequence and where clause
Hi All
Are there any general guidelines how to write select < field sequence >where clause < field sequence ? Is that shuld be in order of the field sequence in tables?
And how to use this when we have a view or a inner - join . Is that separate from normal select statement that is using FOR ALL ENTRIES.
Please let me know any general guidelines available on this,
AmolHello Amol,
I have another hint:
The statement FOR ALL ENTRIES will package the select statements for every five entries in the internal table. So in comparison to the following code sequence...
LOOP AT itab.
SELECT * FROM table WHERE key = itab-key.
ENDLOOP
the number of select statements is reduced to 20% with
SELECT * FROM table INTO TABLE ...
FOR ALL ENTRIES IN itab
WHERE key = itab-key
If I'm expecting a <i>huge</i> amount of data a go a step further and create my own packages by building a range table with around 100-500 entries and execute a select there...
LOOP AT itab.
IF counter < 500.
APPEND itab-key TO range-tab. " just code example
ENDIF.
IF count >= 500.
SELECT * FROM table APPENDING TABLE ...
WHERE key IN range_tab
ENDIF.
" adjust and calculate counter
ENDLOOP.
* Don't forget last select statement after loop
Best wishes,
Florin -
Sql Error in Select statement when doing subquery
Hi,
I am trying to see what the error is in the subquery part of the select statement.
Subquery should be fetching the safety_stock_quantity based on the MAX(effectivity_date).
Any suggestions?
SELECT kbn.last_update_date,itm.segment1,itm.description,kbn.kanban_card_number,kbn.kanban_size,
(SELECT msc.safety_stock_quantity
FROM mtl_safety_stocks msc
WHERE msc.effectivity_date = (select MAX(msc2.effectivity_date)
from mtl_safety_stocks msc2
where msc2.inventory_item_id = itm.inventory_item_id
and msc2.organization_id = itm.organization_id)
AND msc.inventory_item_id = itm.inventory_item_id
AND msc.organization_id = itm.organization_id
FROM mtl_system_items_b itm
,mtl_onhand_quantities_detail moqd
,mtl_safety_stocks msc
,mtl_kanban_card_activity kbn
WHERE itm.inventory_item_id = kbn.inventory_item_id
AND itm.organization_id = kbn.organization_id
AND itm.inventory_item_id = moqd.inventory_item_id
AND itm.organization_id = moqd.organization_id
AND moqd.subinventory_code = kbn.source_subinventory
AND kbn.card_status = 1
AND kbn.supply_status = 5
AND msc.inventory_item_id = itm.inventory_item_id
AND msc.organization_id = itm.organization_id
GROUP BY
kbn.last_update_date,itm.segment1,itm.description,kbn.kanban_card_number,kbn.kanban_size;
Thanks
PravnHi, Pravn,
Remember the ABC's of GROUP BY:
When you use a GROUP BY clause and/or an aggregate fucntion, then every item in the SELECT clause must be:
(A) an <b>A</b>ggregate function,
(B) one of the "group <b>B</b>y" expressions,
(C) a <b>C</b>onstant, or
(D) something that <b>D</b>epends entirely on the above. (For example, if you "GROUP BY TRUNC(dt)", you can "SELECT TO_CHAR (TRUNC(dt), 'Mon-DD')").
There's a GROUP BY clause in your main query, so every item in the main SELECT clause must be one of the above. The last item, the unnamed scalar sub-query, is none of the above.
How can you fix this problem? That depends on your data, the results you want, and perhaps on your Oracle version. If you'd like help, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved. Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
Always say which version of Oracle you're using.
You may have noticed that this site normally doesn't display multiple spaces in a row.
Whenever you post formatted text (including, but limited to, actual code) on this site, type these 6 characters:
\(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing. -
Error "SELECT statement includes a reserved word"
Dear Sir,
I am developing Ms Access 2010 and XP is the operating system.
I have placed a combobox on a form, but when I tired to update new string value in the same combobox, it generates an error "The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is
incorrect." .
I have debuged "Not In List" event and find this error generates soon after completing the "Not In List" event. I tried to find out any help on the internet but failed.
I shall be ever grateful if some one could help this regards.
KazimI think you need to do some homework on how relational databases work.
The following is my short description of the database relational model, but I emphasise the word 'short'.
The subject is a complex one with a huge body of academic and technical literature, so I can only hope to touch upon the basic principles of the model:
"The database relational model was originally proposed by E F Codd in a paper in 1970 in the journal 'Communications
of the Association for Computing Machinery'. Since then there has been a vast amount of further theoretical work, and the relational model has shown itself to be a robust one.
Without going too deeply into the theoretical basis, which can be quite abstract, a relational database in essence models a part of the real world in terms of its entity types and the relationship types between them.
Note the inclusion of the word 'type' in both cases here.
While its almost always used in the former case, its often omitted in the latter case.
This is a little bit sloppy but not too important. When one talks about a 'relationship' it really refers to a relationship value.
As an example 'marriage' is a relationship type, but my being married to my wife Fiona is a relationship value, represented by our names on the marriage certificate, which is the physical equivalent of a row in a Marriages table with columns Husband
and Wife, each referencing the primary key of a table People.
This is a many-to-many relationship type (I've been married twice so would be in two rows, my first wife would also be in two rows as she remarried too).
It is resolved into two one-to-many relationship types, People to Marriages in each case, in one case via the Husband column in the other via the Wife column.
In a relational database tables model Entity Types.
In the above example People is an entity type, modelled by the People table.
Marriage is also an entity type, modelled by the Marriages table.
As we've seen it's also a relationship type. In fact a relationship type is just a special kind of entity type.
Each column in a table represents an attribute type of each entity type, so attribute types of People might be FirstName,
LastName, DateOfBirth etc. This table would also have a PersonID numeric column (usually an autonumber) as its primary key as names are not distinct.
Each row in a table represents one instance of the entity type, and the attributes of each instance are represented by values at column positions in the row.
This is the only way that data can be legitimately stored in a relational database.
It's important that there is no redundancy in the information content of the database.
This is achieved by the process of 'normalization'. Normalization is based on a set of 'normal form's ranging from First Normal Form (1NF) to Fifth Normal Form (5NF) and beyond, though the higher normal forms are of a rather
different nature and we need not concern ourselves unduly with them.
There is also a Boyce/Codd Normal Form (BCNF) which was inserted when it was found that the original Third Normal Form was deficient; it didn't cater satisfactorily for tables with two or more candidate keys where the keys were composite and overlapped,
i.e. Had a column in common. I won't go into the details of normalization here; you'll find it written up in plenty of places.
To see an example of redundancy and therefore a table which is not properly normalized take a look at the Customers table
in the sample Northwind database which comes with Access. You'll see that it includes City, State/Region and Country columns.
If you look at its data you'll see for instance that we are redundantly told twice that Boston is in Massachusetts, and that this is in the USA
twice. This is not just inefficient, it is dangerous as it leaves the table open to inconsistent data being entered.
There is nothing to stop somebody putting Boston in the Massachusetts in one row and Milwaukee
in another, or putting Milwaukee in the UK in one row and the USA in another.
To normalize the table it should be decomposed into Customers, Cities, Regions and Countries tables, each of the first three with a foreign key referencing the primary key of the next table up in the hierarchy."
In your case you say a book can have more than one publisher.
This is true if you regard the entity as the book as a single 'work', not as a title.
I have two copies of Jane Austen's Mansfield Park for instance, each by a different publisher.
It is a single 'work' however. I've no idea if anyone else has written a book called Mansfield Park, but there is no reason why not, so let's assume that one exists.
This is not the same 'work' as Jane Austen's book, so conceptually is a different entity of type Books, and would be represented by a separate row in a table Books.
In the above context there is a many-to-many relationship type between Books and Publishers.
There is only one way to model such a relationship type, which is by a table which resolves the relationship type into two one-to-many relationship types.
So the model would, diagrammatically be:
Books----<BookPublishers>----Publishers
Title is a non-key column of Books.
The same title may appear in different rows, as with our hypothetical Mansfield Park by another author.
The primary key of books is a numeric BookID, usually an autonumber.
The BookPublishers table would have foreign keys BookID and PublisherID referencing the primary keys of the two referenced tables.
It would also have columns representing any attributes of the relationship type between the book and the publisher.
The primary key of this table is a composite one of BookID and Publisher.
To record multiple editions of a book published by a publisher requires another table along the following lines:
BookEditions
....PublisherID
(FK)
....BookID
(FK)
....EditionNumber
....EditionDate
.....ISBN
In this table PublisherID and BookID are a composite foreign key referencing the primary key of BookPublishers.
Note that ISBN is a column in this table as it applies to each edition of a book.
In the language of the relational model it is said to be functionally determined by the key of BookEditions.
Hopefully my short stock description of the relational model above, and my brief description of how it applies to the reality
which you are attempting to model will give you an insight into how to build a database, but I would strongly recommend that you first do some background work on how the database relational model works and how to apply its principles in Access.
I'll leave you with my own four, not altogether serious but nevertheless valid, ground rules for designing a relational database:
1.
KISS (Keep it simple, stupid!).
2.
When in a hole the first thing to do is stop digging.
3.
Always take account of Murphy's Law: 'If something can go wrong, it will go wrong'
4.
Always follow the advice given by Richard Feynman to his students: 'Don't write it down until you understand it'.
Ken Sheridan, Stafford, England -
Getting error while executing this select statement
Hi All,
I am new to this community.
I am getting error whie compiling the below code. Its telling 'Text' is invalid identifier. Also i want to know how can we obtain 'parseable' version of the below query?
my basic intention is to create a trigger header through a select statement and show it the complete text as a single column..
select text from
(select 'CREATE OR REPLACE TRIGGER '||SUBSTR(column_name,2,4)||'aud
AFTER INSERT
OR UPDATE
OF '||column_name||',
OR DELETE ON '||table_name||'
FOR EACH ROW'
FROM(SELECT lower(REPLACE(column_name,'O_','')) column_name , /*changing O to O_*/
lower(replace(t.table_name,'_A_','_')) table_name,
lower(t.table_name) table_name1,
c.column_id
FROM all_tab_columns c,
(SELECT object_name table_name
FROM all_objects
WHERE object_name LIKE '%/_A/_%' ESCAPE '/') t
WHERE c.table_name(+) = t.table_name
AND SUBSTR(column_name(+),1,2) = 'O_'))thanks prathamesh. it solved the problem. i have one more question.
as of now it creates single create trigger statement for each column on a table.
example:
CREATE OR REPLACE TRIGGER ust_aud
AFTER INSERT
OR UPDATE
OF cust_id,
OR DELETE ON characteristic_t
FOR EACH ROW
however, i want to create trigger for all columns in a single statement. can you please help me how to do it?
basically want to 'CREATE TRIGGER' for all columns in a table. i am finding difficult how to change my query to suit this!!
i am pasting my original query again for your reference. pls advise...
example:
CREATE OR REPLACE TRIGGER ust_aud
AFTER INSERT
OR UPDATE
OF cust_id,
fixed_item_val,
copy_item_val,
rgn_id,
txn_id,
OR DELETE ON characteristic_t
FOR EACH ROW
ORIGINAL QUERY
select text from
(select 'CREATE OR REPLACE TRIGGER '||SUBSTR(column_name,2,4)||'aud
AFTER INSERT
OR UPDATE
OF '||column_name||',
OR DELETE ON '||table_name||'
FOR EACH ROW' text
FROM(SELECT lower(REPLACE(column_name,'O_','')) column_name , /*changing O to O_*/
lower(replace(t.table_name,'_A_','_')) table_name,
lower(t.table_name) table_name1,
c.column_id
FROM all_tab_columns c,
(SELECT object_name table_name
FROM all_objects
WHERE object_name LIKE '%/_A/_%' ESCAPE '/') t
WHERE c.table_name(+) = t.table_name
AND SUBSTR(column_name(+),1,2) = 'O_')) -
Runtime error at select statement in RFC_READ TABLE FM
Dear All,
I have copied the standard FM RFC_READ_TABLE to incorporate the customer needs. Below is the select query which I have written in this FM.
SELECT (po_search_text-column_text) INTO <wa> FROM ekko
INNER JOIN ekpo ON ekko~ebeln = ekpo~ebeln
INNER JOIN eket ON ekpo~ebeln = eket~ebeln AND ekpo~ebelp = eket~ebelp
INNER JOIN lfa1 ON ekko~lifnr = lfa1~lifnr
INNER JOIN lfm1 ON ekko~lifnr = lfm1~lifnr AND ekko~ekorg = lfm1~ekorg
INNER JOIN lfb1 ON ekko~lifnr = lfb1~lifnr AND ekko~bukrs = lfb1~bukrs
INNER JOIN t024 ON ekko~ekgrp = t024~ekgrp
INNER JOIN zatscsng_status ON eket~ebeln = zatscsng_status~po_number
AND eket~ebelp = zatscsng_status~po_line
AND eket~etenr = zatscsng_status~po_sched_line
INNER JOIN adrc ON zatscsng_status~delivery_addr = adrc~addrnumber
WHERE (po_search_text-cond_text)
ORDER BY (po_search_text-sort_text).
Here, posearch_text-column_text_ will have the fields to be selected at runtime and posearch_text-cond_text_ is the where condition. It is running fine in this case.
But when I try to select Item Category ( EKPO-PSTYP), if data is present for this category, it is returning the values but if data is not there for the particular item category in the where clause, it is giving a RUNTIME ERROR at the select statement.
Here is the ERROR ANALYSIS:
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_DYNAMIC_OSQL_SEMANTICS', was
not caught in
procedure "ZATSCSNG_RFC_READ_TABLE" "(FUNCTION)", nor was it propagated by a
RAISING clause.
Since the caller of the procedure could not have anticipated that the
exception would occur, the current program is terminated.
The reason for the exception is:
The current ABAP program has tried to execute an Open SQL statement
which contains a WHERE, ON or HAVING condition with a dynamic part.
The part of the WHERE, ON or HAVING condition specified at runtime in
a field or an internal table, contains the invalid value "<L_LINE>-PSTYP".
Edited by: Rob Burbank on Mar 17, 2010 5:09 PMNow that's what I call a join statement...
You probably have a bug in how you build po_search_text-cond_text, the content must be a syntactically correct where clause. It seems that in your example there is just "<L_LINE>-PSTYP" without a condition, so try omitting it altogether.
Debug the content of po_search_text-cond_text before it hits the select statement.
Thomas -
Error in select statement in CMOD
Hi Friends
I am enhancing a data source with some fields and in the CMOD i am writing the code.
My delcaration is as follows
begin of ty_dfkkzp,
SELW2 type dfkkzp-SELW2,
BLART type dfkkzp-BLART ,
BUDAT type dfkkzp-BUDAT ,
BLDAT type dfkkzp-BLDAT ,
TBETR type dfkkzp-TBETR ,
ZZRECEIPT type dfkkzp-ZZRECEIPT ,
ZZPAYCAT type dfkkzp-ZZPAYCAT ,
ZZPAYSRC type dfkkzp-ZZPAYSRC ,
ZZPAYTYPE type dfkkzp-ZZPAYTYPE ,
ZZTENDER type dfkkzp-ZZTENDER ,
end of ty_dfkkzp.
Following is my SELECT statement.
select
SELW2
BLART
BUDAT
BLDAT
TBETR
ZZRECEIPT
ZZPAYCAT
ZZPAYSRC
ZZPAYTYPE
ZZTENDER
into corresponding fields of table lt_dfkkzp
from dfkkzp
for all entries in it_data
where SELW2 = it_data-VTREF.
I am getting an error in the where clause. This is becuase VTERF ( Contract) is of type CHAR and length 20, where as SELW2 is of type CHAR but Length 35. I know the length and type should be the same. But this table DFKKZP strangely has SELW2(Contract) has length 35.
Can someone please suggest me how to handle this inorder for me to get this correct?.
Thanks in adv.
Regards
BNHi,
try this and let me know if it works.
Declare another internal table and work area like it_data1 type it_data as shown below.
Begin of it_data1_wa,
......... type........,
......... type .......,
SELW2 type dfkkzp-SELW2,
end if it_data_wa1.
data: it_data1 like standard table of it_data_wa.
data: it_data_wa type it_data
include all the fields inside the table.
loop at it_data into it_data_wa.
move corresponding lt_data_wa to it_data1_wa.
it_data1_wa-SELW2 = it_data_wa-VTREF.
append it_data1_wa to it_data1.
end loop.
now write the same select statement for all entries in it_data1 instead of it_data.
Regards,
Anusha
Maybe you are looking for
-
This happens when ever FF 9 is open
-
Stored Procedure Call from XMII
Hi, I am facing the following problem. My SQL Stored Procedure has one input parameter,and it returns three values. I want to know the syntax for calling this stored procedure ie. syntax in fixed query in XMII. Thanks.
-
Derar experts, In any orgn, it is common to give some amount (cash) on account without knowing the purpose. And at a latter day the same person (employee) will come to finance and settles his transaction. (Either he may return the balance of amount t
-
I don't understand why Apple removed this Nature folder from my desktop themes. How can I get it back?
-
Assign first column as fixed in table view
I have a table view with many columns and I was wondering if it's possible in JavaFX 2.2 to assign the first column as fixed so when a user scrolls to the right the first column is always visible? I checked the API and this forum and didn't find a wa