Table of records from a stored procedure
Hi
Where could I find an example or documentation about how to retrive a table of records from a Stored Procedure ??
Thanks
Try:
CREATE OR REPLACE TYPE scott.MYRECORDTYPE as object
(a int, b varchar2(40), c date, d number(10));
CREATE OR REPLACE TYPE scott.MYTABLETYPE is table of myrecordtype;
CREATE OR REPLACE PACKAGE BODY scott.MYPACKAGE
as
type number_collection is table of number(38) index by binary_integer;
type varchar2_collection is table of varchar2(4000) index by binary_integer;
type date_collection is table of date index by binary_integer;
g_data myTableType;
empno_col number_collection;
ename_col varchar2_collection;
hiredate_col date_collection;
mgr_col number_collection;
function my_function return myTableType
is
begin
select empno, ename, hiredate, mgr
bulk collect into empno_col, ename_col, hiredate_col, mgr_col
from emp
order by empno; -- Get some data
g_data := myTableType(); -- Initialize
for i in empno_col.first .. empno_col.last loop
g_data.extend; -- Write something in the array
g_data(i) := myRecordtype(empno_col(i), ename_col(i), hiredate_col(i), mgr_col(i));
end loop;
return g_data;
end;
end;
-- Demonstration-View
CREATE OR REPLACE VIEW scott.myview
AS
select a,b,c,d
from table(cast(myPackage.my_function() as mytabletype));
Similar Messages
-
Returning a table from a stored procedure
hi, i need to return a table from a stored procedure and show it, and come to this, but a don't know hoy to run it, so i don't know if it is right, can anyone help me?
uTable out objects_uptime%rowtype
as
begin
select * into uTable from objects_uptime;
end;well, i finally discovered how to do the trick
this is the code for the function:
CREATE OR REPLACE FUNCTION FN_GET_RECORDS RETURN UPTIME PIPELINED IS
CURSOR cUptime is select * from objects_uptime;
p refcur.refcur_t;
temp p%ROWTYPE;
temp2 OUPTIME := OUPTIME(null, null, null, null, null, null, null, null, null);
BEGIN
OPEN cUptime;
LOOP
FETCH cUptime into temp;
temp2.OBJ_NAME := temp.OBJ_NAME;
temp2.IP := temp.IP;
temp2.STATUS := temp.STATUS;
temp2.DOE := temp.DOE;
temp2.ENABLED := temp.ENABLED;
temp2.COMMENT00000 := temp.COMMENT00000;
temp2.USERID := temp.USERID;
temp2.OBJECTID := temp.OBJECTID;
temp2.MNTID := temp.MNTID;
pipe row(temp2);
EXIT WHEN cUptime%NOTFOUND;
END LOOP;
RETURN;
END FN_GET_RECORDS;
and this for the auxiliar package, object and table:
CREATE OR REPLACE PACKAGE REFCUR
as
TYPE refcur_t IS REF CURSOR RETURN objects_uptime%ROWTYPE;
end REFCUR;
CREATE OR REPLACE TYPE OUPTIME AS OBJECT ( "OBJ_NAME"
VARCHAR2(255), "IP" VARCHAR2(20), "STATUS" VARCHAR2(10),
"DOE" DATE, "ENABLED" NUMBER(10, 1), "COMMENT00000"
VARCHAR2(1000), "USERID" VARCHAR2(50), "OBJECTID" NUMBER(10,
1), "MNTID" NUMBER(10, 1) )
CREATE TYPE TUPTIME AS
TABLE OF OUPTIME
i call it this way:
select * from table(FN_GET_RECORDS ())
if anyone knows how to do the same in a shorter manner, tell me please.
thanks to everybody for the help. -
Create a new table from another table that exists ussing a stored procedure
Hi,
I want to know if is posibble to create a new table from another table that exists ussing a stored procedure. This new table is created from other table that exists in the DB.
(in the next code the table tbl1 exist into the schema of the DB, but temp_tbl1 does not exist, it must be created by the procedure)
create or replace procedute temp is
temp_tbl1 tbl1%TYPE; //the temp_tbl1 will have the same type of tbl1
begin
create table temp_tbl1 as (select * from tbl1);
end temp;
thanks very muchcat wrote:
Hello,
I think my problem is not about this grant, because if I execute this as an "anonymous procedure":
DECLARE
BEGIN
EXECUTE IMMEDIATE 'CREATE TABLE Abonus (id NUMBER, amt NUMBER)';
END;
It runs ok
But if I do:
CREATE OR REPLACE procedure temp as
BEGIN
EXECUTE IMMEDIATE 'CREATE TABLE Abonus (id NUMBER, amt NUMBER)';
END;
I have the error
ORA-01031: Insufficient privileges
ORA-06512: at "temp", line 3Anonymous blocks are treated as "Invoker's Rights" from a privilege perspective whereas stored programs by default are treated as "Definer's Rights". Therefore using anonymous blocks is not a valid test to check this.
The simplest form of checking this issue is by executing
SET ROLE NONE;and then to run your statement/code block in question interactively. Using this approach you get in your session the effective rights of a "Definer's Rights" stored program, i.e. only privileges that you got granted directly to your user.
You can revert to the default setting by issuing
SET ROLE ALL;For more information regarding this topic, read e.g. the documentation:
http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/subprograms.htm#LNPLS00809
Regards,
Randolf
Oracle related stuff blog:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/ -
Get variable values from a stored procedure
I am using SQL 2008R2 and I want to replace a view inside a stored procedure with a new stored procedure to return multiple variable values. Currently I am using the code below to get values for 4 different variables. I would rather get the 4 variables
from a stored procedure (which returns all of these 4 values and more) but not sure how to do so. Below is the code for getting the 4 variable values in my current sp.
DECLARE @TotalCarb real;
DECLARE @TotalPro real;
DECLARE @TotalFat real;
DECLARE @TotalLiquid real;
SELECT @TotalCarb = ISNULL(TotCarb,0),
@TotalPro = ISNULL(TotPro,0),
@TotalFat = ISNULL(TotFat,0),
@TotalLiquid = ISNULL(TotLiq,0)
FROM dbo.vw_ActualFoodTotals
WHERE (MealID = @MealID);You can replace the view with inline table valued user-defined function:
http://www.sqlusa.com/bestpractices/training/scripts/userdefinedfunction/
See example: SQL create INLINE table-valued function like a parametrized view
Kalman Toth Database & OLAP Architect
SQL Server 2014 Design & Programming
New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012 -
Updateable recordset from a stored procedure
I would like to retrieve an updateable recordset from a stored procedure using the oracle 9.2.0.2.0
oledb provider
I am using the sample code/tables provided from Oracle.
Does anyone have an example or has actually created an updatedable recordset from a stored procedure ?Assuming your stored procedure is returning a REF CURSOR, it cannot be done. Oracle's REF CURSORS are read only constructs.
Justin -
Resultset from a Stored Procedure
Hello Everyone,
Is it possible to return a resultset from a stored procedure? I need to do display set of rows which are resulted by joining few tables.
Is it possible?
Please help..
TIA
Regards,
Rao Santapur.
null<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Raymond Tang ([email protected]):
You can use 'REF CURSOR'<HR></BLOCKQUOTE>
I have created a stored procedure with a ref cursor- what parameters do i need to pass via Sql*Plus to get results?
[email protected]
null -
Retruring Multiple rows from a Stored Procedure
The Oracle JDBC documentation shows how to return a cursor pointer through the parameter list of a stored procedure allowing a Java program to use the cursor like a normal result set. I've tried it (using the thin driver) and it works fine - however, I'm having trouble getting this to work running the program under a Weblogic server (using their own JDBC implementation). So, I have two questions:
1) Has anyone had this problem before and solved it ??
2) Are there any other techniques for getting multiple rows back from the database without having to fire "raw" sql at it ?Hi
You could return not resultset but array, for example:
PACKAGE TEST:
type string_table is table of varchar2(80)
index by binary_integer;
function get_something (
something1 out string_table,
arraylength in number
) return number;
PACKAGE'S BODY:
function get_something (
something1 out string_table,
arraylength in number /** length of the array **/
) return number as
cursor C is
select something1, ...
from test_table;
pos number := 1;
begin
for position in C loop
exit when (pos > arraylength);
something1(pos) := position.something1;
pos := pos + 1;
end loop;
return (pos - 1);
end;
Of course in this example you need to know length of your array
(arraylength parameter), but you can avoid such problem, for
example, by using DBMS_SQL package (or dynamic SQL feature in
the Oracle8i).
Andrew
Mladen Gogala (guest) wrote:
: Phil Hildebrand (guest) wrote:
: : Is there a way that I can return multiple rows from a stored
: : procedure for function ?
: : Something like:
: : CREATE FUNCTION sp_get_children (my_nip IN port.nip_num%
TYPE)
: : RETURN my_nip
: : IS
: : CURSOR child_cur IS
: : SELECT nip_num
: : FROM logical_port
: : WHERE port_num = my_nip;
: : child_rec child_cur%rowtype;
: : BEGIN
: : FOR child_rec IN child_cur
: : LOOP
: : RETURN my_nip;
: : END LOOP;
: : END tmp_sp_get_children;
: : I know how to do it in Informix ( RETURN WITH RESUME ), but
: I'm
: : not running Informix ;)
: : Thanks,
: : Phil
: In contrast with Informix, SQL Server and Sybase, Oracle
: can not return a result set. the only workaround is to
: return the cursor variable as such.
null -
Calling stored procedure from a stored procedure
I have a stored procedure that accepts a customer prefix like "abc" and returns a customer document number like "abc-0021". (Thanks V Garcia)
This sp works when I call it from SQL Plus Worksheet.
But I need to call it from another stored procedure and store it in a local variable so that I can insert it into a table with the rest of the information.
This is what I have tried so far:
CREATE OR REPLACE PROCEDURE "SCHEMANAME"."SP_XXTESTXX" ( seq_name in
varchar2)
AS
id_out varchar(10);
BEGIN
execute SP_GET_NEXT_DOC_NUMBER(seq_name,:id_out);
print id_out;
END;but this will not compile. I get this error:
Line # = 8 Column # = 12 Error Text = PLS-00103: Encountered the symbol "SP_GET_NEXT_DOC_NUMBER" when expecting one of the following: := . ( @ % ; immediate The symbol ":=" was substituted for "SP_GET_NEXT_DOC_NUMBER" to continue.
Line # = 8 Column # = 41 Error Text = PLS-00049: bad bind variable 'ID_OUT'
Line # = 10 Column # = 10 Error Text = PLS-00103: Encountered the symbol "ID_OUT" when expecting one of the following: := . ( @ % ; The symbol ":=" was substituted for "ID_OUT" to continue.I think I got it.
CREATE OR REPLACE PROCEDURE "SCHEMANAME"."SP_XXTESTXX" ( seq_name in
varchar2)
AS
id_out varchar(10);
BEGIN
SP_GET_NEXT_DOC_NUMBER(seq_name,id_out);
dbms_output.put_line(id_out);
END;This works like I wanted it to do. -
Set page item from a stored procedure
Dear reader
We would like to have a stored procedure to run every 10 minutes. When the procedure starts, the user has to be warned that the update process is running.
When the procedure is finished, the user should receive a message that the update process is finished.
What I had in mind was to set a Page 0 item 'P0_REFRESH' and set his value depending on the status of the update. Then add a dynamic action with a change event. So everytime the value of this page item changes, the user will receive a correct message.
Does anyone know if it is possible to set a page item from a stored procedure?
Kind regards
XnniAndyPol
I found a solution by querying the user_jobs table. In Apex, I created two page 0 items that hold the current status of the job (online, offline) and the old value of the job.
Online of offline in the current status item is determined by a decode on "this_sec".
The enext step was to include a html region in P0 that contains some javascript. This javascript will display a message when the values of the new status is different from the old status ;)
Many thanks for bringing up the ideas.
Greetz
Xnni -
How do I get return parameters from a stored procedure call?
The Open SQL Statement has an option on the Advanced tab to specify a command type of 'stored procedure'. In addition to returning a recordset, a stored procedure can also return parameters (see http://support.microsoft.com/support/kb/articles/Q185/1/25.ASP for info on doing this with ADO). Is it possible to get those return parameters with TestStand? In particular, I want to be able to get error codes back from the stored procedure in case it fails (maybe there is another way).
The Open SQL Statement step type does not fully support stored procedures. If the procedure returns a record set than you can fetch the values as you would a SELECT statement. Stored procedures require you to setup the parameters before the call and this is not yet supported. Bob, in his answer, made a reference to the Statements tab and I think that he was talking about the Database Logging feature in TS 2.0.
If the stored procedure is returning a return value, it may return as a single column, single row recordset which can be fetched as you normally do a record set.
Scott Richardson
National Instruments -
How to fetch oracle process id from a stored procedure.
Hi,
I want to fetch the oracle process id from within a stored procedure.
I know that the one way to do this is using the v$process view. But, a grant has to be given to the user on this table. Due to the strict policies at my workplace, I do not have the permission to do this, nor can i ask anyone to give the grant. But, i need the oracle pid very much.
Is there an alternate way to get the oracle process id from within the stored procedure (without using the v$process view, like we have sys_context() to fetch session id without using v$session) ?
Any help would be appreciated.
Thanks,
APHi,
The point is i do not want to use v$process ( or v_$process) ,because i can not give the select grant to the user on this view. ( As i need to fetch it from a stored procedure, not from the SQL prompt).
Rahul , your query is correct. It fetches the values ( though i needed oracle process id not unix pid ; i would get it through p.pid), but i need an alternate approach to this.
Is there an alternate approach which would enable me to fetch the oracle process id ( without using any of the V$ - system views) ? Does Oracle has such a feature /approach ?
-AP -
How to use dbms_Scheduler.Create_Job from within stored procedure?
Hello,
using 10g (10.1.0.2.0) on Windows 2000 I had problems to create scheduler jobs from within a stored procedure (see example below). What easily succeeds using anonymous blocks failed when calling from a stored procedure, due to ORA-27486. Only when I compile the procedure with invoker's rights the call to dbms_Job.Create_Job is successfull!? From my knowledge there is no difference between invoker's and definer's rights, if I compile and call with the same user, is there?
Does anyone know the reason for this behaviour or is it simply a bug?
Have a nice day.
Björn Hachmann
Hamburg / Germany
-- Example start.
create table t
a number(1),
b date default sysdate
create or replace procedure sched1
is
begin
dbms_scheduler.create_job(
job_name => 'TEST_JOB1',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN insert into t values (1); END;',
repeat_interval => 'freq=secondly',
enabled => TRUE
commit;
end;
create or replace procedure sched2
authid current_user
is
begin
dbms_scheduler.create_job(
job_name => 'TEST_JOB2',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN insert into t values (2); END;',
repeat_interval => 'freq=secondly',
enabled => TRUE
commit;
end;
exec sched1; -- This call fails with ORA-27486.
exec sched2; -- This call succeeds!
/* Cleanup.
exec dbms_scheduler.drop_job('TEST_JOB1', true);
exec dbms_scheduler.drop_job('TEST_JOB2', true);
drop table t;
*/Your example code ran without problems for me on 10.1.0.3.0 so it probably is a bug.
-
Creating universe from MySql stored procedure?
Hi,
I am new to BusinessObjects. I need to create universes based on the schema in our MySql database. However, when I tried to create one from a stored procedure, I fount that I wasn't allowed to do that or the option to insert a stored procedure was grayed out.
Is it true that universe creation from MySql stored procedures not supported, or is it just something I didn't do right? Is there any workaround?
Thanks in advance!jason Lee,
You cannot combine universes with table structures with that of the stored procedures.Thats the reason in the existing universe the option is greyed out to insert stored procedures. You need to create a new universe thru design wizard and check the option to "create a universe through the stored procedure" in the first page.
Let me know your results
Thanks,
Karthik -
Privilege for creating a View from a Stored Procedure
Hi,
I need to create a view from a procedure. I could do it from an anonymous block whereas I am unable to do that from a Stored Procedure. Should I need a specific privilege for performing this operation? If so what would be the reason behind it? Will that privilege be given in production databases?
Code to replicate:
CREATE TABLE t11 AS SELECT * FROM DUAL;
CREATE OR REPLACE PROCEDURE p_etl_test_view
AS
BEGIN
EXECUTE IMMEDIATE 'CREATE OR REPLACE VIEW v_t11 AS SELECT * FROM t11';
END;
PROCEDURE P_ETL_TEST_VIEW compiled
Elapsed: 00:00:00.131
BEGIN
EXECUTE IMMEDIATE 'CREATE OR REPLACE VIEW v_t11 AS SELECT * FROM t11';
END;
anonymous block completed
Elapsed: 00:00:00.069
BEGIN
p_etl_test_view;
END;
Error starting at line 13 in command:
BEGIN
p_etl_test_view;
END;
Error report:
ORA-01031: insufficient privileges
ORA-06512: at "OCCSS_ENTMT_HK_DEV_01.P_ETL_TEST_VIEW", line 4
ORA-06512: at line 2
01031. 00000 - "insufficient privileges"
*Cause: An attempt was made to change the current username or password
without the appropriate privilege. This error also occurs if
attempting to install a database without the necessary operating
system privileges.
When Trusted Oracle is configure in DBMS MAC, this error may occur
if the user was granted the necessary privilege at a higher label
than the current login.
*Action: Ask the database administrator to perform the operation or grant
the required privileges.
For Trusted Oracle users getting this error although granted the
the appropriate privilege at a higher label, ask the database
administrator to regrant the privilege at the appropriate label.
Elapsed: 00:00:00.100
The privileges I am having:
SELECT *
FROM dba_sys_privs
WHERE grantee = 'OCCSS_ENTMT_HK_DEV_01'
OR grantee IN (SELECT granted_role
FROM dba_role_privs
where grantee = 'OCCSS_ENTMT_HK_DEV_01')
ORDER BY 1;
GRANTEE
PRIVILEGE
ADMIN_OPTION
EXP_FULL_DATABASE
ADMINISTER RESOURCE MANAGER
NO
EXP_FULL_DATABASE
ADMINISTER SQL MANAGEMENT OBJECT
NO
EXP_FULL_DATABASE
BACKUP ANY TABLE
NO
EXP_FULL_DATABASE
CREATE SESSION
NO
EXP_FULL_DATABASE
CREATE TABLE
NO
EXP_FULL_DATABASE
EXECUTE ANY PROCEDURE
NO
EXP_FULL_DATABASE
EXECUTE ANY TYPE
NO
EXP_FULL_DATABASE
READ ANY FILE GROUP
NO
EXP_FULL_DATABASE
RESUMABLE
NO
EXP_FULL_DATABASE
SELECT ANY SEQUENCE
NO
EXP_FULL_DATABASE
SELECT ANY TABLE
NO
OCCSS_ENTMT_HK_DEV_01
CREATE DATABASE LINK
NO
OCCSS_ENTMT_HK_DEV_01
CREATE TABLE
NO
OCCSS_ENTMT_HK_DEV_01
DEBUG CONNECT SESSION
NO
OCCSS_ENTMT_HK_DEV_01
SELECT ANY DICTIONARY
NO
SCB_SCHEMA_ROLE
ALTER SESSION
NO
SCB_SCHEMA_ROLE
CREATE CLUSTER
NO
SCB_SCHEMA_ROLE
CREATE DIMENSION
NO
SCB_SCHEMA_ROLE
CREATE INDEXTYPE
NO
SCB_SCHEMA_ROLE
CREATE JOB
NO
SCB_SCHEMA_ROLE
CREATE MATERIALIZED VIEW
NO
SCB_SCHEMA_ROLE
CREATE OPERATOR
NO
SCB_SCHEMA_ROLE
CREATE PROCEDURE
NO
SCB_SCHEMA_ROLE
CREATE SEQUENCE
NO
SCB_SCHEMA_ROLE
CREATE SESSION
NO
SCB_SCHEMA_ROLE
CREATE SYNONYM
NO
SCB_SCHEMA_ROLE
CREATE TABLE
NO
SCB_SCHEMA_ROLE
CREATE TRIGGER
NO
SCB_SCHEMA_ROLE
CREATE TYPE
NO
SCB_SCHEMA_ROLE
CREATE VIEW
NOBoopathyVasagam wrote:
Thank you for your answer. So should I issue the below statement? (Since I dont have dba privs i couldn't test this)
GRANT CREATE VIEW to P_ETL_TEST_VIEW;
I doubt that above will prevent the error from being thrown.
prior to running anonymous block again; just do as below
SET ROLE NONE;
doing so should result in same error being thrown when invoking
BEGIN
p_etl_test_view;
END; -
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
-
Neo4/SLI doesn't recognize X2 3800+
Is it normal for the MSI BIOS and Windows XP (Properties of My Computer) to both say 'AMD Hammer Family processor - Model Unknown' when running an X2 3800+ in a MSI Neo4/SLI motherboard? Does the processor still work at full capability this way? My b
-
Date/Time Stamp on AP1242AG
Having just configured the AP i was reviewing the available tabs. When looking at the log i notice that the date is Mar 1. Can this be changed to the current date? If so how?
-
What is the Best way to connect CRM Case Management with EP-KM?
Hi Gurus, We will implement a Case Management in CRM 7.0 EHP2 and EP 7.31 with KM. The Client needs Clasifications and Search of the documents in Case Management, the number of documents could be 1,000, 000 aprox... I thing are 2 options : 1) The
-
Adobe Reader 11.0.09
-
Photo counts in Library Tab of Inspector Pane
I run Aperture 3.1 on a home and work computer. Home runs Snow Leopard. Work runs Leopard. On my home computer there is a photo count shown along the right edge of the library tab across from each Project name. On the work computer, there is none. I