Geneartion of max srlno +1 for a given table and a column
Dear friends,
I am trying to write a function which will accept a table name and a column name (must be numeric) of that table, calculate the maximum value of the column name as under...
The funtion compiles fantastic but on execution it gives a lot of error. I admit to be a newbie writing dynamic sql, and hence needs help on that ....Below what I wrote...
create or replace function get_newsrl(TabNm user_tab_columns.TABLE_NAME%TYPE,ColNm user_tab_columns.COLUMN_NAME%TYPE) return number is
NewSrl number;
Begin
NewSrl:=0;
dbms_output.put_line(TabNm);
dbms_output.put_line(ColNm);
Begin
Execute Immediate
'Begin
'select max(' || ColNm ||') into NewSrl from ' ||TabNm||' Using '||ColNm||','||TabNm||';';
||'end;';
end;
NewSrl:=NewSrl+1;
Return NewSrl;
End;
SQL> create or replace function get_newsrl(TabNm Varchar2, ColNm Varchar2) return number is
2 NewSrl number;
3 Begin
4 /*
5 NewSrl:=0;
6 dbms_output.put_line(TabNm);
7 dbms_output.put_line(ColNm);
8 */
9 Execute Immediate
10 'select max(' || ColNm ||') into NewSrl from ' ||TabNm;
11 NewSrl:=NewSrl+1;
12 Return NewSrl;
13 Exception
14 When OTHERS
15 then return (- SQLCODE);
16 End;
17 /
Ôóíêöèÿ ñîçäàíà.
SQL> select get_newsrl('EMP', 'EMPNO') from dual;
GET_NEWSRL('EMP','EMPNO')
905
SQL>
Similar Messages
-
Projected Stock for a given Material and Location (System: SCM-APO)
Hello Experts,
Appreciate, if anybody can help me in getting a time-series key-figure data (Stock-On-Hand for a given Material and Location) for a given period.
I am working on a report to display the projected stock (Material & Location are known) for a given period (1 month).
I am able to view the above data in my planning book.
Thanks in advance.
Regards,
Prasanna
Edited by: Prasanna Gunji on Apr 9, 2010 3:42 PMHi Prasanna,
9ASOQMQTY - Stock in quality inspection
9ASOTRSQTY - Stock in transit
9AAVLSTCK - Projected Stock
Hope this helps
Regards
R. Senthil Mareeswaran. -
TO GET WEEKS for a given MONTH AND YEAR
Is there any FM to get the no of weeks for a given month, say 01 2005.
Can i get the week numbers say 1 2 3 4 5 for the given month and year.
Please let me know.
Happy Holidays.
Regards,
Manohar EHi Manohar,
Use FM DATE_GET_WEEK twice; first time pass first day of the month and again pass the last day of the month as a parameter. So u will be having week number(yyyyxx) for the first week of the month and week number for the last week of the month. From these two, in between week numbers u can easily fetch. I hope this will help u out.
Regards,
Kavya Shah -
How to get classification for a given material and material type in MM
Hello Friends,
One of my developer colleagues is struggling to find out : how to get classification for a given material and material type in MM?
He is looking for probable table and table fields to Select from.
I would appreciate seriously any help in this regard.
~Yours SincerelyHi
Below given the flow and table details for a given class and class type.
- Table KLAH --> This contains the "Internal class no" [ for the given Class & Class type ]
- Table KSML --> This contains the " internal character numbers " [ nothing but characteristics attached to the class ] , which can be fetched with the above fetched internal class no
- Table AUSP --> This table contains the objects ( material ) attached to the internal characters of that class
- Table CABNT --> This table contains the "Description" for the internal character numbers.
- award points if this is ok -
Info needed on how to get list price for a given MATNR and pricing Conditio
Hi All,
Can some one help me in finding List price for a given MATNR and pricing condition type.
Basically, i need info regarding the tables that i need to use for this purpose.
Thanks in advance.
Regards,
Udaya.
PS: All helpful answers will be rewarded.Hi Udaya,
A simple solution to all these kind of problems:
Goto Transation SE16
Table :TSTC
in Tcode :Give A* or V* or anything...and find the relevant transctions and data.
if found useful...reward points.
Regards,
Nisha -
Info needed on how to get list price for a given MATNR and pricing Conditi
Hi All,
Can some one help me in finding List price for a given MATNR and pricing condition type.
Basically, i need info regarding the tables that i need to use for this purpose.
Thanks in advance.
Regards,
Udaya.
PS: All helpful answers will be rewarded.Hi,
I moved your topic to this forum
Mario -
How to find the Datasources for the given table names ?
Hi All,
I have an urgent requirement where I ned to find the names of BW Datasources, created for the given table names.
Both the tables and Datasources are in BW system only. I can see the table in SE11 but I am unable to find its associated Datasources in the 'Where Used List'.
Is there any method ?
Will assign points to satisfactory answers.
Regards,
SrinivasHi,
Check this thread on how to find the DS.
I have the field name, please help me find the data source.
Once you identify your DS you find which all Data targets are fed by trying to see the " Show data flow" in RSA1 for this data source.
Hope this helps.
Thanks,
JituK
Edited by: Jitu Krishna on Apr 30, 2008 11:52 AM -
Hi all,
Long time ago, I manually created a Database (APGriMMRP) and 3 Tables (dbo.Table_1_XYcoordinates, dbo.Table_2_Soil, and dbo.Table_3_Water) in my SQL Server 2012 Management Studio (SSMS2012). The dbo.Table_1_XYcoordinates has the following columns: file_id,
Pt_ID, X, Y, Z, sample_id, Boring. The dbo.Table_2_Soil has the following columns: Boring, sample_date, sample_id, Unit, Arsenic, Chromium, Lead. The dbo.Table_3_Water has the following columns: Boring, sample_date, sample_id, Unit, Benzene, Ethylbenzene,
Pyrene. The dbo.Table_1_XYcoordinates is a Parent Table. The dbo.Table_2_Soil and the dbo.Table_3_Water are 2 Child Tables. The sample_id is key link for the relationship between the Parent Table and the Child Tables.
Problem #1) How can I print out or export these 3 dbo Tables?
Problem #2) If I right-click on the dbo Table, I see "Start PowerShell" and click on it. I get the following error messages: Warning: Failed to load the 'SQLAS' extension: An exception occurred in SMO while trying to manage a service.
--> Failed to retrieve data for this request. --> Invalid class. Warning: Could not obtain SQL Server Service information. An attemp to connect to WMI on 'NAB-WK-02657306' failed with the following error: An exception occurred in SMO while trying
to manage a service. --> Failed to retrieve data for this request. --> Invalid class. .... PS SQLSERVER:\SQL\NAB-WK-02657306\SQLEXPRESS\Databases\APGriMMRP\Table_1_XYcoordinates> What causes this set of error messages? How can
I get this problem fixed in my PC that is an end user of the Windows 7 LAN System? Note: I don't have the regular version of Microsoft Visual Studio 2012 in my PC. I just have the Microsoft 2012 Shell (Integrated) program in my PC.
Problem #3: I plan to create an XML Schema Collection in the "APGriMMRP" database for the Parent Table and the Child Tables. How can I handle the relationship between the Parent Table and the Child Table in the XML Schema Collection?
Problem #4: I plan to extract some results/data from the Parent Table and the Child Table by using XQuery. What kind of JOIN (Left or Right JOIN) should I use in the XQuerying?
Please kindly help, answer my questions, and advise me how to resolve these 4 problems.
Thanks in advance,
Scott ChangIn the future, I would recommend you to post your questions one by one, and to the appropriate forum. Of your questions it is really only #3 that fits into this forum. (And that is the one I will not answer, because I have worked very little with XSD.)
1) Not sure what you mean with "print" or "export", but when you right-click a database, you can select Tasks from the context menu and in this submenu you find "Export data".
2) I don't know why you get that error, but any particular reason you want to run PowerShell?
4) If you have tables, you query them with SQL, not XQuery. XQuery is when you query XML documents, but left and right joins are SQL things. There are no joins in XQuery.
As for left/right join, notice that these two are equivalent:
SELECT ...
FROM a LEFT JOIN b ON a.col = b.col
SELECT ...
FROM b RIGHT JOIN a ON a.col = b.col
But please never use RIGHT JOIN - it gives me a headache!
There is nothing that says that you should use any of the other. In fact, if you are returning rows from parent and child, I would expect an inner join, unless you want to cater for parents without children.
Here is an example where you can study the different join types and how they behave:
CREATE TABLE apple (a int NOT NULL PRIMARY KEY,
b varchar(23) NOT NULL)
INSERT apple(a, b)
VALUES(1, 'Granny Smith'),
(2, 'Gloster'),
(4, 'Ingrid-Marie'),
(5, 'Milenga')
CREATE TABLE orange(c int NOT NULL PRIMARY KEY,
d varchar(23) NOT NULL)
INSERT orange(c, d)
VALUES(1, 'Agent'),
(3, 'Netherlands'),
(4, 'Revolution')
SELECT a, b, c, d
FROM apple
CROSS JOIN orange
SELECT a, b, c, d
FROM apple
INNER JOIN orange ON apple.a = orange.c
SELECT a, b, c, d
FROM apple
LEFT OUTER JOIN orange ON apple.a = orange.c
SELECT a, b, c, d
FROM apple
RIGHT OUTER JOIN orange ON apple.a = orange.c
SELECT a, b, c, d
FROM apple
FULL OUTER JOIN orange ON apple.a = orange.c
go
DROP TABLE apple, orange
Erland Sommarskog, SQL Server MVP, [email protected] -
Need to know base table and base column name for Oracle view columns
I am trying to load metadata for some views and that requires me to know what the final table and column name would be corresponding to the view column.
For example, if I have a view x_v that is select a,b from x_v2; and x_v2 is a view that is select a,b,c from x;
I need to get the following information.
View View Col Base Table Base Col
X_V A X A
X_V B X B
and so on.
Is it possible to get this programmatically using any SYS schema tables or Dependency tables?
I tried an indirect approach wherein I lock tables using LOCK TABLE or FOR UPDATE OF. But I'm not too sure if I can go down to the level of individual view columns.
Can you help me with this?Thanks. I was looking at some indirect approaches.
I came up with this script that does it faster than dependencies but thats just for tables and not column mapping.
declare
cursor bt(cp_sid number) is
select u.name uname, o.name oname
from sys.obj$ o, sys.user$ u
where o.obj# in (select id1
from v$lock
where sid=cp_sid)
and u.user# =o.owner#;
cursor c_sid is
select sid
from v$session
where audsid =userenv('sessionid');
l_sid number;
l_view varchar2(100):= 'PER_PEOPLE_V';
l_schema varchar2(10):= 'APPS';
begin
open c_sid;
fetch c_sid into l_sid;
close c_sid;
dbms_output.put_line('SID: '||l_sid);
execute immediate 'lock table '||l_schema||'.'||l_view||' in row share mode nowait';
for i in bt(l_sid) loop
dbms_output.put_line(i.uname||'.'||i.oname);
execute immediate 'alter table '||i.uname||'.'||i.oname||' disable table lock';
execute immediate 'alter table '||i.uname||'.'||i.oname||' enable table lock';
end loop;
end;
It basically uses locks on views to verify locks on the base tables.
Just wondering, can we use FOR UPDATE OF statements to get to the columns? -
What is the Tcode for Aggregate Statstics Table and PSA table
What is the Tcode for Aggregate Statstics Table and PSA table
Hii raina..
There is no such perticular Tcode to check PSA data . Go to RSA1 and open ur DS . Right click and say manage. U will get PSA data.. But their should be data in PSA
I hope thjis is useful to u. -
Hi...
3....how to create table maintanence generator for a z table and how to use that for transfering a selected records to one server to another server.
thanks and regards,
k.swaminath reddyHi,
Table maintanance Generator is used to manually
input values using transaction sm30.The Table Maintenance Generator is used to create table maintenance program to add, modify or delete records in the database table. This can be accessed using transaction SE54 or in SE11 using the menu Utilities->Table Maintenance Generator
<b>
Follow below steps</b>
go to se11 check table maintanance check box under
attributes tab
utilities-table maintanance Generator->
create function group and assign it under
function group input box.
also assign authorization group default &NC& .
select standard recording routine radio in table
table mainitainence generator to move table
contents to quality and production by assigning
it to request.
select maintaience type as single step.
maintainence screen as system generated numbers
this dialog box appears when you click on create
button
save and activate table
http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ed2d446011d189700000e8322d00/content.htm
One step, two step in Table Maintenance Generator
Single step: Only overview screen is created i.e. the Table Maintenance Program will have only one screen where you can add, delete or edit records.
Two step: Two screens namely the overview screen and Single screen are created. The user can see the key fields in the first screen and can further go on to edit further details.
please check the link for getting information about table maintenance generator !
https://www.sdn.sap.com/irj/sdn/advancedsearch?query=use%20of%20table%20maintenance%20generator&cat=sdn_all
http://www.sapdevelopment.co.uk/tips/tips_tabmaint_tcode.htm
http://www.sap-img.com/abap/create-a-table-maintance-program-for-a-z-table.htm
Regards,
Priyanka. -
How to findout DS for a given table name!
Dear Members,
I am trying to find the datasource for the given customized table!....and it's not easy to find!!!
I kindly request you to share some inputs if any possibilites to find.
Many thanks in advance.
Best Regards,
KSHi Raj,
As you said it's a customized table it will be difficult to find the standard data source, better to create a generic data source.
Can you post ur requirement and what is the customized table n the fields in the table.
If its not a new development system you can make use of the table RSOSFIELDMAP-Mapping Between OLTP Source Fields and InfoObjects to get the data source names where that particular field is being used.
or else if its not used in any of the data source in your system then you can search in SDN or google to find out the data source.
If there is not data source related to your respective table then u can go for creation of Generic data source.
ROOSOURCE Header Table for SAP BW DataSources (SAP Source System/BW System)
Regards
KP
Edited by: prashanthk on Apr 1, 2011 12:30 PM -
How to get cost center ranges for a given company and division...
Hello Experts,
Is there a table, BAPI or FM that can get the company or division of a given cost center?
Currently I am creating cost center ranges in my program but that is not the best way to do it
since they can always add or delete cost centers. Just like in transaction OKEON wherein you
can see the cost center ranges for a given company or division.
Hope you can help me guys. Thank you and take care!Hi Viray,
You can try BAPI 'BAPI_COSTCENTER_GETDETAIL1'.
You need to pass controlling area and cost center detail to this BAPI.
It will return the cost center detail in return.
Hope this helps you.
Thanks,
Arun -
Just new to this and unable to find answers
My solution
Public Function GetTableColumnNames() As Boolean
Form1.ListBox1.Items.Clear()
_MDFFileName = String.Format("{0}.mdf", _DatabaseName)
_sqlConnectionString = String.Format("Data Source=(LocalDB)\v11.0;AttachDBFileName={1};Initial Catalog={0};Integrated Security=True;", _DatabaseName, Path.Combine(_DatabaseDirectory, _MDFFileName))
Dim cn As New SqlConnection(_sqlConnectionString)
'put the table name in brackets in case it has spaces in it
Dim SQLString As String = "SELECT * FROM [" & _TableName & "]"
Try
cn.Open()
Dim cmd As New SqlCommand(SQLString, cn)
Dim rdr As SqlDataReader =
cmd.ExecuteReader(CommandBehavior.KeyInfo)
Dim tbl As DataTable = rdr.GetSchemaTable
'This shows all of the information you can access about each column.
For Each col As DataColumn In tbl.Columns
Form1.ListBox1.Items.Add(col.ColumnName)
Debug.Print("col name = " & col.ColumnName & ", type = " & col.DataType.ToString)
Next
'Get each column.
For Each row As DataRow In tbl.Rows
Form1.ListBox1.Items.Add(row("ColumnName"))
Next
rdr.Close()
Catch
MessageBox.Show("Error opening the connection to the database.")
Finally
cn.Close()
End Try
Return _Success
End Function -
How to determine Free Pool Ids in Timesten Db for a given Table
Hi All,
I am using Times ten DB. I have a requirement that i need to have a query which will fetch the free ids in DB. Say
if a table has entries with ids 2,3,5 it should return me 1,4 or if the DB has entries for ids 99,100 the query should return me 1,2,3,......98.
We have found a query but that is not efficient enough as it fetched free ids starting from the ids present i.e it fetches for the case 1 but for case 2 it fails.That is if ids are from 99 or any no say 2 the ids 1,2..98 and id 1 is not retrieved respectively.
Any help on this will be appreciated.
Thanks and Regards,
Namita"Database General" is for the Oracle database not TimesTen. Please change the subject to "Please Ignore" and repost in the correct forum group. Thank you.
Maybe you are looking for
-
Issues with calendar invites from Outlook address that come to my gmail on iPhone
I have been trying for HOURS to get to the bottom of this iPhone calendar invite problem I'm having. I'll try to summarize. I LOVE iCal and I want to continue using it. Though I have a personal mid-2010 Macbook Pro, I don't use it too much (my compan
-
Closing a window or frame in amenu application
Sir, I am at present doing a project in java swing regarding preventive healthcare systems. I would like to let you know a problem i am confrontin now. The problem with my aplication is : It is a menu driven application (The previous application was
-
Convert application error to system error
Iam facing an issue in BPM, Iam triyng to access to a webservice using synchronous send step, and I ahve an exception branch to catch the syetm error and fault message. Eventhough I specified fault messages, application error was not properly recogni
-
The summary pretty well sums it up. Don't know that it makes a difference, but I'm using an iMac running Yosemite.
-
HT5509 How can I disable guided access without a password on my iphone
How can I disable guided access without a password on my iphone? Please help. I can't use Find My Iphone and touch screen.