Help please : dbsequence refresh on MS sql server
This is a month that I work on this problem and no result
I want to set up a field as DBSequence with a database SQL Server, and then refreshes its value after an insert and can then edit the corresponding record on the same form ...
I tried to use a Impl class and method do_dml () but this one works only for MySQL and not for SQL Server , this is the code of the method do_DML ():
*protected void doDML(int i, TransactionEvent e) {*
super.doDML(i, e);
String currentViewName = getEntityDef().getName();
*if ( i == DML_INSERT) {*
PreparedStatement stmt = this.getDBTransaction().createPreparedStatement("SELECT last_insert_id()",1);
*try {*
stmt.execute();
ResultSet rs = stmt.getResultSet();
*if ( rs != null ){*
rs.first();
setAttribute("id",rs.getBigDecimal(1));
*} catch (SQLException ex) {*
ex.printStackTrace();
it also works on Oracle, simply activate the option "refrech after insert".
someone told me the following link, but I could not make it work:
http://www.oracle.com/technetwork/developer-tools/jdev/multidatabaseapp-085183.html
Now I would really like you to help me because my project is stuck because of this problem.
I would be very grateful
hello,
by searching in Help, I have found it possible to generate a field DBSequence and refreshes without using a database trigger, here's what I found:
*4.12.5 Assigning the Primary Key Value Using an Oracle Sequence*
As an alternative to using a trigger-assigned value (as described in Section 4.10.10, "How to Get Trigger-Assigned Primary Key Values from a Database Sequence"), you can assign the value to a primary key when creating a new row using an Oracle sequence. This metadata-driven approach allows you to centralize the code to retrieve the primary key into a single Java file that can be reused by multiple entity objects.
Example 4-17 shows a simple CustomEntityImpl framework extension class on which the entity objects are based. Its overridden create() method tests for the presence of a custom attribute-level metadata property named SequenceName and if detected, populates the attribute's default value from the next number in that sequence.
Example 4-17 CustomEntityImpl Framework Extension Class
package sample;
import oracle.jbo.AttributeDef;
import oracle.jbo.AttributeList;
import oracle.jbo.server.EntityImpl;
import oracle.jbo.server.SequenceImpl;
*public class CustomEntityImpl extends EntityImpl {*
*protected void create(AttributeList attributeList) {*
super.create(attributeList);
*for (AttributeDef def : getEntityDef().getAttributeDefs()) {*
String sequenceName = (String)def.getProperty("SequenceName");
*if (sequenceName != null) {*
SequenceImpl s = new SequenceImpl(sequenceName,getDBTransaction());
setAttribute(def.getIndex(),s.getSequenceNumber());
To assign the primary key value using an Oracle sequence:
Create the CustomEntityImpl.java file in your project, and insert the code shown in Example 4-17.
In the Application Navigator, double-click the entity you want to edit.
In the overview editor, click the Attributes navigation tab, and double-click the attribute you want to edit.
In the Edit Attribute dialog, set the attribute Type to Number, and then click the Custom Properties node.
Enter SequenceName for the name.
Enter the name of the database sequence for the value, click Add, and then click OK to create the custom property.
For example, a Dept entity could define the custom property SequenceName on its Deptno attribute with the value DEPT_TABLE_SEQ.
Now I do not know what I need to replace DEPT_TABLE_SEQ
Similar Messages
-
Require help with Pivot table query in SQL Server 2008
Hi,
I have a query regarding converting columns to rows in SQL Server 2008. Please look at the table below.
I need the output to look something like this :
The columns for the children can be dynamic or fixed ( max of 6 children) based on the Family_ID. For Example: A family can have 1 child or more than 1 child.
Not sure how to go about it. Would appreciate your help :)Looks like you need dynamic pivot on multiple columns. I have two articles on this topic, start from this one
T-SQL:
Dynamic Pivot on Multiple Columns
It has reference to my other blog post.
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles -
Need help in storing XML data in SQL server using EJB
Hi all...
i have one XML file and i need to store the data of XML in one of the table of SQL server ..i want to do this using EJB..
like this
Example :
Data i XML :
========
<Employee>
<Details>
<empid> 101 </empid>
<name> Ajitha </name>
</Details>
</Employee>
Table i have Created in SQL SERVER:
==============================
Empid || name
Final output should be :
=================
Empid || name
101 || AjithaHI,
Please check your settings as per following.
Goto T code> DC20>Define data carrier type "server, front end"---> Then check the setting as per below
Type Description Path Online
PC give descriptio maintain path Tick
Then Select this entry and click on " Define servers and files or folders"--->Then check the setting as per below
Data Carrier Type Description
DEFAULT PC default
Then Select this entry and click on "Identify front computer"--> Then check the setting as per below
Data Carrrier Type Net. address Description
Default PC DEFAULT Default for local PC
I have explained above so that u can co relate your settings with above..
I hope this will help you.
Thanks
Yogesh -
Little help please with forwarding traffic to proxy server!
hi all, little help please with this error message
i got this when i ran my code and requested only the home page of the google at my client side !!
GET / HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*
Accept-Language: en-us
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.2; .NET CLR 2.0.50727)
Host: www.google.com
Connection: Keep-Alive
Cookie: PREF=ID=a21457942a93fc67:TB=2:TM=1212883502:LM=1213187620:GM=1:S=H1BYeDQt9622ONKF
HTTP/1.0 200 OK
Cache-Control: private, max-age=0
Date: Fri, 20 Jun 2008 22:43:15 GMT
Expires: -1
Content-Type: text/html; charset=UTF-8
Content-Encoding: gzip
Server: gws
Content-Length: 2649
X-Cache: MISS from linux-e6p8
X-Cache-Lookup: MISS from linux-e6p8:3128
Via: 1.0
Connection: keep-alive
GET /8SE/11?MI=32d919696b43409cb90ec369fe7aab75&LV=3.1.0.146&AG=T14050&IS=0000&TE=1&TV=tmen-us%7Cts20080620224324%7Crf0%7Csq38%7Cwi133526%7Ceuhttp%3A%2F%2Fwww.google.com%2F HTTP/1.1
User-Agent: MSN_SL/3.1 Microsoft-Windows/5.1
Host: g.ceipmsn.com
HTTP/1.0 403 Forbidden
Server: squid/2.6.STABLE5
Date: Sat, 21 Jun 2008 01:46:26 GMT
Content-Type: text/html
Content-Length: 1066
Expires: Sat, 21 Jun 2008 01:46:26 GMT
X-Squid-Error: ERR_ACCESS_DENIED 0
X-Cache: MISS from linux-e6p8
X-Cache-Lookup: NONE from linux-e6p8:3128
Via: 1.0
Connection: close
java.net.SocketException: Broken pipe // this is the error message
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:115)
at java.io.DataOutputStream.writeBytes(DataOutputStream.java:259)
at SimpleHttpHandler.run(Test77.java:61)
at java.lang.Thread.run(Thread.java:595)
at Test77.main(Test77.java:13)please could just tell me what is wrong with my code ! this is the last idea in my G.p and am havin difficulties with that cuz this is the first time dealin with java :( the purpose of my code to forward the http traffic from client to Squid server ( proxy server ) then forward the response from squid server to the clients !
thanx a lot,
this is my code :
import java.io.*;
import java.net.*;
public class Test7 {
public static void main(String[] args) {
try {
ServerSocket serverSocket = new ServerSocket(1416);
while(true){
System.out.println("Waiting for request");
Socket socket = serverSocket.accept();
new Thread(new SimpleHttpHandler(socket)).run();
socket.close();
catch (Exception e) {
e.printStackTrace();
class SimpleHttpHandler implements Runnable{
private final static String CLRF = "\r\n";
private Socket client;
private DataOutputStream writer;
private DataOutputStream writer2;
private BufferedReader reader;
private BufferedReader reader2;
public SimpleHttpHandler(Socket client){
this.client = client;
public void run(){
try{
this.reader = new BufferedReader(
new InputStreamReader(
this.client.getInputStream()
InetAddress ipp=InetAddress.getByName("192.168.6.29"); \\ my squid server
System.out.println(ipp);
StringBuffer buffer = new StringBuffer();
Socket ss=new Socket(ipp,3128);
this.writer= new DataOutputStream(ss.getOutputStream());
writer.writeBytes(this.read());
this.reader2 = new BufferedReader(
new InputStreamReader(
ss.getInputStream()
this.writer2= new DataOutputStream(this.client.getOutputStream());
writer2.writeBytes(this.read2());
this.writer2.close();
this.writer.close();
this.reader.close();
this.reader2.close();
this.client.close();
catch(Exception e){
e.printStackTrace();
private String read() throws IOException{
String in = "";
StringBuffer buffer = new StringBuffer();
while(!(in = this.reader.readLine()).trim().equals("")){
buffer.append(in + "\n");
buffer.append(in + "\n");
System.out.println(buffer.toString());
return buffer.toString();
private String read2() throws IOException{
String in = "";
StringBuffer buffer = new StringBuffer();
while(!(in = this.reader2.readLine()).trim().equals("")){
buffer.append(in + "\n");
System.out.println(buffer.toString());
return buffer.toString();
Edited by: Tareq85 on Jun 20, 2008 5:22 PM -
Need help converting Oracle PIVOT script to SQL Server
I hope it is not inappropriate to ask for SQL Server question in a .NET forum. I can not understand SQl 2k5+ syntax for pivoting. I am pivoting on company name and storenbr in the following. Thanks for any help.
WITH dummydata AS
SELECT 'Store1' AS storenbr, 2 AS period, 1 AS weeknbr, '40' AS PLU, 'tomato' as descrip, 16 AS used, 100 AS wasted from dual UNION ALL
SELECT 'Store1' AS storenbr, 2 AS period, 1 AS weeknbr, '50' AS PLU, 'bacon' as descrip, 87 AS used, 100 AS wasted from dual UNION ALL
SELECT 'Store1' AS storenbr, 2 AS period, 2 AS weeknbr, '40' AS PLU, 'tomato' as descrip, 26 AS used, 100 AS wasted from dual UNION ALL
SELECT 'Store1' AS storenbr, 2 AS period, 2 AS weeknbr, '50' AS PLU, 'bacon' as descrip, 97 AS used, 100 AS wasted from dual UNION ALL
SELECT 'Store2' AS storenbr, 2 AS period, 1 AS weeknbr, '40' AS PLU, 'tomato' as descrip, 16 AS used, 100 AS wasted from dual UNION ALL
SELECT 'Store2' AS storenbr, 2 AS period, 1 AS weeknbr, '50' AS PLU, 'bacon' as descrip, 87 AS used, 100 AS wasted from dual UNION ALL
SELECT 'Store2' AS storenbr, 2 AS period, 2 AS weeknbr, '40' AS PLU, 'tomato' as descrip, 26 AS used, 100 AS wasted from dual UNION ALL
SELECT 'Store2' AS storenbr, 2 AS period, 2 AS weeknbr, '50' AS PLU, 'bacon' as descrip, 97 AS used, 100 AS wasted from dual UNION ALL
SELECT 'Store3' AS storenbr, 2 AS period, 1 AS weeknbr, '40' AS PLU, 'tomato' as descrip, 18 AS used, 100 AS wasted from dual UNION ALL
SELECT 'Store3' AS storenbr, 2 AS period, 1 AS weeknbr, '50' AS PLU, 'bacon' as descrip, 89 AS used, 100 AS wasted from dual UNION ALL
SELECT 'Store3' AS storenbr, 2 AS period, 2 AS weeknbr, '40' AS PLU, 'tomato' as descrip, 28 AS used, 100 AS wasted from dual UNION ALL
SELECT 'Store3' AS storenbr, 2 AS period, 2 AS weeknbr, '50' AS PLU, 'bacon' as descrip, 99 AS used, 100 AS wasted from dual
, store_details as
SELECT 'Store3' AS storenbr, 'D-Bingham' as districtname, 'R-15 James' as regionname, 'C-Atlantic' as companyname from dual UNION ALL
SELECT 'Store2' AS storenbr, 'D-Dunley' as districtname, 'R-15 James' as regionname, 'C-Atlantic' as companyname from dual UNION ALL
SELECT 'Store1' AS storenbr, 'D-Murdoc' as districtname, 'R-16 Reynolds' as regionname, 'C-Soutn' as companyname from dual
, pivoted as
select storenbr
, plu
, max(descrip) as Descrip
, max(decode(dd.weeknbr, 1, used , 0)) as Week1used
, max(decode(dd.weeknbr, 1, wasted , 0)) as Week1wasted
, max(decode(dd.weeknbr, 2, used , 0)) as Week2used
, max(decode(dd.weeknbr, 2, wasted , 0)) as Week2wasted
, max(decode(dd.weeknbr, 3, used , 0)) as Week3used
, max(decode(dd.weeknbr, 3, wasted , 0)) as Week3wasted
, max(decode(dd.weeknbr, 4, used , 0)) as Week4used
, max(decode(dd.weeknbr, 4, wasted , 0)) as Week4wasted
, max(decode(dd.weeknbr, 5, used , 0)) as Week5used
, max(decode(dd.weeknbr, 5, wasted , 0)) as Week5wasted
from dummydata dd
group by storenbr, plu
order by storenbr, plu
select decode(grouping(stores.storenbr), 0, stores.storenbr, decode(grouping(districtname), 0, districtname, decode(grouping(regionname), 0, regionname, decode(grouping(companyname), 0, companyname, 'GRAND')))) as storenbr
, decode(grouping(descrip), 0, descrip, 'TOTAL') as descrip
--== I substited Description for clarity
, sum(Week1used) as Week1used
, sum(Week1wasted) as Week1wasted
, sum(Week2used) as Week2used
, sum(Week2wasted) as Week2wasted
, sum(Week3used) as Week3used
, sum(Week3wasted) as Week3wasted
, sum(Week4used) as Week4used
, sum(Week4wasted) as Week4wasted
, sum(Week5used) as Week5used
, sum(Week5wasted) as Week5wasted
, companyname
from pivoted pvt
inner join store_details stores on pvt.storenbr = stores.storenbr
group by companyname
, rollup ( regionname
, districtname
, stores.storenbr
, descrip
;New output:
STORENBR DESCRIP WEEK1USED WEEK1WASTED WEEK2USED WEEK2WASTED WEEK3USED WEEK3WASTED WEEK4USED WEEK4WASTED WEEK5USED WEEK5WASTED COMPANYNAME
Store1 bacon 87 100 97 100 0 0 0 0 0 0 C-Soutn
Store1 tomato 16 100 26 100 0 0 0 0 0 0 C-Soutn
Store1 TOTAL 103 200 123 200 0 0 0 0 0 0 C-Soutn
D-Murdoc TOTAL 103 200 123 200 0 0 0 0 0 0 C-Soutn
R-16 Reynolds TOTAL 103 200 123 200 0 0 0 0 0 0 C-Soutn
C-Soutn TOTAL 103 200 123 200 0 0 0 0 0 0 C-Soutn
Store2 bacon 87 100 97 100 0 0 0 0 0 0 C-Atlantic
Store2 tomato 16 100 26 100 0 0 0 0 0 0 C-Atlantic
Store2 TOTAL 103 200 123 200 0 0 0 0 0 0 C-Atlantic
D-Dunley TOTAL 103 200 123 200 0 0 0 0 0 0 C-Atlantic
Store3 bacon 89 100 99 100 0 0 0 0 0 0 C-Atlantic
Store3 tomato 18 100 28 100 0 0 0 0 0 0 C-Atlantic
Store3 TOTAL 107 200 127 200 0 0 0 0 0 0 C-Atlantic
D-Bingham TOTAL 107 200 127 200 0 0 0 0 0 0 C-Atlantic
R-15 James TOTAL 210 400 250 400 0 0 0 0 0 0 C-Atlantic
C-Atlantic TOTAL 210 400 250 400 0 0 0 0 0 0 C-AtlanticArthurZ thank you, it was just a minor bug:
(DT_DATE)(SUBSTRING("20001211", 1,4) + "-" + SUBSTRING("20001211",
5,2) + "-" + SUBSTRING("20001211",
7,2) )
Working fine now :) thanks!
Sorry if I caused it, but glad you found it
Arthur
MyBlog
Twitter -
HELP: Reports Builder 9iDS Rel2 and SQL Server 2000
Hi,
I need to connect to a SQL Server 2000 database from within Report Builder (for a proof of concept) and I am getting error 62000-Failed to connect to datasource.
Can you help?
My OS is Windows Prof 2000.
I have Downloaded Oracle 9iDS Rel2 and Oracle 9i AS J2EE and Web Cache. They are installed in the same Oracle Home.
I have modified the REPORTS_CLASSPATH with the datadirect jar files and the j2ee oc4j.jar.
The oc4j.jar is in my system classpath.
I have added the classpath definition with jars to my rwserver.conf.
I start Report Builder select JDBC Query
enter my connect info:
Username: user
Passowrd: pwd
Database: dbname
and select the merant-sqlserver driver from the list.
What am I doing wrong?
I have been at this a week can anyone help?
Thanks.Hi Jeanne
1. When you run the report to paper design from builder, you need to add the necessary jar file of driver to REPORTS_CLASSPATH env variable in registery.
2. To run the report from report server and to generate to file from report builder, you need to add the jar files via classPath attribute of engine element in server/builder conf file. It would be like this
<engine id="rwEng" .....classPath="<yr classpath>" >
3. Have a look at jdbcpds.conf file in OH/reports/conf dir. This file need to have the driver information for the driver you are using. The entry here also specifies the connect sting format which is required by the driver. You need to refer to driver doc for connect string format.
Once you have all this set up ready, run the report. You need to mention the connect string in same format as specified in driver info in jdbcpds.conf file.
Try this.
Thanks
Rohit -
Help me shrink this database in SQL Server 2005
I archived a ton of records from a database, and it is expected to grow very slowly going forward. So please don't ask if I really need to shrink it or not. Yes...I definitely need to shrink it. I'm thinking it only needs to be 5GB now. But
I don't know how to shrink it without it running for a very long time.
408,092 MB Size
405,195 MB Space Available
I only have about 70 GB spare space on the drive that holds the log files, so I can't have it growing huge while the shrink is running.
Anyone know any tricks to get this done more efficiently?Are there LOB columns (text/ntext/image, (n)varchar/varbinary(MAX), xml) in the database? In that case the shrink could take a really long time, I believe. In that case it may be faster in terms of clock-time to build a new database and move all data move
over. But it will certainly take more of your time.
Shrinking is an online operation, that is it works with small transactions, so you can 1) interrupt it 2) back up the tranaction log while it's running to keep the disk space in check.
Erland Sommarskog, SQL Server MVP, [email protected] -
Help Configuring Transparent Gateway for Ms Sql Server
I have Installed Oracle 9.2.0.1.0 with Transparent Gateway for Ms Sql Server.
Followed the configuration furnished therein the Documents for Tnsnames.ora & Listener.ora.
Connection to Sql Server 2000 is NOT SUCCESSFUL. Trace File contents from Tg4sql is furnished below :
Oracle Corporation --- WEDNESDAY DEC 18 2002 22:32:50.625
Heterogeneous Agent Release
9.2.0.1.0
HS Agent diagnosed error on initial communication,
probable cause is an error in network administration
Network error 2: NCR-00002: NCR: Invalid usage
Note :- Sql Server & Oracle Server are on the same Machine running of Windows 2000 Server.
Am i missing something !!!
TIAPlease guide me, would appreciate your suggestions to solve this heck....
TIA -
Help with DR plan for Exchange & SQL Server vDP 6 please.
Hi there,
I just need a little guidance building a backup & DR strategy using vDP and/or VR. SRM is probably not in the budget right now.
First question about "Application" backup recovery.... Do I need BOTH a "Guest Image" & "Application" backup of these servers to be able to recover in case of disaster? I'm guessing YES, since when I try to "Restore" an Application backup, I only see the Exchange or SQL databases for example. I do not see the actual VM C:\ drive, etc. Would I use a "Guest Image" restore, THEN an "Application" restore for a full recovery? What happens if your SQL database is on the C:\ drive, you will be backing them up double in this scenario, once in Guest Image, then again in Application backups?
Next question.... I've tested VR to a remote location (no SRM yet), and it worked well. I consider this a good DR plan for what we need. We currently use TSM for backups. If I change to local vDP backup + replicated vDP backups at the remote site, would this be a good replacement instead of VR? Our RTO is not a huge issue. Can I recover the replicated backups easily to the remote hosts? I realize the advantages of SRM, and I would need to do more manual steps, but our budget is tight.
Thanks for your help.As with many things, these answers depend a lot on your environment, that said, from my experience as a customer, partner (and now with VMware) here are my answers:
- Depending on the application both guest and application can be a good idea. If you have applications with agents, I think it often makes sense to use them.
- You are correct that if you need to recover the entire VM, you would recover the VM image and then the application backup (if it was needed - there is a likelihood that the application backup may not be needed)
- You are correct, you are very likely backing up the application data twice. Seems worthwhile to me for the right applications, you'll have to evaluate for your environment
- VR or backups can work as a DR solution, especially if RTO isn't an issue. The main difference I see between them is RPO. VR can go as low as 15 mins, backups are usually 24 hours so again, it depends on your requirements. One additional benefit to SRM is the ability to non-disruptively test your DR plan which I think is one of the best parts of it. Totally understand about budget. I would recommend building and testing your DR plan and communicating the resulting RPO/RTO to the business so they are aware.
Does this answer your questions? -
Help! SQL Server to Oracle 10.1.0.2
Hello! I need your help.
I need to migrate SQL Server 2000 to Oracle 10g on HP-UX.
I read the SQL Developer documentation, but it only seems to be available for Windows, MacOS, and Linux.
Is there one available for Unix?
Thank you in advance,
siAs user502130 indicates, you don't have to run sqldev on the database server itself; any Linux/Windows/Mac client will do.
Nevertheless, if you can install a JDK on Unix, you can install the platform independent sqldev.
Have fun,
K. -
Cannot Migrate SQL Server Adventureworks Need Help
Has anyone been able to migrate Adventureworks from SQL Server 2005 to Oracle? I've been trying but keep getting errors in the "Build" step.
I would appreciate any help.The AdventureWorks example database in SQL Server relives heavily on the XML syntax within their stored procedures, functions, views. AdventureWorks example database was written to showcase new features of SQL Server 2005.
XML syntax is not currently handled by the T-SQL Translator, as for our initial releases we want to concentrate more on the more widely used syntax.
If your own database relies heavily on XML syntax then you will have to manually modify those statements.
If on the other hand your just trying out the SQL Developer Migration Workbench can I suggest using the Northwind example database.
Regards,
Dermot -
Hi, I've seen questions about this error posted elsewhere but I'm not sure if the same issues applied.
I'm trying to connect to SQL Server from a VBA macro in excel. I've managed to do this with the code below where my query is return to cells in my active worksheet but for another query I want to run the data to be return is too large for Excel to handle
and so I'd like to save it as a .csv file but using the second example of my code I get the message "[Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied". Since I have access to this database from the first example
of the code, I assume my conn.ConnectionString line of code is letting me down.
Can anyone help me please?
'Code to return data to worksheet'
Sub macro2()
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array(Array( _
"ODBC;DSN=SQLRA - OPENBET;UID=user1;Trusted_Connection=Yes;APP=Microsoft Office 2013;WSID=pdfdf3001;DATABASE=open;Network=DBMSS" _
), Array("OCN;Address=SQLRA_DB,55455;ApplicationIntent=READONLY;")), _
Destination:=Range("$BG$1")).QueryTable
.CommandText = Array( _
"select A.ev_oc_id, B.ev_mkt_id, A.ev_id, D.start_Time, Upper(Replace(A.[desc],'|','')) , A.result, COALESCE(A.sp_num, A.lp_num) , ", _
"COALESCE(A.sp_Den, A.lp_Den) from open.reporting.tevoc A, open.reporting.tevmkt B, open.reporting.tevocgrp C, open.reporting.tev D ", _
"where A.ev_mkt_id = B.ev_mkt_id and B.ev_oc_grp_id = C.ev_oc_grp_id and D.ev_id = A.ev_id and Upper(Replace(D.[desc],'|','')) = 'home' and upper(B.name) = '|today|' and D.ev_type_id in (264, 289) and D.ev_class_id = 49
and D.start>= '" & Year & "-" & Month & "-" & Day & "'" _
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = True
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "Table_Query_from_SQLRA___OPEN_1"
.Refresh BackgroundQuery:=False
End With
End Sub
'Code that produces error'
Sub macro1()
Dim conn As ADODB.Connection
Set conn = New ADODB.Connection
Dim testSQL As String
Dim qd As DAO.QueryDef
Dim openbetdb As Database
conn.ConnectionString = "driver={SQL Server}; server= sqlra_db;uid=user1;APP=Microsoft Office 2013;WSID=pdfdf3001;database=openbet"
conn.Open
testSQL = "SELECT * FROM open.reporting.TevType where ev_class_id = 49 and ev_type_id in(289,330,518,13492);"
Set qd = Db.CreateQueryDef("tmpExport", testSQL)
DoCmd.TransferText acExportDelim, , "tmpExport", "C:\\export.csv"
End SubHello,
Are you connect to remote SQL Server? If so,
please make sure the target SQL Server is running and is listening on appropriate protocols. Please take a look at the following article about general steps to troubleshoot
SQL connectivity issues:
http://blogs.msdn.com/b/sql_protocols/archive/2008/04/30/steps-to-troubleshoot-connectivity-issues.aspx
Regards,
Elvis Long
TechNet Community Support -
How to install SQL server 2008 express on Windows server 2008 R2 standard OS
Hi,
I have Windows server 2008 R2 Standard edition (64-bit) and trying to install SQL server 2008 express edition since I do not have SQL server 2008. When I install it I am unable to see Management Studio so I am trying to install management studio as well
but still I am facing issue. Please let me know whether SQL server 2008 express edition is compatible with Windows server 2008 R2 Standard. If not then pls let me know the proper steps to install it.
RegdsHello,
Service Pack 1 for SQL Server 2008 is required to be compatible with Windows Server 2008 R2.
Please download QL Server 2008 Express with SP1 included from the following link:
http://www.microsoft.com/en-us/download/details.aspx?id=25052
Hope this helps.
Regards,
Alberto Morillo
SQLCoffee.com -
CHECK for duplicate inside a cursor and pass a ouptut parameter in sql server 2008
Hi All,
I am inserting a value into a table, Before inserting i am checking that record already exists or not in the target table, If its existsing i am making an entry into errorlog table and set the output parameter to 'errorlog' . This is inside the cursor, as
il be passing multiple values. Next is I have separate query to get the new record which is not in the target table. Using EXCEPT i get the new record and i insert into a main table. after insertion i set output as 'success'.
Here while executing the procedure i pass a duplicate value and a new value. As it is in cursor,first it will insert into errorlog and set output parameter as 'errorlog' .Next it will insert a new record into main table and set output parameter as 'Success'.
So on completion of the execution of the procedure i get output as success.
But i should get as errorlog. I should get success only on no errors in the procedure. How i can i achieve this? Please help me.
Below is my code
IF NOT EXISTS(SELECT Beginmilepost,BeginTrackName,Endmilepost,EndTrackName
FROM SSDB_Segment WHERE BeginMilepost>=@BegMP AND EndMilepost<=@EndMP AND SearchID = @SearchID AND Reference = 'Range')
BEGIN
Declare C_Max1 Cursor FOR
(SELECT Beginmilepost,BeginTrackName,Endmilepost,EndTrackName FROM SSDB_Segment WHERE BeginMilepost = @BegMP AND EndMilepost = @EndMP AND BeginTrackName = @BegtrkName
AND EndTrackName = @EndTrkName AND SearchID = @SearchID)
Open C_Max1
FETCH FROM C_MAX1 INTO @BeginMilepost,@BTrackName,@EndMilepost,@ETrackName
WHILE(@@FETCH_STATUS=0)
BEGIN
IF OBJECT_ID ('tempdb..#temp') IS NOT NULL
BEGIN
DROP TABLE #temp
END--IF
Select BeginLatitude,BeginLongitude,BeginTrackName,BeginMilepost,BeginMilepostPrefix,BeginMilepostSuffix,EndLatitude,EndLongitude,EndTrackName,EndMilepost,TrainType into #temp
FROM
SELECT BeginLatitude= case when @BegLat = 0 THEN NULL ELSE @BegLat end ,BeginLongitude= case when @BegLong=0 THEN NULL ELSE @BEgLong end ,@BTrackName AS BeginTrackName,ROUND(@BeginMilepost ,3) AS BeginMilepost,
BeginMilepostPrefix= CASE WHEN @BegPrefix = 'null' THEN NULL ELSE @BegPrefix END,BeginMilepostSuffix= CASE WHEN @BegSuffix = 'null' THEN NULL ELSE @BegSuffix END,
EndLatitude=case when @EndLat =0 then NULL else @EndLat end,EndLongitude=case when @Endlong = 0 THEN NULL ELSE @Endlong END,@ETrackName AS EndTrackName,ROUND(@EndMilepost ,3) AS EndMilepost,@TrainType AS TrainType
UNION ALL
select BeginLatitude,BeginLongitude,BeginTrackName,ROUND(BeginMilepost,3) AS BeginMilepost,BeginMilepostPrefix,BeginMilepostSuffix, EndLatitude,EndLongitude,EndTrackName,ROUND(EndMilepost,3) AS EndMilepost,TrainType from SSDB_MaximumPermissibleSpeed)data
group by BeginLatitude,BeginLongitude,BeginTrackName,BeginMilepost,EndLatitude,EndLongitude,EndTrackName,EndMilepost,BeginMilepostPrefix,BeginMilepostSuffix,TrainType
having COUNT(*)>1
SET @COUNT= (select count(*) from #temp )
Print @COUNT
IF @COUNT>=1
BEGIN
INSERT INTO ErrorLog_Asset (
ErrorCode,
ErrorMessage,
TableName,
MilepostPrefix,
Milepost
SELECT
'1',
'Already exists at BeginMp '+ CAST(@BeginMilepost as varchar) +',EndMp '+ CAST(@EndMilepost as varchar) +' ,Beginlat
'+CAST(@BegLat as varchar)
+' ,Endlat '+CAST(@EndLat as varchar)+', BeginTrackName '+@BTrackName +' and EndTrackName '+@ETrackName
'MaximumPermissibleSpeed',
CASE WHEN @BegPrefix = 'null' THEN NULL
ELSE @BegPrefix END ,
@BeginMilepost
SET @output = 'Errorlog'
END
IF OBJECT_ID ('tempdb..#Max') IS NOT NULL
BEGIN
DROP TABLE #Max
END--IF
Select BeginLatitude,BeginLongitude,BeginTrackName,BeginMilepost,BeginMilepostPrefix,BeginMilepostSuffix,EndLatitude,EndLongitude,EndTrackName,EndMilepost,TrainType into #Max from
(SELECT BeginLatitude= case when @BegLat = 0 THEN NULL ELSE @BegLat end ,BeginLongitude= case when @BegLong=0 THEN NULL ELSE @BEgLong end ,@BTrackName AS BeginTrackName,ROUND(@BeginMilepost ,3)
AS BeginMilepost,
BeginMilepostPrefix= CASE WHEN @BegPrefix = 'null' THEN NULL ELSE @BegPrefix END,BeginMilepostSuffix= CASE WHEN @BegSuffix = 'null' THEN NULL ELSE @BegSuffix END,
EndLatitude=case when @EndLat =0 then NULL else @EndLat end,EndLongitude=case when @Endlong = 0 THEN NULL ELSE @Endlong END,@ETrackName AS EndTrackName,ROUND(@EndMilepost ,3) AS EndMilepost,@TrainType AS TrainType
except
select BeginLatitude,BeginLongitude,BeginTrackName,ROUND(BeginMilepost,3) AS BeginMilepost,BeginMilepostPrefix,BeginMilepostSuffix, EndLatitude,EndLongitude,EndTrackName,ROUND(EndMilepost,3) AS EndMilepost,TrainType
from SSDB_MaximumPermissibleSpeed)data
Declare C_Max2 Cursor FOR
Select BeginMilepost,BeginTrackName,EndMilepost,EndTrackName from #Max
Open C_Max2
FETCH FROM C_Max2 INTO @BeginMP,@BeginTrackName,@EnMP,@EnTrackName
WHILE(@@FETCH_STATUS=0)
BEGIN
IF (Select COUNT(*) from tbl_Trackname )>=1
BEGIN
IF (@TrainType IN (SELECT TrainType FROM SSDB_TrainType )AND (@Speed <>0) AND @BeginMP IS NOT NULL AND @BeginTrackName IS NOT NULL AND @EnMP IS NOT NULL
AND @Direction IN (SELECT Direction FROM SSDB_Direction) AND @EnTrackName IS NOT NULL )
BEGIN-------------
SET @ID = (Select MAX(MaximumpermissibleSpeedID) from SSDB_MaximumPermissibleSpeed)
IF @COUNT =0
BEGIN
INSERT INTO SSDB_MaximumPermissibleSpeed
BeginMilepostPrefix,
BeginMilepostSuffix,
BeginMilepost,
BeginTrackName,
BeginLatitude,
BeginLongitude,
BeginElevation,
EndMilepostPrefix,
EndMilepostSuffix,
EndMilepost,
EndTrackName,
EndLatitude,
EndLongitude,
EndElevation,
Direction,
Speed,
TrainType,
Description,
InsertUser,
S_ID
SELECT
CASE WHEN @BegPrefix = 'null' THEN NULL
ELSE @BegPrefix END,
CASE WHEN @BegSuffix = 'null' THEN NULL
ELSE @BegSuffix END,
@BeginMP ,
@BeginTrackName ,
case WHEN @BegLat = 0 THEN NULL
ELSE @BegLat END,
CASE WHEN @BegLong=0 THEN NULL
ELSE @BegLong END ,
CASE WHEN @BegEle = 0 THEN NULL
ELSE @BegEle END ,
CASE WHEN @EndPrefix = 'null' THEN NULL
ELSE @EndPrefix END,
CASE WHEN @EndSuffix = 'null' THEN NULL
ELSE @EndSuffix END,
@EnMP ,
@EnTrackName ,
case WHEN @EndLat = 0 THEN NULL
ELSE @EndLat END,
CASE WHEN @EndLong=0 THEN NULL
ELSE @EndLong END ,
CASE WHEN @EndEle = 0 THEN NULL
ELSE @EndEle END ,
@Direction ,
@Speed ,
@TrainType ,
CASE WHEN @Description ='null' THEN NULL
ELSE @Description END ,
@InsertUser ,
@UID
INSERT INTO SSDB_MaxSpeed_History
MSID,
BeginMilepostPrefix,
BeginMilepostSuffix,
BeginMilepost,
BeginTrackName,
BeginLatitude,
BeginLongitude,
BeginElevation,
EndMilepostPrefix,
EndMilepostSuffix,
EndMilepost,
EndTrackName,
EndLatitude,
EndLongitude,
EndElevation,
Direction,
Speed,
TrainType,
Description,
S_ID,
NOTES ,
[Action] ,
InsertUser
SELECT
(Select MaximumPermissibleSpeedID from SSDB_MaximumpermissibleSpeed WHERE MaximumPermissibleSpeedID > @ID),
CASE WHEN @BegPrefix = 'null' THEN NULL
ELSE @BegPrefix END,
CASE WHEN @BegSuffix = 'null' THEN NULL
ELSE @BegSuffix END,
@BeginMP ,
@BeginTrackName ,
case WHEN @BegLat = 0 THEN NULL
ELSE @BegLat END,
CASE WHEN @BegLong=0 THEN NULL
ELSE @BegLong END ,
CASE WHEN @BegEle = 0 THEN NULL
ELSE @BegEle END ,
CASE WHEN @EndPrefix = 'null' THEN NULL
ELSE @EndPrefix END,
CASE WHEN @EndSuffix = 'null' THEN NULL
ELSE @EndSuffix END,
@EnMP ,
@EnTrackName ,
case WHEN @EndLat = 0 THEN NULL
ELSE @EndLat END,
CASE WHEN @EndLong=0 THEN NULL
ELSE @EndLong END ,
CASE WHEN @EndEle = 0 THEN NULL
ELSE @EndEle END ,
@Direction ,
@Speed ,
@TrainType ,
CASE WHEN @Description ='null' THEN NULL
ELSE @Description END ,
@UID,
NULL,
'INSERT',
@InsertUser
set @output='Success'
--IF ((@COUNT >=1) AND (@COUNT =0))
--BEGIN
-- SET @output = 'ErrorLog'
--END
--IF (@COUNT = 0)
-- BEGIN
--SET @output ='Success'
--END
--END
END
END------------------------>
DeepaHi Deepa,
If I understand your question correctly, you would like the @Output parameter to contain the value "Success" only if all rows were successful. As soon as one row was found to be a duplicate, the value of @Output at the end of execution should be "ErrorLog".
Currently, you modify the value of @Output in each iteration of the cursor, so at the end of execution you're left with the last value.
In order to change that to work the way you want it, you need to set the value of @Output in the beginning of execution (before entering the cursor) to "Success", and as soon as there is a duplicate row, you should modify the value to "ErrorLog". This way,
if all rows are successful, the value of @Output will be "Success" at the end of execution. On the other hand, if there is even a single duplicate row, the value of @Output will be "ErrorLog" at the end of execution.
I hope this helps...
Guy Glantser
SQL Server Consultant & Instructor
Madeira - SQL Server Services
http://www.madeirasql.com -
SQL Server 2000 std Report Performance Issue
Dear All,
I have a VB based desktop application with back end MS SQL server 2000 database with server machine ibmx5650 with specs intel xeon 2.7GHz (24 CPU's) & 24GB RAM.
There are two things i need help:
Recently we have upgrade the SQL server from 2000 personal edition to the 2000 standard edition. There comes a problem with one of the Report in the application. The report took almost 30 mins previously in SQL 2000 personal edition.But after the upgrade
to Standard edition we are unable to view report before 3 hours even sometimes it doesn't appear after several hours.
Secondly for brief testing i have installed the personal edition on a simple PC rather then a server PC specs are corei5 & 4 GB of RAM. The same report is generated in only 15 mins from the application with this desktop machine as DB server.
Please help me out i have gone through all SQL Server & system performance log of my server machine everything is normal but the report is taking too long & i can only generate that report from personal edition.
Is there the difference due the higher corei5 processor in desktop machine or there is any other issue behind this.
Your prompt response is highly appreciated.
Regards,
Rashid AliHello,
SQL Server 2000 is not support since 2013. Please upgrade to SQL Server 2012 to get better performance and support.
Thanks for your understanding and support.
Regards,
Fanny Liu
Fanny Liu
TechNet Community Support
Maybe you are looking for
-
Can't connect to internet after upgrading to leopard
Can someone please HELP ME! I have a ibook g4 and I recently upgraded from tiger to Leopard. My wireless internet service worked fine until I upgraded. My computer still recognizes the network i'm trying to connect to but when I try to connect, it ei
-
I'm new to Adobe Reader, using Adobe reader 8, on Windows Vista. I have written a workbook that will be emailed to Life Coaching clients. They will read the questions and fill out the form prior to a conference call session for a group class session.
-
please help.
-
Re-installation of CS6 Design & Web Premium
Nouméa, 20/08/2014 In 2013 I have bought the CS6 Design & Web Premium Student version, in Australia I have installed it on both my desktop and old laptop. All the emails exchanged with Adobe at the time of purchase containing my licence details are o
-
Hi, I am trying to rollup the cube using process chain. Rollup was failed because of follwing error. "Rollup terminated: Data target SDFRTYH, from 0000211066 to 0000211174. Request SID must be smaller than or equal to 211172" Could you pls e