Recordset from count of records (field in Access DB)
I'm creating an application with DW CS3 using ASP VBscript
and an Access database. Users will be able to register to attend a
session on one of a number of dates. Upon submitting a form, their
contact info and choice of date will be input into an Access table
called registrants. The field 'regDate' within the table
'registrants' will contain the dates that each user selected.
I want to be able to close registrations when 85 people have
selected a date. I thought I would do that by creating a recordset
in DW that only displayed dates with less than 86 registrants so
that people cannot select a date that has been filled. A DW form
inputs into the 'registrants' table as a field of each registrant's
record; but I don't have a table in Access that displays the number
of people who registered for each date and can't quite figure out
the best way to get that number and utilize it in DW. I want to
utilize that count by creating a recordset that will include only
dates that have less than 86 registrants.
I created a query in MS Access that displays each of the
registration dates and the number of people who selected that date.
I don't know the best way to transfer that and use it in DW.
Following is the Access query that gives me the number of
registrants per date. Can the SQL be modified to work in a
recordset within DW? It doesn't work to paste it directly because I
guess it's a different kind of SQL language.
SELECT registrants.regDate, Count(registrants.regDate) AS
CountOfregDate INTO Registrations
FROM registrants
GROUP BY registrants.regDate;
That would be a MS Access question. Try their forums. I take it u want to set it dynamically within JAVA. Otherwise to set the description in Access DB; right click on table and design view :D But I know thats not what ur after.
Similar Messages
-
Refresh page with data from the Next Record in the Table through a Button
Scenario: Record of a table “prototype” is made up of 8 columns,
key_col,
text_col,
label1_col, label2_col, label3_col,
check1_col, check2_col, check3_col,
I have created the following items on a page:
a) A Display Only item that is populated through a SQL query
“SELECT text_col from prototype where rownum=key_seq.NEXTVAL “.
b) Hidden item for the database columns “label1_col, label2_col, label3_col”
Source type for the hidden items is of type SQL query, Source expression is:
Select label1_col from prototype where rownum=key_seq.NEXTVAL ;
Select label2_col from prototype where rownum=key_seq.NEXTVAL ;
Select label3_col from prototype where rownum=key_seq.NEXTVAL ;
(key_seq is a sequence).
c) Checkbox item for the database columns “ check1_col, check2_col,check3_col"
d) The labels for the above checkbox items are &label1_col. , &label2_col. , &label3_col.
I have created a Save button to save the state of the checkboxes; (STATIC:;1 )
I want the page to be refreshed with the data from the next record (Fields text_col, label1_col, label2_col, label3_col) through a “ Next” Button.
Can I please know how I can achieve this?
Thanks in advanceIf you need the value that is entered in the textbox as the email body, then try this..
<html>
<HEAD>
<title>WebForm1</title>
<script language="javascript">
function mailHTML() {
var content=document.getElementById('textBox').value;
location.href="mailto:?body="+encodeURI(content);
</script>
</head>
<body>
<form name="theform" id="theform">
<div name="body1"/>
<input type="text" value="Test" id="textBox"/>
<input type="button" value="Send Email" onClick="mailHTML()"/>
</div>
</form>
</body>
</html> -
To get the count of records and able to access the column value in a single
Hi
Is there any way to get the number of records in the query and access the column values
e.g
select count(*)
from
(SELECT department, COUNT(*) as "Number of employees"
FROM employees
WHERE salary > 25000
GROUP BY department ) a
This wil only get the Count, if i want to access each row from the inline view how can i do that.Your question is not clear.
Are you looking for total record count as well as count by department ?
Something like this?
SQL>
SQL> with temp as
2 (
3 select 1 dept ,10000 sal from dual union
4 select 1 dept ,25100 sal from dual union
5 select 1 dept ,30000 sal from dual union
6 select 1 dept ,40000 sal from dual union
7 select 2 dept ,10000 sal from dual union
8 select 2 dept ,25100 sal from dual union
9 select 2 dept ,30000 sal from dual union
10 select 2 dept ,40000 sal from dual )
11 select count(*) over( partition by 1 ) total_count,dept,
12 count(*) over(partition by dept) dept_cnt from temp
13 where sal>25000;
TOTAL_COUNT DEPT DEPT_CNT
6 1 3
6 1 3
6 1 3
6 2 3
6 2 3
6 2 3
6 rows selected
SQL> -
Deleting database records/recordsets from LabVIEW
I would like to manage database information with LabVIEW. Any guidance or sample VIs on deleting records or recordsets from data displayed in a listbox in LabVIEW?
Ok, if the database you're talking to was designed correctly the table you're reading data from should have a "primary key value" this is a field containing a unique identifier. Primary keys are typically integers because integers are faster to search and index--but they don't have to be.
When you are performing your select statement to retrieve the data, be sure to also read the primary key. Keep this column of data in an array that you can refer to.
Now, when your user selects one or more items to delete, the code looks up the primary keys for those items and formats an SQL delete statement to delete just those records.
If the data you are reading comes from several tables using a "join", the problem gets a little more difficult, but
the same basic technique should work, the SQL will just be more complex.
The worse case situation is if you are getting your data from what is called a "view". If that is the case, you will need to spend sometime with someone in your MIS department and workout exactly how to do the delete.
Mike...
Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion
"... after all, He's not a tame lion..."
Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps -
Getting a field from a derived record
I have been asked to put a value on a page that seems to be part of a PS-supplied derived record in Campus Solutions, derived_cs. My understanding is that derived records are built on the fly. I can see in App Designer what table is used for a prompt for the field I care about but since the field is part of a derived record, I don't see anything in the PeopleCode for the field for where its value gets written to. How do I figure out where the values entered on a page in fields of a derived record go? I need to get the real value. I don't want to try to reconstruct the derived record in my custom app. Thanks.
KenDerived/work records allow you to display the values of variables on pages. As you noted, they don't have database compliments. In other words, Derived/Work record field values are not persisted. This makes it difficult to determine where the values come from and, if they are data entry fields, where the values go. The movement of the data to and from a Derived/Work record is all done in PeopleCode. To find where the values come from, I usually start with an SQL trace level of 7. You can also use an SQL trace to determine where the values go. The nice thing about Derived/Work values that are persisted is that you will see values in the SQL insert bind variables. Unfortunately, when reading data from the database, you only see bind variables, you don't see the values that were selected. This makes finding where data comes from very difficult.
-
How to get count of records for each type from internal table
Hi Guys,
I want to implement a logic to find out the count of records in a internal table.
Assume my internal table have one field having the entries as shown below.
Internal table Entries
10
10
10
11
11
12
12
12
12
13
14
14
15
15
15
15
15
16
16
17
18
19
20
20
20
....... etc....
I should get an output as below
10's - 3
11's -2 ,
12's - 4.... etc..
Could any one help me how to do this.
Thanx,
KumarREPORT zzz.
DATA: i(100),
t(100),
j TYPE n.
TYPES: BEGIN OF gt_int_type,
linex(100) TYPE c,
END OF gt_int_type.
DATA: gt_int TYPE STANDARD TABLE OF gt_int_type,
wa_int LIKE LINE OF gt_int.
START-OF-SELECTION.
wa_int-linex = '10'.
APPEND wa_int TO gt_int.
wa_int-linex = '10'.
APPEND wa_int TO gt_int.
wa_int-linex = '10'.
APPEND wa_int TO gt_int.
wa_int-linex = '11'.
APPEND wa_int TO gt_int.
wa_int-linex = '11'.
APPEND wa_int TO gt_int.
wa_int-linex = '12'.
APPEND wa_int TO gt_int.
wa_int-linex = '12'.
APPEND wa_int TO gt_int.
wa_int-linex = '12'.
APPEND wa_int TO gt_int.
wa_int-linex = '12'.
APPEND wa_int TO gt_int.
wa_int-linex = '13'.
APPEND wa_int TO gt_int.
wa_int-linex = '14'.
APPEND wa_int TO gt_int.
wa_int-linex = '14'.
APPEND wa_int TO gt_int.
wa_int-linex = '15'.
APPEND wa_int TO gt_int.
wa_int-linex = '15'.
APPEND wa_int TO gt_int.
wa_int-linex = '15'.
APPEND wa_int TO gt_int.
wa_int-linex = '15'.
APPEND wa_int TO gt_int.
wa_int-linex = '15'.
APPEND wa_int TO gt_int.
wa_int-linex = '16'.
APPEND wa_int TO gt_int.
wa_int-linex = '16'.
APPEND wa_int TO gt_int.
wa_int-linex = '17'.
APPEND wa_int TO gt_int.
wa_int-linex = '18'.
APPEND wa_int TO gt_int.
wa_int-linex = '19'.
APPEND wa_int TO gt_int.
wa_int-linex = '20'.
APPEND wa_int TO gt_int.
wa_int-linex = '20'.
APPEND wa_int TO gt_int.
wa_int-linex = '20'.
APPEND wa_int TO gt_int.
LOOP AT gt_int INTO wa_int.
WRITE:/ wa_int-linex.
ENDLOOP.
ULINE.
SKIP 3.
SORT gt_int BY linex.
READ TABLE gt_int INDEX 1 INTO i.
j = 0.
LOOP AT gt_int INTO wa_int.
IF wa_int-linex EQ i.
j = j + 1.
ELSE.
WRITE:/ i,'''s = ', j.
j = 1.
i = wa_int-linex.
ENDIF.
ENDLOOP.
WRITE:/ i,'''s = ', j.
consider clearing leading/trainling spaces... -
Use field from file header record in detail records
Hi,
I receive a file with different records type (transmission header, file header, detail records, file footer). The fields in each record type are different. The transmission header tells me who the sender of the file is. I need this information, because I am merging data of various senders into one table.
When processing the files, I need to split each file according to recordtype. (I can not use the same logic for each recordtype). How can I populate an extra column in the detail files with the value from the header record?
What I tried so far is the following:
- Populate a global variable using a script: This does not seem to work in the context of dataflows.
- Create a 'join' between header record and detail record. However there are no fields I can join, so Data Services is not happy with that.
- Store the field value from the header record in a DS (I chose a cache datastore, memory datastore did not work in batch scenario. I feel I can get this to work, but it seems quite an elaborate and expensive solution: First Filter the header record from the file, write the required field to the cache datastore, then read the same file but now filter the detail records, and join this with the datastore.
Is there a better way to do this? I was hoping I could just use a script and read the first line of my file and move the value to a global variable....
It would be great if someone could give me some tips...
Many thanks,
Jan.Hi Werner,
I am not sure if I understand you correctly.
I have declared $State as a global variable, not as a parameter.
When I check my custom function I do get a warning that a variable is called which is not declared.
I thought I did not have to worry about this as the variable does exist within the job where the function is called.
It looks like I can not set a value to a global variable in a custom function.
Is that correct, or is there something wrong with my syntax?
Really the only reason I call a custom function is to set the global variable, so I could even make my function as simple as this:
$State = 'NSW';
Return 0;
It still doesn't work...
Any idea why?
Thanks,
Jan. -
Word 2007 VBA - Can't Move around in a Recordset - From a Beginner
[reposted from the VB.net forum where I mistakenly posted it]
Hi,
This is a simple program. The issue is that Recordset.MoveNext and .MovePrevious aren't working, though .MoveFirst and MoveLast are. If I exchange MoveLast for MoveNext and MovePrevious to MoveNext, the output will be 8 repetitions of the last record
as compared to the first. Counter will be 0 for each output starting with MoveFirst and 7 starting with MoveLast (which is interesting since I read that the AbsolutePosition property is supposed to be 1-based). Any help will be appreciated! The
recordset is default (table-based) but this issue remained when I changed it to a dynaset recordset.
Following is the code:
Private Sub CmbOffices_Click()
Call WordEx 'opens a Word doc and sets database objects
Dim Counter As Long
Dim intComboItem As Integer
Set objSelection = objWord.Selection
objSelection.TypeText ("STUFF") & vbCrLf
For intComboItem = 0 To CmbOffices.ListCount - 1
recordset.MoveFirst
Counter = recordset.AbsolutePosition
objSelection.TypeText field.Value & field2.Value & field3.Value & Counter &
vbCrLf
'Else
recordset.MoveNext
'End If
Next
recordset.Close
db.Close
End Sub
ChiroacumanHi Gill,
Thanks for helping me with this. I forgot to mention that I have spent a lot of time on the net and here trying to find a solution. Here is the code where I defined variables:
[General Declarations in a classic Module]
Public db As DAO.Database
Public recordset As DAO.recordset
Public field As DAO.field
Public field2 As DAO.field
Public field3 As DAO.field
Public Sub WordEx()
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add
Set db = CurrentDb
Set recordset = db.OpenRecordset("Headers", dbOpenDynaset)
Set field = recordset.Fields(0)
Set field2 = recordset.Fields(1)
Set field3 = recordset.Fields(2)
objWord.Visible = True
End Sub
Chiroacuman -
How to find count of records based on batch wise.
Hi All,
We are working on OWB10gr2. I would like share one requirement. Any one can suggest me how to do it and which is the best way to get accurate information.
We have 2 schemas’ like nia_src and nia_tgt. currently we are moving data from nia_src to nia_tgt for that reason we implemented some mappings based on requirement. In my source schema (nia_src) having 100 tables with data and similar structure replicated in target schema (nia_tgt).
In source schema every table having one date field for which record is inserted and based on that field we can find how may records are inserted on particular table ,particular time.
Same like target also maintaining date fields for tracking purposes.
We have done some mappings and scheduled also. Every day we are into the target with incremental data. All are working fine not any issues.
I wanted to know how many records inserted, updated, merged for particular batch
How can we find?
Can we find exact information in OWB_REP_OWNER schema on WB_RT_AUDIT?.
For tracking purposes I need to find those values how many records are available in
Source table and how many records are populated to the target schema?
How to find schedule batch count of records table wise for batch wise?
Please suggest me any one on this.
thanks and regards,
venkat.RE: based on pre operator can we find count of records. if yes how to do it.
No, you cannot tell from the pre- operator how many records will be inserted or updated into a mapping. How could you? The mapping hasn't run yet!
At best (if you have simple mappings with single targets) you could come up with a strategy to have the pre-mapping procedure aware of it's package name, then select from user_source for that package body until you find that first cursor used for the row-based processing, copy the cursor into a local variable, and then execute immediate select count(*) from that cursor definition. But still, all that would get you is the number of rows selected - not inserted / updated / errored etc.
A post-mapping procedure that is aware of the package name will, however, run prior to package exit so that the package spec is still in memory so you can access the public variables in the package spec. We do that in our standard post-mapping procedure
CREATE OR REPLACE procedure erscntrl_finalize_prc(
p_process_id in number,
p_process_name in varchar2)
as
l_numread number := 0;
l_numInserted number := 0;
l_numUpdated number := 0;
l_numMerged number := 0;
l_owb_audit_id number := 0;
l_owb_status number := 0;
sqlStmt varchar2(2000) :=
'begin '||
' :1 := '||p_process_name||'.get_selected; '||
' :2 := '||p_process_name||'.get_inserted; '||
' :3 := '||p_process_name||'.get_updated; '||
' :4 := '||p_process_name||'.get_merged; '||
' :5 := '||p_process_name||'.get_audit_id; '||
' :6 := '||p_process_name||'.get_status; '||
' end;';
begin
-- we use dynamic SQL to return required audit field values.
-- This allows us to alter which values we need at a later date
-- without impacting the deployed mappings.
execute immediate sqlStmt
using out l_numread, out l_numInserted, out l_numUpdated,
out l_numMerged, out l_owb_audit_id, out l_owb_status;
-- then execute our own logging package.
owb_mapping_log_pkg.finalize(
p_process_id,
p_process_name,
l_numread,
l_numInserted,
l_numUpdated,
l_numMerged,
l_owb_audit_id,
l_owb_status
end;
/However, even in this case bear in mind that if you run the mapping in set-base mode, all Oracle returns is the number merged which does not give values for the inserted and updated counts. If you really need those values you need to either a) run in row-based mode or row-based-target-only, or come up with some custom queries. For example, in your pre-mapping do a select count(*) from your_target_table, then run the mapping, then get the number merged, then do another select count(*) from your_target_table. With these values and basic math you could tell the number inserted by the growth in the table, and the rest of the number merged must have been updates.
That being said, if you are playing with dimensions as large as most of the ones I am - there is no bloody way that you want to do two select count(*) statements on each run without a really, really good reason.....
Cheers,
Mike -
How can I get a count of records in a DB?
If I want to get a count of the number of records in a table how do I do it?
Generally, it's good practice to close the connection once you're done with it unless you have a reason to keep going back to it, in which case it probably becomes a performance issue. If you need to keep accessing the same connection repeatedly while your form is running (in Acrobat), I think you would be best to leave it open after initialization.<br /><br />You might consider placing the code which counts the records into a function inside a Script Object. This way, you can just call the Script Object method and retrieve the record count whenever you need it.<br /><br />Make sure you define the <b>oDB</b> variable outside the function but inside the Script Object:<br /><pre>var oDB = null;<br /><br />function GetRecordCount()<br />{<br /> if (oDB == null)<br /> {<br /> var sDataConnectionName = "<value>"; // example - var sDataConnectionName = "MyDataConnection"; <br /><br /> // Search for sourceSet node which matchs the DataConnection name <br /> var nIndex = 0; <br /> while(xfa.sourceSet.nodes.item(nIndex).name != sDataConnectionName) <br /> { <br /> nIndex++; <br /> } <br /><br /> var oDB = xfa.sourceSet.nodes.item(nIndex); <br /> oDB.open();<br /> }<br /><br /> oDB.first(); <br /><br /> // Search node with the class name "command" <br /> var nDBIndex = 0; <br /> while(oDB.nodes.item(nDBIndex).className != "command") <br /> { <br /> nDBIndex++; <br /> } <br /><br /> // Backup the original settings before assigning BOF and EOF to stay <br /> var sBOFBackup = oDB.nodes.item(nDBIndex).query.recordSet.getAttribute("bofAction"); <br /> var sEOFBackup = oDB.nodes.item(nDBIndex).query.recordSet.getAttribute("eofAction"); <br /><br /> oDB.nodes.item(nDBIndex).query.recordSet.setAttribute("stayBOF", "bofAction"); <br /> oDB.nodes.item(nDBIndex).query.recordSet.setAttribute("stayEOF", "eofAction"); <br /><br /> var itemCount = 0; <br /><br /> while(!oDB.isEOF()) <br /> { <br /> itemCount++; <br /> oDB.next(); <br /> } <br /><br /> // Restore the original settings <br /> oDB.nodes.item(nDBIndex).query.recordSet.setAttribute(sBOFBackup, "bofAction"); <br /> oDB.nodes.item(nDBIndex).query.recordSet.setAttribute(sEOFBackup, "eofAction"); <br /><br /> return itemCount;<br />}</pre><br />You can create a script object by right-clicking on the top-level form node ("form1" by default). Say you name your script object "Utils", you can then call the function inside of it from any event script like this:<br /><pre>this.rawValue = Utils.GetRecordCount();</pre><br />Stefan<br />Adobe Systems
-
Output count of SELECT statement is diff from count(*) of the same query
Has this ever happened to you?
I was wondering why some of the items were not appearing in my output. I have this select query:
SELECT
bukrs
gjahr
hkont
belnr
wrbtr
dmbtr
matnr
bschl
kunnr
vbeln
shkzg
FROM bseg
INTO CORRESPONDING FIELDS OF TABLE i_output
FOR ALL ENTRIES IN i_bkpf
WHERE
bukrs EQ i_bkpf-bukrs
AND belnr EQ i_bkpf-belnr
AND gjahr EQ i_bkpf-gjahr
AND hkont IN hkont
AND hkont IN
('0004000000',
'0004000010',
'0004000020',
'0004000030',
'0004000040')
When I tried to put sample filters (bukrs: 1000; belnr 1800000016; gjahr: 2005; hkont: 4000000), I am getting 3 entries from bseg. But when I tried using SE16 or SE16N, I am getting 6 (which is the expected output). When I modify the same SELECT query to return just the output count, I AM getting 6.
SELECT count(*)
FROM bseg
INTO count
FOR ALL ENTRIES IN i_bkpf
WHERE
bukrs EQ i_bkpf-bukrs
AND belnr EQ i_bkpf-belnr
AND gjahr EQ i_bkpf-gjahr
AND hkont IN hkont
AND hkont IN
('0004000000',
'0004000010',
'0004000020',
'0004000030',
'0004000040')
Do you have any idea why this happens? My internal table is a standard table with no header line and no OCCURS statement.
KyleHello Kyle,
Thats because when using FOR ALL ENTRIES, it will delete the duplicates if the records selected dont have all the primary keys specified in the select query. In your first select query, the field BUZEI is missing which makes the records unique. Change your first select query as this and try
SELECT
bukrs
gjahr
hkont
belnr
buzei -------> Add this and check
wrbtr
dmbtr
matnr
bschl
kunnr
vbeln
shkzg
FROM bseg
INTO CORRESPONDING FIELDS OF TABLE i_output
FOR ALL ENTRIES IN i_bkpf
WHERE
bukrs EQ i_bkpf-bukrs
AND belnr EQ i_bkpf-belnr
AND gjahr EQ i_bkpf-gjahr
AND hkont IN hkont
AND hkont IN
('0004000000',
'0004000010',
'0004000020',
'0004000030',
'0004000040')
Vikranth -
Random record selection in Access
I need to define a record set in ASP / Access consisting of a
single record from the available records.
In PHP / MySQL I have used the following and it works fine:
SELECT *
FROM photolist
ORDER BY RAND()
LIMIT 1
Can anyone give me a suitable recordset definition to do this
in access?"whatalotofrubbish" <[email protected]>
wrote in message
news:gmk6pe$90k$[email protected]..
>I need to define a record set in ASP / Access consisting
of a single record
> from the available records.
> In PHP / MySQL I have used the following and it works
fine:
>
> SELECT *
> FROM photolist
> ORDER BY RAND()
> LIMIT 1
>
> Can anyone give me a suitable recordset definition to do
this in access?
>
Access won't do a "random" command when queried from a web
page, although it
can if done so within the actual Access application. ASP
pages can certainly
utilize mySQL databases; why not use mySQL as it would be far
more robust
and stable than Access would be. If you can't move to mySQL,
try this
extension from DMXzone:
http://www.dmxzone.com/go?3705 -
Reading a record by key access.
Hi Gurus,
In 'read table' for reading a record by key access they have used 'comparing' , 'transporting' , 'assigning'.
Can you please explain me what exactly the above will happen with an clear example.
Thanks,
Prabu S.mostly you wont need these
but still: from documentation:
READ TABLE - transport_options
Syntax
... [COMPARING { {comp1 comp2 ...}|{ALL FIELDS}|{NO FIELDS} }]
[TRANSPORTING { {comp1 comp2 ...}|{ALL FIELDS} }] ... .
Effect:
The addition COMPARING compares the specified components comp1 comp2 ... (or the subareas or attributes thereof) in a found
line before they are transported with the corresponding components of the work area. If ALL FIELDS is specified, all components
are compared. If no NO FIELDS is specified, no components are compared. If the content of the compared components is
identical, sy-subrc is set to 0. Otherwise it is set to 2. The found line is assigned to the work area independently of the result of
the comparison.
If the addition TRANSPORTING is specified, only the specified components comp1 comp2 ... (and their subareas) in the found line
are assigned to the corresponding components of the work area (or their subareas). If ALL FIELDS is specified, all the
components are assigned.
COMPARING must be specified before TRANSPORTING. The components comp1 comp2 ... are specified according to the rules in
the section Specifying Components. This is subject to the restriction that after TRANSPORTING, attributes of classes cannot be
addressed using the object component selector, and after COMPARING, this is only possible as of release 6.10. -
Insert multiple rows into a same table from a single record
Hi All,
I need to insert multiple rows into a same table from a single record. Here is what I am trying to do and I need your expertise. I am using Oracle 11g
DataFile
1,"1001,2001,3001,4001"
2,"1002,2002,3002,4002"
The data needs to be loaded as
Field1 Field2
1 1001
1 2001
1 3001
1 4001
2 1002
2 2002
2 3002
2 4002
ThanksYou could use SQL*Loader to load the data into a staging table with a varray column, then use a SQL insert statement to distribute it to the destination table, as demonstrated below.
SCOTT@orcl> host type test.dat
1,"1001,2001,3001,4001"
2,"1002,2002,3002,4002"
SCOTT@orcl> host type test.ctl
load data
infile test.dat
into table staging
fields terminated by ','
( field1
, numbers varray enclosed by '"' and '"' (x))
SCOTT@orcl> create table staging
2 (field1 number,
3 numbers sys.odcinumberlist)
4 /
Table created.
SCOTT@orcl> host sqlldr scott/tiger control=test.ctl log=test.log
SQL*Loader: Release 11.2.0.1.0 - Production on Wed Dec 18 21:48:09 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Commit point reached - logical record count 2
SCOTT@orcl> column numbers format a60
SCOTT@orcl> select * from staging
2 /
FIELD1 NUMBERS
1 ODCINUMBERLIST(1001, 2001, 3001, 4001)
2 ODCINUMBERLIST(1002, 2002, 3002, 4002)
2 rows selected.
SCOTT@orcl> create table destination
2 (field1 number,
3 field2 number)
4 /
Table created.
SCOTT@orcl> insert into destination
2 select s.field1, t.column_value
3 from staging s, table (s.numbers) t
4 /
8 rows created.
SCOTT@orcl> select * from destination
2 /
FIELD1 FIELD2
1 1001
1 2001
1 3001
1 4001
2 1002
2 2002
2 3002
2 4002
8 rows selected. -
How to get an updatable ADODB Recordset from a Stored Procedure?
In VB6 I have this code to get a disconnected ADODB Recordset from a Oracle 9i database (the Oracle Client is 10g):
Dim conSQL As ADODB.Connection
Dim comSQL As ADODB.Command
Dim recSQL As ADODB.Recordset
Set conSQL = New ADODB.Connection
With conSQL
.ConnectionString = "Provider=OraOLEDB.Oracle;Password=<pwd>;Persist Security Info=True;User ID=<uid>;Data Source=<dsn>"
.CursorLocation = adUseClientBatch
.Open
End With
Set comSQL = New ADODB.Command
With comSQL
.ActiveConnection = conSQL
.CommandType = adCmdStoredProc
.CommandText = "P_PARAM.GETALLPARAM"
.Properties("PLSQLRSet").Value = True
End With
Set recSQL = New ADODB.Recordset
With recSQL
Set .Source = comSQL
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockBatchOptimistic
.Open
.ActiveConnection = Nothing
End With
The PL/SQL Procedure is returning a REF CURSOR like this:
PROCEDURE GetAllParam(op_PARAMRecCur IN OUT P_PARAM.PARAMRecCur)
IS
BEGIN
OPEN op_PARAMRecCur FOR
SELECT *
FROM PARAM
ORDER BY ANNPARAM DESC;
END GetAllParam;
When I try to update some values in the ADODB Recordset (still disconnected), I get the following error:
Err.Description: Multiple-step operation generated errors. Check each status value.
Err.Number: -2147217887 (80040E21)
Err.Source: Microsoft Cursor Engine
The following properties on the Command object doesn't change anything:
.Properties("IRowsetChange") = True
.Properties("Updatability") = 7
How can I get an updatable ADODB Recordset from a Stored Procedure?4 years later...
I was having then same problem.
Finally, I've found how to "touch" the requierd bits.
Obviously, it's hardcore, but since some stupid at microsoft cannot understand the use of a disconnected recordset in the real world, there is no other choice.
Reference: http://download.microsoft.com/downlo...MS-ADTG%5D.pdf
http://msdn.microsoft.com/en-us/library/cc221950.aspx
http://www.xtremevbtalk.com/showthread.php?t=165799
Solution (VB6):
<pre>
Dim Rst As Recordset
Rst.Open "select 1 as C1, '5CHARS' as C5, sysdate as C6, NVL(null,15) as C7, null as C8 from DUAL", yourconnection, adOpenKeyset, adLockBatchOptimistic
Set Rst.ActiveConnection = Nothing
Dim S As New ADODB.Stream
Rst.Save S, adPersistADTG
Rst.Close
Set Rst = Nothing
With S
'Debug.Print .Size
Dim Bytes() As Byte
Dim WordVal As Integer
Dim LongVal As Long
Bytes = .Read(2)
If Bytes(0) <> 1 Then Err.Raise 5, , "ADTG byte 0, se esperaba: 1 (header)"
.Position = 2 + Bytes(1)
Bytes = .Read(3)
If Bytes(0) <> 2 Then Err.Raise 5, , "ADTG byte 9, se esperaba: 2 (handler)"
LongVal = Bytes(1) + Bytes(2) * 256 ' handler size
.Position = .Position + LongVal
Bytes = .Read(3)
If Bytes(0) <> 3 Then Err.Raise 5, , "ADTG, se esperaba: 3 (result descriptor)"
LongVal = Bytes(1) + Bytes(2) * 256 ' result descriptor size
.Position = .Position + LongVal
Bytes = .Read(3)
If Bytes(0) <> 16 Then Err.Raise 5, , "ADTG, se esperaba: 16 (adtgRecordSetContext)"
LongVal = Bytes(1) + Bytes(2) * 256 ' token size
.Position = .Position + LongVal
Bytes = .Read(3)
If Bytes(0) <> 5 Then Err.Raise 5, , "ADTG, se esperaba: 5 (adtgTableDescriptor)"
LongVal = Bytes(1) + Bytes(2) * 256 ' token size
.Position = .Position + LongVal
Bytes = .Read(1)
If Bytes(0) <> 6 Then Err.Raise 5, , "ADTG, se esperaba: 6 (adtgTokenColumnDescriptor)"
Do ' For each Field
Bytes = .Read(2)
LongVal = Bytes(0) + Bytes(1) * 256 ' token size
Dim NextTokenPos As Long
NextTokenPos = .Position + LongVal
Dim PresenceMap As Long
Bytes = .Read(3)
PresenceMap = Val("&H" & Right$("0" & Hex$(Bytes(0)), 2) & Right$("0" & Hex$(Bytes(1)), 2) & Right$("0" & Hex$(Bytes(2)), 2))
Bytes = .Read(2) 'ColumnOrdinal
'WordVal = Val("&H" & Right$("0" & Hex$(Bytes(0)), 2) & Right$("0" & Hex$(bytes(1)), 2))
'Aca pueden venir: friendly_columnname, basetable_ordinal,basetab_column_ordinal,basetab_colname
If PresenceMap And &H800000 Then 'friendly_columnname
Bytes = .Read(2) 'Size
LongVal = Bytes(0) + Bytes(1) * 256 ' Size
.Position = .Position + LongVal * 2 '*2 debido a UNICODE
End If
If PresenceMap And &H400000 Then 'basetable_ordinal
.Position = .Position + 2 ' 2 bytes
End If
If PresenceMap And &H200000 Then 'basetab_column_ordinal
.Position = .Position + 2 ' 2 bytes
End If
If PresenceMap And &H100000 Then 'basetab_colname
Bytes = .Read(2) 'Size
LongVal = Bytes(0) + Bytes(1) * 256 ' Size
.Position = .Position + LongVal * 2 '*2 debido a UNICODE
End If
Bytes = .Read(2) 'adtgColumnDBType
'WordVal = Val("&H" & Right$("0" & Hex$(Bytes(0)), 2) & Right$("0" & Hex$(bytes(1)), 2))
Bytes = .Read(4) 'adtgColumnMaxLength
'LongVal = Val("&H" & Right$("0" & Hex$(Bytes(3)), 2) & Right$("0" & Hex$(Bytes(2)), 2) & Right$("0" & Hex$(Bytes(1)), 2) & Right$("0" & Hex$(Bytes(0)), 2))
Bytes = .Read(4) 'Precision
'LongVal = Val("&H" & Right$("0" & Hex$(Bytes(3)), 2) & Right$("0" & Hex$(Bytes(2)), 2) & Right$("0" & Hex$(Bytes(1)), 2) & Right$("0" & Hex$(Bytes(0)), 2))
Bytes = .Read(4) 'Scale
'LongVal = Val("&H" & Right$("0" & Hex$(Bytes(3)), 2) & Right$("0" & Hex$(Bytes(2)), 2) & Right$("0" & Hex$(Bytes(1)), 2) & Right$("0" & Hex$(Bytes(0)), 2))
Dim ColumnFlags() As Byte, NewFlag0 As Byte
ColumnFlags = .Read(1) 'DBCOLUMNFLAGS, First Byte only (DBCOLUMNFLAGS=4 bytes total)
NewFlag0 = ColumnFlags(0)
If (NewFlag0 And &H4) = 0 Then 'DBCOLUMNFLAGS_WRITE (bit 2) esta OFF
'Lo pongo en ON, ya que quiero escribir esta columna LOCALMENTE en el rst DESCONECTADO
NewFlag0 = (NewFlag0 Or &H4)
End If
If (NewFlag0 And &H8) <> 0 Then 'DBCOLUMNFLAGS_WRITEUNKNOWN (bit 3) esta ON
'Lo pongo en OFF, ya que no me importa si NO sabes si se puede updatear no, yo lo se, no te preocupes
'ya que quiero escribir esta columna LOCALMENTE en el rst DESCONECTADO
NewFlag0 = (NewFlag0 And Not &H8)
End If
If (NewFlag0 And &H20) <> 0 Then 'DBCOLUMNFLAGS_ISNULLABLE (bit 5) esta OFF
'Lo pongo en ON, ya que siendo un RST DESCONECTADO, si le quiero poner NULL, le pongo y listo
NewFlag0 = (NewFlag0 Or &H20)
End If
If NewFlag0 <> ColumnFlags(0) Then
ColumnFlags(0) = NewFlag0
.Position = .Position - 1
.Write ColumnFlags
End If
.Position = NextTokenPos
Bytes = .Read(1)
Loop While Bytes(0) = 6
'Reconstruyo el Rst desde el stream
S.Position = 0
Set Rst = New Recordset
Rst.Open S
End With
'TEST IT
On Error Resume Next
Rst!C1 = 15
Rst!C5 = "MUCHOS CHARS"
Rst!C7 = 23423
If Err.Number = 0 Then
MsgBox "OK"
Else
MsgBox Err.Description
End If
</pre>
Maybe you are looking for
-
Capturing Detail Items for a Related List in a New Item Form
I have a simple (ha!) requirement to capture Purchase Requests with the individual line items being captured in a separate List. I have been using InfoPath, but will consider ANY solution at this point. If I have an Edit Item Form, I can have a Data
-
Revision: 4159 Author: [email protected] Date: 2008-11-21 13:06:29 -0800 (Fri, 21 Nov 2008) Log Message: Enhancement SDK-18016 - updating mxmlc's Embed functionality to recognize .pbj files as precompiled Shader files. This change still retains the o
-
What steps need follow in OWB after changing SERVICE_NAME in RAC
Hi, Due to some reason we are planning to change the SERVICE_NAME in the RAC environment. We have deployed near about 500 mapping and 10 process flows with the old SERVICE_NAME.Using OMBALTER LOCATION "LOCATION_NAME" SET PROPERTIES(SERVICE_NAME) VALU
-
Hello, I am trying to find some info about how to store very large numbers with like 2000 digits or even more and do calculations on them. Does anyone have any info or links about this ?? Thanks.
-
Hi, I have the following problem: I need to write a String to a file. The string is encoded in Windows-1250 code page. I use RandomAccessFile.writeBytes(String) method but for special characters (Polish letters) there are written some Ascii signs (0-