HSTMT, UCHAR, SDWORD meaning in ODBC Log - sql

I have the following lines in my ODBC Log :
(Scenario: pgAdmin4, using PostgreSQL server through ODBC32 in another application named System Administration)
System Admi 6a0-6f8 ENTER SQLExecDirect
HSTMT 0x00630718
UCHAR * 0x036B29C0 [ 63] "create table new (npages integer, ifnds integer, ifnid integer)"
SDWORD 63
I need to know the meaning of HSTMT, UCHAR* and SDWORD. What do those numbers next to them mean ?

From the article Everything You Want To Know About ODBC Tracing
In the trace log, you’ll see the data type of the handle being
SQLHANDLE, HENV / SQLHENV, HDBC / SQLHDBC, HSTMT / SQLHSTMT. This
value is unique to the particular series of items being called. You
can search in the trace log for this handle number and each call made
on the handle will be shown. This allows you to pick out only the
calls in the trace log that are relevant to your error message. Keep
in mind, some applications may create multiple handles. For example,
your application may execute three statements consecutively with each
residing on a different statement handle.
For examples and more details follow the next nice document:-
How to read an ODBC trace file.rtf

This is a record of ODBC tracing
There was a procedure "SQLExecDirect" with statement handle 0x00630718, text parameter (passed as pointer) is "create table ..." and last parameter is size of text (passed as word type). See related reply in MSDOC.
HSTMT,UCHAR, SDWORDS are data types used by C, C++ MS Windows API.

Related

Clone a program which uses a logical database, programmatically

I have a report, let's call it REPORT_A, and I'd like to clone it to REPORT_B, execute REPORT_B, and then come back.
I'm doing the following:
DATA: lv_report_name TYPE c LENGTH 30 VALUE `DEMO_LIST_OUTPUT`,
lv_new_report_name TYPE c LENGTH 30 VALUE `ZZ_DEMO_LIST_OUTPUT`,
lt_report_code TYPE abaptxt255_tab,
lv_message TYPE abaptxt255,
lv_line TYPE i,
lv_word TYPE abaptxt255.
READ REPORT lv_report_name INTO lt_report_code.
SYNTAX-CHECK FOR lt_report_code
MESSAGE lv_message
LINE lv_line
WORD lv_word.
IF sy-subrc = 0.
INSERT REPORT lv_new_report_name FROM lt_report_code STATE 'A'.
GENERATE REPORT lv_new_report_name.
SUBMIT (lv_new_report_name) VIA SELECTION-SCREEN AND RETURN.
ENDIF.
The syntax-check statement is returning sy-subrc = 4, and lv_message contains:
PERNR is not defined for the current logical database
This is the issue -> REPORT_A uses PNP logical database and has a get pernrstatement, so it fails the syntax-check.
Detail: REPORT_A is working just fine, tables pernr is declared in it. If I run it alone in SE38, it executes perfectly.
But, due to this weird error, I am always failing to generate REPORT_B.
Even if I skip the IF condition, it will then DUMP in the submit line, pointing a syntax error referring to the same error, "pernr is not defined for the current logical database".
Is there a way around it?
Can I call get pernr dynamically, so it doesn't fail the syntax check?
First of all, be careful, INSERT REPORT and GENERATE REPORT are statements for internal use (reserved to SAP).
If you still want to use the internal statements, see the rest of my answer.
Otherwise the workaround is to use GENERATE SUBROUTINE POOL. But it won't work for a logical database. If you copy a standard program maybe it's not a good idea of copying it (no note assistant to help you in case of patch/upgrade), so the classic workarounds are to add implicit enhancement options, or use eventual user exits proposed by SAP in this particular program (if any). There might be other options, but it depends on your exact goal, which you didn't share (yet).
The statement INSERT REPORT creates a source code module with a program entry (in table TRDIR) which by default corresponds to an Executable program (A.K.A. "report"), and so can be executed with SUBMIT.
But in your case, the program you want to generate is a program using a Logical Database, so you must assign the program attribute Logical database (TRDIR-LDBNAME).
The program attributes are to be passed via the words DIRECTORY ENTRY in the following statements:
SYNTAX-CHECK ... DIRECTORY ENTRY ls_trdir
INSERT REPORT ... DIRECTORY ENTRY ls_trdir
An easy solution for copying an existing program is to read its program attributes from the table TRDIR, change the name of the program (TRDIR-NAME) that you are creating, and pass them after the words DIRECTORY ENTRY.
Additional comments:
COMMIT WORK should be placed after GENERATE REPORT as explained in the documentation.
SY-SUBRC should be checked after INSERT REPORT and GENERATE REPORT.
Consequently, the following code will work:
DATA: lv_report_name TYPE c LENGTH 30 VALUE `DEMO_LIST_OUTPUT`,
lv_new_report_name TYPE c LENGTH 30 VALUE `ZZ_DEMO_LIST_OUTPUT`,
lt_report_code TYPE abaptxt255_tab,
lv_message TYPE abaptxt255,
lv_line TYPE i,
lv_word TYPE abaptxt255,
ls_trdir TYPE trdir.
READ REPORT lv_report_name INTO lt_report_code.
SELECT SINGLE * FROM trdir INTO ls_trdir WHERE name = lv_report_name.
ls_trdir-name = lv_new_report_name.
SYNTAX-CHECK FOR lt_report_code
MESSAGE lv_message
LINE lv_line
WORD lv_word
DIRECTORY ENTRY ls_trdir.
IF sy-subrc = 0.
INSERT REPORT lv_new_report_name FROM lt_report_code STATE 'A' DIRECTORY ENTRY ls_trdir.
IF sy-subrc = 0.
GENERATE REPORT lv_new_report_name.
IF sy-subrc = 0.
COMMIT WORK.
SUBMIT (lv_new_report_name) VIA SELECTION-SCREEN AND RETURN.
ELSE.
* Handle the error + rollback
ENDIF.
ELSE.
* Handle the error + rollback
ENDIF.
ELSE.
* Handle the error
ENDIF.

Omitting the creation of a temporary access path with DB2/400 when accessing DDS-defined tables with SQL

I have two table definitions in DDS, compiled into *FILE objects and filled with data:
Kunpf:
A UNIQUE
A R KUNTBL
A FIRMA 60A ALWNULL
A KUNR 5S 0B
A KUNID 4S 0B
A K KUNR
A K KUNID
Kunsupf:
A R KUNSUTBL
A KUNID R B REFFLD(KUNID KUN/KUNPF)
A
A SUCHSTR 78A
A K SUCHSTR
A K KUNID
I'm using the following statement in interactive SQL (STRSQL):
SELECT DISTINCT FIRMA, KUNR FROM KUN/KUNPF
LEFT JOIN KUN/KUNSUPF ON (KUNPF.KUNID = KUNSUPF.KUNID)
WHERE SUCHSTR LIKE 'Freiburg%'
ORDER BY FIRMA
FOR READ ONLY
Everytime I execute this statement, I'm getting a considerable delay until the answer screen opens up. Beforehand a message is shown, stating that a temporary access path is being created.
How can I find out which/how this temporary access path is created? My goal is to have this access path made permanent so it doesn't need to be rebuilt with every invocation of this query.
I searched the net (especially the IBM site) but what I found out was mostly for DB2 on z/OS. The F4-Prompting facility in STRSQL doesn't provide help: I was searching for something like EXPLAIN SELECT from MySQL. The IBM DB2 Advanced Functions and Administration PDF states that there's a debug mode but it seems that it is only available from some (old) Windows tool I don't remember to have.
I'm utilizing V4R5, if this is relevant.
to see the access path on the green screen...
strdbg
strsql
run your statement
exit f3
enddbg
dspjoblog
the access path messages are at the bottom of the log f10 f18 afaik
v4r5??? That's like 20 years old...
For the IBM i, the "Run SQL Scripts" component of the old Client Access For Windows iSeries Navigator component and the new Access Client Solutions (ACS) contains Visual Explain (VE).
Luckily it seems though it was added to v4r5
http://ibmsystemsmag.com/ibmi/administrator/db2/database-performance-tuning-with-visual-explain/
Just start iNav, right click on "Database" and select "Run SQL Scripts"
Paste your query there and click "Visual Explain" -->"Run and Explain"
(or the corresponding button)
Optionally, in green screen.
Do a STRDBG to enter debug mode, F12 to continue and then go into STRSQL. The Db optimizer will then output additional messages into the joblog giving you more information about what it is doing..

Importing data from multi-value D3 database into SQL issues

Trying to use the mv.NET by bluefinity tools. Made some integration packages with it for importing data from a d3 multi-value database into MS SQL 2012 but seem to be having some trouble with the mapping.
For the VOYAGES table have some commentX fields in the D3 application that are acting quite unwieldy and the INSERT fails after a certain number of rows with the following message
>Error: 0xC0047062 at INSERT, mvNET Source[354]: System.Exception: Error #8: dataReader[0] = LTPAC002 ci.BufferColumnIndex = 52, ci.ColumnName = COMMGROUP(Error #8: dataReader[0] = LTPAC002 ci.BufferColumnIndex = 52, ci.ColumnName = COMMGROUP(The value is too large to fit in the column data area of the buffer.))
at mvNETDataSource.mvNETSource.PrimeOutput(Int32 outputs, Int32[] outputIDs, PipelineBuffer[] buffers)
at Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostPrimeOutput(IDTSManagedComponentWrapper100 wrapper, Int32 outputs, Int32[] outputIDs, IDTSBuffer100[] buffers, IntPtr ppBufferWirePacket)
Error: 0xC0047038 at INSERT, SSIS.Pipeline: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED.The PrimeOutput method on mvNET Source returned error code 0x80131500.The component returned a failure code when the pipeline engine called PrimeOutput().The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing.There may be error messages posted before this with more information about the failure.
The value is too large to fit in the column data area of the buffer. -> tried changing the input / outputs types but can't seem to get it right.
In the SQL table the columns are of type ntext.
In the .dtsx job the data type for the columns are of type Unicode String [DT_WSTR] with length 4000 , I guess these are auto-detected.
The import worked for other D3 files like this not sure why it fails for these comment fields.
Running the query on the mv.NET Data Manager ( on the d3 server) times out after 240 seconds so maybe this is the underlying issue?
Any ideas how to proceed? Thank you ~
Most like reason is column COMMGROUP does not have correct data type or some record in source do not fit in output type
To find error record (causing) you have to use on redirect row (property of component failing component ) and get the result set in some txt.csv /or tsv file .
then check data
The exception is being thrown from mv.NET so I suggest you call (or ask your reseller) to call Bluefinity support and ask them about this. You're paying for support, might as well use it. Those programs shouldn't be allowed to throw exceptions like that.
D3 doesn't export Unicode, that might be one issue. But if the Data Manager times-out then I suspect something is wrong in the connectivity into D3. Open a Connection Monitor from the Session Monitor and watch the connection when you make the request. I'm guessing it's either hanging or more probably it's falling into BASIC Debug.
Make sure all D3-side programs related to this are either all Flash-compiled, or all Not Flashed. Your app code will fall into Debug if it's not Flashed but MVNET.BP is.
If it's your program that's in Debug, fix it. If you're not sure which program it is, LIST-RUNTIME-ERRORS in DM.
If it's a MVNET.BP program, again work with Bluefinity. If you are using MVSP for connectivity then the Connection Monitor may be useless, you'll need to change that to an IP (Telnet) connection to see the raw data exchange.

Vb6 Adodb error codes with equivalent nativeerror

I need to know the list of Visual Basic 6 error codes returned by ADODB SQL Server connection. I also want to know the Err.Nativeerror for each SQL ADODB error code.
Any information about where we can get these errors codes or any VB6 codes which list the exceptions and error codes with descriptions of the error details and what the errors mean.
A table of the ADODB error codes with brief descriptions are located at ADO Programmer's Reference > ADO API Reference > ADO Enumerated Constants.
There is a note:
OLE DB errors may be passed to your ADO application. Typically, these
can be identified by a Windows facility code of 4. For example,
0x8004.
Also to determine if an HRESULT error code is an ADODB error, this additional note indicates:
Hexadecimal—The hexadecimal representation of the full error number.
The Windows facility code is in the fourth digit. The facility code
for ADO error numbers is A. For example: 0x800A0E7B.
See also [MS-ERREF]: Windows Error Codes from Microsoft which has a link to a pdf of a document from Microsoft with a fairly comprehensive list of codes and their descriptions. There is an RSS feed to subscribe for notifications of updates.
See as well as very comprehensive list of Error Codes list for Microsoft technologies from Symantech.
See this Wikipedia topic HRESULT describing the error code format used by Microsoft for HRESULT error codes. From the topic the format as to how bits are used is:
S - Severity - indicates success/fail
0 - Success
1 - Failure
R - Reserved portion of the facility code, corresponds to NT's second severity bit.
1 - Severe Failure
C - Customer. This bit specifies if the value is customer-defined or Microsoft-defined.
0 - Microsoft-defined
1 - Customer-defined
N - Reserved portion of the facility code. Used to indicate a mapped NT status value.
X - Reserved portion of the facility code. Reserved for internal use. Used to indicate HRESULT values that are not status values, but are instead message ids for display strings.
Facility - indicates the system service that is responsible for the error. Example facility codes are shown below (for the full list see [1]).
1 - RPC
2 - Dispatch (COM dispatch)
3 - Storage (OLE storage)
4 - ITF (COM/OLE Interface management)
7 - Win32 (raw Win32 error codes)
8 - Windows
9 - SSPI
10 - Control
11 - CERT (Client or server certificate)
...
Code - is the facility's status code
The ITF facility code has subsequently been recycled as the range in which COM components can define their own component-specific error code.
A few of the more common codes are:
adErrItemNotFound - -2146825023 or 0x800A0CC1 - Item cannot be found in the collection that corresponds to the requested name or ordinal.
adErrNoCurrentRecord - -2146825267 or 0x800A0BCD - Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
adErrObjectNotSet - -2146824868 or 0x800A0D5C - Object is no longer valid.
One programmer error that I have done myself which resulted in an HRESULT of 0x800A0CC1 when doing an Update() is that the I did not have my SAFEARRAY setup properly. See usage differences between _variant_t, COleVariant, CComVariant, and VARIANT and using SAFEARRAY variations.

updateblob fails in Powerbuilder

In Powerbuilder I am trying to update a table (Oracle) with blob but get sqlerror, "Database statement must refer to blob variable". My declaration and updateblob statements are as follows:
blob lblob_newxml
long llong_subid
UPDATEBLOB RP_XML_FORMS SET XML_DOC = :lblob_newxml
WHERE SUBMISSION_ID = :llong_subid
USING SQLCA;
Does anybody know why it is happening and or how to solve this problem? Thanks.
To get more information on this problem and the possible causes, I'd run with one of the database traces turned on. (You can check out database trace options in the Connecting to Your Database manual; link may not be appropriate for your PB version, which you haven't mentioned yet.) This may or may not tell you more, but it tracks everything between the app and when the PB drivers pass the commands "over the wall" to the database's driver.
Good luck,
Terry.
"The PowerBuilder VM can get the SQL syntax for the following types of errors, and passes it to the Transaction object’s DBError event for the following types of errors: ..." (see this page).
If your lblob_newxml is null then use this update statement instead:
UPDATE RP_XML_FORMS SET XML_DOC = NULL
WHERE SUBMISSION_ID = :llong_subid
USING SQLCA;