Hi ,
I need to add default value column in SqlServer Compact....i am new to this SQL server compact so Plz anyone tell me the Solution of this....
Thanks In Advance
I just noted that my hibernate entities are automatically persisted to the database (or at least to cache) before I call any save() or update() method. To me this is a pretty strange default behavior but ok, as long as I can disable it, it´s fine.
The problem I have is I want to update my entity´s state (from 1 to 2) only if the entity in the database still has the state it had when I retrieved [1] (this is to eliminate concurrency issues when another server is updating this same object). For this reason I have created a custom NamedQuery that will only update the entity if state is 1. So here is some pseudo-code:
//Get the entity
Entity item = dao.getEntity();
item.getState(); //==1
//Update the entity
item.setState(2); //Here is the problem, this effectively changes the state of my entity braking my query that verifies that state is still == 1.
dao.customUpdate(item); //Returns 0 rows changes since state != 1.
So, how do I make sure the setters don´t change the state in cache/db?
Thanks,
Kristofer
Given the following example:
>> I=[2 1 3;3 2 4]
I =
2 1 3
3 2 4
>> I(:)
ans =
2
3
1
2
3
4
>> I(1:2)
ans =
2 3
Why does I(:) return a column vector while I(1:2) returns a shorter row vector?
I have a gridview and a column of that gridview is displaying images whose path is stored in a database & image is stored in locale folder inside my website. My problem is that I want to use the hyperlink control with the image, so that when the image is clicked it should jump to another page. How can I do that?
Hi All,
Could I get ideas on retrieving the dataset using lookup method. Basically, my scenario as I have source data needs to lookup for other source table and on matching column from source I need to get all the records from other source data.
its a one to many relations. I tried Lookup but gives only one record on matching condition, OLE DB command don't retrieve any data as it will do only Insert/Update operations.
Thanks
prav
Hi, I'm trying to write a query that returns the shortest string value in the column. For ex: if ColumnA has values ABCDE, ZXDR, ERC, the query should return "ERC". I've written the following query, but I'm wondering if there is any better way to do this?
BTW, the query should return a single value.
select distinct ColumnA from
(
select ColumnA, rank() over (order by length(ColumnA), ColumnA) len_rank from TableA where ColumnB = 'XXX'
)
where len_rank <= 1
Thank you.
We have some objects that have an associated workflow instance. The objects are identified with a GUID, which is also the GUID of the workflow instance associated with the object. We need to restart (see NOTE 3 for the meaning of 'restart') the workflow instance if the workflow definition changed (there is no state in the workflow itself and it is written to support restarting in this manner).
The restarting is performed by calling Terminate on the WorkflowInstance, then recreating the instance with the same GUID. The weird part is that this works every other attempt (odd attempts - the workflow is stopped, but for some reason doesn't restart, even attempt - the already terminated workflow is recreated and started successfully).
While I admit that using 'second hand' GUIDs is a sign of extraordinary cheapness (and something we plan to change), I'm wondering why this isn't working. Any ideas?
NOTES:
The terminated workflow instance is passivated (waiting for a notification) at the time of the termination.
The Terminate call successfully deletes the data persisted in the database for that instance.
We're using 'restarting' with a meaning that's less common in the context of WF - not restarting a passivated instance, but force the workflow to start again from the beginning of its definition.
Thanks!
Hi
I am using two different databases for my project.
Oracle and apache derby and trying to use as much as possible ansi sql syntax supported by both of the databases.
I have a table with column amount_paid NUMERIC(26,2), in a table.
My old code which was using oracle db need to retrieve value in this format
SELECT LTRIM(TO_CHAR(amount_paid,'9,999,999,999,999.99')) .
How can i do this using ANSI sql syntax.
SELECT TotalItems.Total_Items
,TotalItems.No_Items_Present
,ItemsTable.No_Of_Items_Ret
FROM TotalItems
INNER JOIN ItemsTable ON
ItemsTable.Item_Name= '" + DropItemName.SelectedValue + "'"
this is my SQL query what I want is to retrieve two column values corresponding to the item I enter in my dropdown list from one table and the no_of_items_ret from another table satisfying the condition of the dropdownlist
I'm getting all the values corresponding to any item I enter what should i do?
Hi,
I try to use the SQL statement
SELECT * FROM table ORDER BY column
via an PDO-Object in PHP. Problem is, that I always get an error (Call to a member function fetchall() on a non-object - that means, the query did not return a PDO-object) when using the names of all columnname EXCEPT for ID. When I query
SELECT * FROM table ORDER BY ID
it works. ID is the PRIMARY INTEGER KEY, all other columns are TEXT or NUMERIC, neither of them would works with the ORDER BY clause.
Any ideas?
Hi,
I've got tqo queries:
First doesn't work:
select hotels.TargetCode as TargetCode from hotels
union all
select DuplicatedObjects.duplicatetargetCode as TargetCode from DuplicatedObjects where DuplicatedObjects.objectType=4
because I get error:
Cannot resolve collation conflict for column 1 in SELECT statement.
Second works:
select hotels.Code from hotels where hotels.targetcode is not null
union all
select DuplicatedObjects.duplicatetargetCode as Code from DuplicatedObjects where DuplicatedObjects.objectType=4
Structure:
Hotels.Code -PK nvarchar(40)
Hotels.TargetCode - nvarchar(100)
DuplicatedObjects.duplicatetargetCode PK nvarchar(100)
In a file 4th column contains a floating point numbers
dsfsd sdfsd sdfds 4.5 dfsdfsd
I want to delete the entire line if the number between -0.1 and 0.1 (or some other range).
Can sed or awk do that for me?
thanks
hello i am having two entities...
Exam and Exam_Normal
EXAM
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
private String name;
private String codeName;
@Enumerated(EnumType.STRING)
private ExamType examType;
@ManyToOne
private Category category;
@OneToMany(mappedBy="id",cascade=CascadeType.PERSIST)
@OrderBy("id")
private List<Exam_Normal> exam_Normal;
EXAM_NORMAL
@Id
private Long item;
@Id
@ManyToOne
private Exam id;
@Enumerated(EnumType.STRING)
private Gender gender;
private Integer age_month_from;
private Integer age_month_to;
The problem is that if i put a list of EXAM_NORMAL at an EXAM class if i try to persist(EXAM) i get an error because it tries to persist EXAM_NORMAL first but it cant because the primary keyof EXAM is missing because it isnt persisted...
Is there any way to define the order?Or i should set null the list ,persist and then set the list again ?
thanks:)
I have a column DECIMAL(9,6) i.e. it supports values like 999,123456.
But when I insert data like 123,4567 it becomes 123,456700
How to remove those zeros?
How can I get the set difference of two result sets?
Say I have a result set (just one column in each):
result1:
'a'
'b'
'c'
result2:
'b'
'c'
I want to minus what is in result1 by result2: result1 - result2 such that it equals:
difference of result1 - result2:
'a'
I want to use the JPA EntityListener to support spring security ACLs.
On @PostPersist events, I create a permission corresponding to the persisted entity.
I need this operation to participate to the current Transaction.
For this to happen I need to have a reference to the application TransactionManager in the EntityListener.
The problem is, Spring can't manage the EntityListener as it is created automatically when EntityManagerFactory is instantiated.
And in a classic Spring app, the EntityManagerFactory is itself created during the TransactioManager instantiation.
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
So I have no way to inject the TransactionManager with the constructor, as it is not yet instantiated.
Making the EntityManager a @Component create another instance of the EntityManager.
Implementing InitiliazingBean and using afterPropertySet() doesn't work as it's not a Spring managed bean.
Any idea would be helpful as I'm stuck and out of ideas.
Hi, my app presents a listview, from a database cursor and XML, that needs to replace the values in a column with various words based on the integer value contained in the cursor. For example, if the value is -1, replace it with the word "Invalid", but if the value is = 0 then just display the value.
I was under the impression this could magically be done via XML... TIA.
I have a list of installed software, obtained from WMI class select * from Win32_Product.
I'd like to deny execution rights for some users on certain software like so:
find the path to installed software
recursively remove execution rights
I find the path to installed software from Win32_Product InstallLocation column. But the PROBLEM is that not all rows in Win32_Product have a value for InstallLocation. What can I do to overcome this? Is there somewhere in registry where I can find this path?
i need to implement the following query in SQL Server
select *
from table1
WHERE (CM_PLAN_ID,Individual_ID)
IN
(
Select CM_PLAN_ID, Individual_ID
From CRM_VCM_CURRENT_LEAD_STATUS
Where Lead_Key = :_Lead_Key
)
but the WHERE..IN clause allows only 1 column. How to compare 2 or more columns with another inner select?
I have a simple User model whose fields are annotated with play validation annotations and morphia annotations like below.
import play.data.validation.*;
import play.modules.morphia.Model;
import com.google.code.morphia.annotations.*;
@Entity
public class User extends Model{
@Id
@Indexed(name="USERID", unique=true)
public ObjectId userId;
@Required public String userName;
@Email
@Indexed(name="USEREMAIL", unique=true)
@Required public String userEmail;
}
Now I have a service which has a CreateNewUser method responsible for persisting the data. I have used Morphia plugin for the dao support. But the problem is that User Document gets persisted in mongo-db even if userName or userEmail is NULL. Also @Email validation does not happen
// Below code is in app/controllers/Application.java
User a = new User();
a.userName = "user1";
// calling bean to create user, userService is in app/service/UserService
userService.createNewUser(a);
It does not work even after adding @valid and validation.hasErrors() check.Below code is in app/service/UserService
public void createNewUser(@Valid User user) {
if (Validation.hasErrors()) {
System.out.println("has errors");
} else {
// TODO Auto-generated method stub
userDao.save(user);
}
}
Hi,
Might be this question a blunder :(...
I have a a button in silverlight application...
<Button Height="25" Width="100" Grid.Column="0" Grid.Row="0" Click="Button_Click"/>
I read that silverlight need WCF to interact with server side... So is it like to access my "Button_Click" event I need WCF ?
Hi friends,
While updating a datatime column in a table from another table, i noticed that mnilliseconds value are not shown.. instead it is rounded and the value is updated to nearest seconds.
Example :
Original Value: 2008-06-26 14:06:36.643
Updated Value : 2008-06-26 14:07:00
Please help me getting the actual value including milliseconds