Recordset .value property - vb6

Please see the DDL below:
CREATE TABLE TestDate (bookingdate datetime)
INSERT INTO TestDate VALUES ('2013-10-04')
Please see the ADODB recordset below:
rs.open "SELECT bookingdate FROM TestDate"
If rs("bookingdate") > dateadd("yyyy", -6, Now)
msgbox("test")
end if
What is the difference between specifying rs("bookingdate") and rs("bookingdate").value. I have read some questions on here where answerers say always use .value, but it is not explained why. I had a look on MSDN but could not find an answer.

Value is the default property of the Field object, so in VB6 there is no difference between rs("bookingdate") and rs("bookingdate").value when used without Set.
I personally prefer not using default properties that don't take parameters. It makes the code less confusing IMO.
In VB.NET the default property must have a parameter, so this situation does not occur.
Note Recordset has such default property with parameter, and you are using it to return the Field object: rs("bookingdate") is actually rs.Item("bookingdate"). Using those, IMO, makes no harm.

Related

PreparedStatement - set param to DEFAULT (keyword)

Although this question seems to be close to this one, it is actually different.
Question
Is there any way to specify DEFAULT value as a parameter in JDBC's PreparedStatement?
Use-case
I'd like to have a single statement used for several inserts (or batch) into the table having some column defined as, say:
updated TIMESTAMP NOT NULL DEFAULT TIMESTAMP.
Now, assume that I got a non-uniform set of entries to insert, some of them DO have a value for that column while others DOESN'T (effectively relying on the DB to generate it).
Instead of 'divide and conquer' pattern (which obviously may become exponentially complex if there are more columns like this), I'm looking to run the same PreparedStatement in the single batch, while specifying DEFAULT value for all those entries that DOESN'T have the required values.
Well, seems that a statement of the #a_horse_with_no_name is straight forwardly to the point.
Gone over the PreparedStatement Java 9 docs again and found no hints to anything even close to this.
I'm missing a functionality to set parameters to a DB functions/keywords like DEFAULT, CURRENT_TIMESTAMP etc, but that's the state of PreparedStatement as of now.

Add map rule to predefined data style (refer to "value of this data item")

in our reporting the value of data elements will be rewrited with "-" in the case of Null.
Can I put this mapping rule to the predefined style of the "data" element ? I tried it, but I don't know who to implement the later reference to "The_current_row_value". Has anyone a idea?
Thanks a lot.
Instead of trying to use an edit tool in the report, use SQL's isnull() to convert null values to whatever value you desire.
ISNULL (Transact-SQL)
If for some reason that does not appeal to you, use a computed column in your BIRT data set, and define the value with Java Script.

BIRT Before Open value list params errors

I have a (semi) basic data cube set up with a cascading parameters of State and Area. The state select box is straight forward as is the Area; when a user selects a State, the Area options are set accordingly. However, the value for Area is a long list of strings that will be sent to the mysql select statement which will use both params (State & the list of strings from Area) several time. Its a big ugly collection of UNIONS. My problem is somewhere between the before Start and query time.
//beforeOpen script...LState & LAreas the name of the report param
this.queryText = this.queryText.replace('stateList', params["LStates"].value);
this.queryText = this.queryText.replace('areaList', params["LAreas"].value);
In my mysql statement I use them in the following way:
SELECT ..XXX..
FROM ..XXX..
WHERE ..XXX..
State.State_Location in ('stateList')
AND Range_Locator.Range in ('areaList')
UNION ALL
SELECT ..XXX..
FROM ..XXX..
WHERE ..XXX..
State.State_Location in ('stateList')
AND Range_Locator.Range in ('areaList')
The two errors I get from BIRT are:
(Pretty obvious)
Cannot get the result set. org.eclipse....SQL statement doesn ot return a ResultSet object.
(Not so obvious to me)
A BIRT exception occured. Error evaluating Javascript expression. Script engine error: Can't find method java.lang.String.replace(string.java.lang.Object[]).
There are error evaluating script "this.queryText = this.queryText.replace('stateList', params["LStates"].value);this.queryText = this.queryText.replace('areaList', params["LAreas"].value);"
Any ideas? Any help would be greatly appreciated.
It seems LStates is defined as a "multi-value" parameter, therefore params["LStates"].value returns an array of values: this is why this replace method does not work.
You should try like this:
this.queryText = this.queryText.replace('stateList', params["LStates"].value.join("','"));
I am not exactly sure what you are doing in beforeOpen script, but your SQL is looking for the string values 'stateList' & 'areaList' and is probably not happy about the (). You need to use question marks to call the parameters you define in the 'parameters' you set up in the data set design.
SELECT ..XXX..
FROM ..XXX..
WHERE ..XXX..
State.State_Location in ?
AND Range_Locator.Range in ?
UNION ALL
SELECT ..XXX..
FROM ..XXX..
WHERE ..XXX..
State.State_Location in ?
AND Range_Locator.Range in ?
I don't recall using
in ?
In any queries, I usually try and set it to use
like ?
There are number of issues in sending multiple choice parameters to SQL via BIRT. you might want to look at How do I set a parameter to a list of values in a BIRT report? There are also some security concerns. When I have to filter on multiples, I usually do it in a filter (data set design option) after the SQL has run. Thought this can be a resource problem if your SQL returns lots of values.
Thanks for the replies but since I was unable to get these options to work, I wound up restructuring the database & sql statements to run better. To address some previous suggestions:
#dom the states parameter has only one value and while using "IN ('stateList')" is not efficient (disclaimer, not my code) adding the .join(',') did throw an error specific to that; I tried and mysql/BIRT seemed to be expecting a comma separated list but got a string with a trailing comma.
#James I tried using the question mark (?) instead of the 'stateList' & 'areaList' but I think mysql/BIRT was not able to recognize which value went with which question mark...not too sure though since I was not able to debug well enough and find out exactly why. Could be a form to param mapping issue that I didn't notice. Thanks for the help.

Oracle: error while trying to use formulas

I created an element with an input value of type "Day" , when i write a formula i get this error.
Any idea what's wrong?
APP-FF-33232:
EATC_EXTRA_DAYS_ENTRY_EFFECTIVE_DATE_ENTRY_VALUE has null or not found allowed, but no
default set specified.
Cause: If a Database Item has
null allowed, or not found allowed,
then the item must also specify a
default set to be used to provide
default values in the event of these
occurring. The item named has one of
these conditions allowed, but the
default set column in the
FF_DATABASE_ITEMS table is null.
Action: Please refer to your
local support representative.
-
I'm not an expert in Oracle Apps (to say the least) but the error message is fairly clear. You - or someone - have written a Fast Formula which references a database column EATC_EXTRA_DAYS_ENTRY_EFFECTIVE_DATE_ENTRY_VALUE. Apparently this column can be nullable, in which case your Formula needs to provide a default value. Something like:
default for EATC_EXTRA_DAYS_ENTRY_EFFECTIVE_DATE_ENTRY_VALUE is 01-JAN-2010
Or perhaps you can use SYSDATE or CURRENT_DATE rather than a fixed value.
Solution to error: You called database item in Fast formula,
you need to initialize the date to specific date
alias EATC_EXTRA_DAYS_ENTRY_EFFECTIVE_DATE_ENTRY_VALUE as day
default for day is 01-jan-2010

When using Linq, is DbNull equivalent to Null?

This is not about DBNull vs Null. I understand the difference.
What I would like to know is if I am using Linq, say to access a User.EmailAddress, then checking User.EmailAddress == null is the same as User.EmailAddress == DBNull correct?
My reasoning is that the absence of data in the database results into Linq not generating an object reference, which then means that null is in fact equivalent to DBNull when used with Linq.
Is my reasoning correct or not?
You shouldn't use DBNull with LinqToSql. The point is Language Integration, and so one concept or name for null will suffice.
Here's the select statement that works in LINQ to SQL for Visual Basic. I assume it will be the same in C#.
User.EmailAdress.Equals(Nothing)
For example:
Dim EmptyEmailAddressEntries = From User in DC.Users _
Where User.EmailAddress.Equals(Nothing) select User
Will give you all the Users that have nothing in the email address. To check for entries with space " " characters only add
Or
User.EmailAddress = ""
In LINQ to SQL, you should be using null rather than DBNull. LINQ to SQL is an OR mapper, so it works with objects in a native way. The whole goal with L2S is to allow you to work with objects in a standard .NET way, and let L2S handle all the mapping between native and DB specific for you. You should avoid using DBNull in any L2S statements...in fact, I'm not even sure that is even a valid check (it'll probably cause some odd behavior if it works at all.)

Resources