i have a dataview from a data table i am trying to filter to see if there are duplicate values for a manufacture, Type and Serial number but i am getting an error
string strFilter = "Manufacture = " + strMake + " and Type = " + strModel + " and Serial Number = " + strSn;
strfilter = "Manufacture = ford 150 and Type = Raptor and Serial Number = 9999"
dv.RowFilter = strFilter;
this it the error i am getting
An unhandled exception of type 'System.Data.SyntaxErrorException' occurred in System.Data.dll
Additional information: Syntax error: Missing operand after 'Number' operator
You need single quotes for strings.Write serial number in brackets like [Serial number] if that is the name of your column.
For one you are missing a semi colon here.
strfilter = "Manufacture = ford 150 and Type = Raptor and Serial Number = 9999" <---------
:)
Related
i want to insert a query but not work :
my $query1 = $db1->prepare("SELECT host, name, severity FROM XX");
my $query2 = $db2->prepare('UPDATE worldmap_table' . ' SET severity = ?, name = ? WHERE HOST = ?');
$query1->execute;
while (my #row = $query1->fetchrow_array) {
$query2->execute($row[2]);
print "$row[2]\n";
}
preparation query 3
my $query3 = $db1->prepare("SELECT host, name, severity
FROM XX);
preparation query 4
my $query4 = $db2->prepare('UPDATE worldmap_table' . ' SET severity = 6, name = ? WHERE HOST = ?');
$query3->execute;
this part not work
while (my #row2 = $query3->fetchrow_array) {
$query4->execute($row2[2], $row2[1], $row2[0]);
print "$row2[2], $row2[1], $row2[0] \n";
}
i have this error:
DBD::mysql::st execute failed: called with 3 bind variables when 2 are needed at worldmap2.pl line 103.
DBD::mysql::st execute failed: called with 3 bind variables when 2 are needed at worldmap2.pl line 103.
There are two placeholders in query 4:
my $query4 = $db2->prepare(
'UPDATE worldmap_table' . ' SET severity = 6, name = ? WHERE HOST = ?'
# ~ ~
);
But you're calling it with only one argument:
$query4->execute($row2[2]);
# ~~~~~~~~
The error message mentions different numbers, so I guess you simplified the code.
So I have 13 binary values, which I call b_1... b_13, and based off these values I'd like to either set something I call indic_j to a previously defined string called inf_j, or nothing at all. Is it possible to do this without using 13 "If..." statements? What I have tried is below:
inf_1 = "aaaaa"
inf_2 = "bbbbb"
... and so on defining 13 infs, where aaaaa, bbbbb etc are names of columns in a table that I want to select.
FOR j = 1 to 13
IF b_j = 1 THEN "indic_"+j = inf_j + ",";
ELSE "indic_"+j = ""
ENDIF
ENDFOR
Also, before this I haven't introduced anything called indic_1, indic_2, etc. Is this needed?
My end goal is to transfer selected columns over to Excel. I've no problems doing this with predetermined columns, but I'm not sure how to allow for selected columns only.
I've tried using 13 IF statements, but I'm getting operator/operand type mismatch errors. My code currently is
IIF(b_1 = 1, indic_1 = inf_1 + ",",indic_1 = "")
IIF(b_2 = 1, indic_1 = inf_2 + ",",indic_1 = "")
IIF(b_3 = 1, indic_1 = inf_3 + ",",indic_1 = "")
and so on for 13 times, and then
SELECTIONRANG = indic_1 + indic_2 + indic_3 + indic_4 + indic_5 + indic_6 +indic_7 + indic_8 + indic_9 + indic_10 + indic_11 + indic_12 + indic_13
SELECTIONRANGE = LEFT(SELECTIONRANG,LEN(Selectionrang)-1)
You could create te variable name as a string and use it with &
As:
ind = 13
Var = "inf_" + ind
&Var ** inf_13
I have a question about the SAP Function Module "http_post".
I just want to post a short message (msg) out of the SAP to a Push Notification Server (pushd-Github-Projekt) I installed before. Now I'm not sure how to pass the message.
I tested the FM with the test-symbol:
CALL FUNCTION 'HTTP_POST'
exporting
ABSOLUTE_URI = uri " Uniform Resource Identifier (RFC 1945)
* REQUEST_ENTITY_BODY_LENGTH = 14 "request_entity_body_length
* RFC_DESTINATION = " RFC Destination
* PROXY = " HTTP Proxy Rechner
* PROXY_USER = " Benutzername auf dem Proxy Rechner
* PROXY_PASSWORD = " Passwort auf dem Proxy Rechner
* USER = " Benutzername auf dem HTTP Server
* PASSWORD = " Passwort auf dem HTTP Server
* BLANKSTOCRLF = " Blanks in CRLF konvertieren im Entity Body
* importing
* STATUS_CODE = " Statuscode ( 2xx = OK )
* STATUS_TEXT = " Text zum Statuscode
* RESPONSE_ENTITY_BODY_LENGTH = " Länge vom Response-Entity-Body
tables
REQUEST_ENTITY_BODY = '{"msg":"test"}' "request_entity_body
RESPONSE_ENTITY_BODY = '' " Response-Entity-Body Daten
RESPONSE_HEADERS = '' " Header Zeilen vom Response
REQUEST_HEADERS = 'Content-Type: application/json' "request_headers
* exceptions
* CONNECT_FAILED = 1
* TIMEOUT = 2
* INTERNAL_ERROR = 3
* TCPIP_ERROR = 4
* SYSTEM_FAILURE = 5
* COMMUNICATION_FAILURE = 6
* OTHERS = 7
.
I know my values are no tables, but I tested it with the test-symbol, where you can write the values directly in a table.
When I start the FM, I get an Bad Request error in the SAP
and this error at the push notification server:
SyntaxError: Unexpected token
at Object.parse (native)
at IncomingMessage.<anonymous> ...Path from the pushd..
express\node_modules\connect\lib\middleware\json.js:76:27
at incomingMessage.EventEmitter.emit events.js:92:17
at _stream:readable.js:919:16
at process._tickCallback <node.js:419:13>
Can anyone help me how to pass the request to the FM HTTP-Post? It has to be sth. with msg, because otherwise the Push-Notification-Server can't handle it.
In SAP_BASIS release 731 or higher, I would strongly recommend to use the class CL_HTTP_CLIENTfor doing HTTP requests. See here an example report on how to do it. Replace the dummy string http:1.2.3.4:80/testjon/by your URL in question.
report z_test_http_post.
start-of-selection.
perform start.
* ---
form start.
data: lv_status type i,
lv_error_occurred type flag,
lv_error_msg type string,
lv_response_body type string.
perform send_json using
'http://1.2.3.4:80/testjson/' " Use your URL here
'{"hello":"world"}' " Use your JSON here
changing lv_status lv_response_body
lv_error_occurred
lv_error_msg.
* Show result
format color col_heading.
write: / 'Response status:', lv_status.
if lv_error_occurred = 'X'.
format color col_negative.
write: / 'Error occurred:', lv_error_msg.
endif.
format color col_normal.
write: / 'Response:', lv_response_body.
endform. "start
form send_json using iv_url type string
iv_json_data type string
changing cv_status type i
cv_response_body type string
cv_error_occurred type flag
cv_error_msg type string.
data: lo_client type ref to if_http_client.
clear: cv_error_msg,
cv_status,
cv_error_occurred,
cv_error_msg.
if iv_url is initial.
* No URL passed
message e349(sbds) into cv_error_msg.
cv_error_occurred = 'X'.
return.
endif.
call method cl_http_client=>create_by_url
exporting
url = iv_url
importing
client = lo_client
exceptions
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
others = 4.
if sy-subrc ne 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
into cv_error_msg.
cv_error_occurred = 'X'.
return.
endif.
lo_client->request->set_cdata( iv_json_data ).
lo_client->request->set_content_type( 'application/json' ).
lo_client->request->set_method( 'POST' ).
call method lo_client->send
exceptions
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
others = 4.
if sy-subrc ne 0.
lo_client->get_last_error( importing message = cv_error_msg ).
cv_error_occurred = 'X'.
return.
endif.
lo_client->receive( exceptions others = 1 ).
if sy-subrc ne 0.
lo_client->get_last_error( importing message = cv_error_msg ).
cv_error_occurred = 'X'.
return.
endif.
cv_response_body = lo_client->response->get_cdata( ).
lo_client->response->get_status( importing code = cv_status ).
endform.
I am writing in Visual Basic on Visual Studio 2013.
I have defined the Customer record structure in a module. I am trying to save to a fixed length record. However, when I try and save it comes back highlighting FilePut with the error message:
"An unhandled exception of type 'System.ArgumentException' occurred in
Microsoft.VisualBasic.dll".
My code for the subroutine is below:
'Open customer file to find what ID to use
FileOpen("1", "CustomerRecord.dat", OpenMode.Random, OpenAccess.ReadWrite)
'Find length of customer file
Dim RecordLength As Integer = Len(Customer)
'Populate customer ID with algorithm to find unique ID to use (Last ID used + 1)
txt_CustomerID.Text = Str(LOF(1) / RecordLength + 1)
'Find record number to write
Dim RecordToWrite As Integer = (LOF(1) / RecordLength + 1)
'Populate all the customer variables with the corresponding
'textbox information
Customer.CusID = Int(txt_CustomerID.Text)
Customer.Title = cmb_Title.Text
Customer.Forename = txt_Forename.Text
Customer.Surname = txt_Surname.Text
Customer.Postcode = txt_Postcode.Text
Customer.NameNo = txt_HouseName.Text
Customer.Town = txt_Town.Text
Customer.DOB = txt_DOB.Text
Customer.TelNo = txt_TelNo.Text
Customer.Email = txt_Email.Text
FilePut("1", Customer, RecordToWrite)
FileClose(1)
How would I solve this problem?
I'm trying to use the openedge jdbc connector to pull data from an existing progress db but im running into column width issues.
Here is the error that is holding me up.
[DataDirect][OpenEdge JDBC Driver][OpenEdge] Column TabDisplayName in table PUB.Menu has value exceeding its max length or precision.
I've looked at many posts, each offering different advice, and here's what I've given a go this far:
Manually modify the SQL width via the data dictionary.
I ran a quick check on PUB.Menu.TabDisplayName to find a max value of 44 Characters
Set the width to x(50) to no avail and then x(100) out of a fix of irrational rage, again with no luck.
Use the SUBSTR() SQL Function to truncate the field -not optimum but better than nothing
I get weird results with this. It works fine in sqlexp but in a java environment its like the column is never selected.
Use the dbtool to automatically fix width problems with option #2
After selecting all tables and "areas" (not sure what those are...) and submitting the final option I am returned to the proenv cmdline as if nothing ever happened.
Modify the sql width programmatically via 4gl
This is the only option I found that I have yet to try.
I am a little reluctant to try this only because a manual modification failed. Also this is a live development environment(for me only) and Im trying to mess it up too terribly, although i am taking snaps regularly.
Running progress 10.2B on a unix machine.
Any comments and suggestions would be appreciated.
-Thanks
The dbtool option is the best. It is designed for this. From proenv you should see something like this:
proenv> dbtool s2k
DATABASE TOOLS MENU - 10.2B
---------------------------
1. SQL Width & Date Scan w/Report Option
2. SQL Width Scan w/Fix Option
3. Record Validation
4. Record Version Validation
5. Read or Validate Database Block(s)
6. Record Fixup
7. Schema Validation
9. Enable/Disable File Logging
Q. Quit
Choice: 2
: (0=single-user 1=self-service >1=#threads)? 1
Padding % above current max: 100
: (Table number or all)? all
: (Area number or all)? all
: (verbose level 0-3)? 0
Total records read: 31357
SQLWidth errors found: 0, Date errors found: 0
SQLWidth errors fixed: 0
If your db has a server up & running choose "1" at the connect: prompt. If not, choose "0".
Pick 100 for padding to double the width of fields.
Try it on a copy of the "sports" database if you are unsure. Use a higher level of verboseness if you want some insight into what it is doing.
It does not take very long to run on a small development database. (It is basically instantaneous on "sports".)
It is possible to create views with substring (field.name,1,maxlength) option and use PUB2.viewname instead pub.tablename
DROP VIEW PUB2."accounts";
CREATE VIEW PUB2."accounts" (
"ACC-TYPE",
"ACCOUNT-NAME",
ANALITIC,
ARCH,
COUNT1,
CURRENCY,
PLAN,
QUANTITY,
"RID-ANOBJECT",
"RID-APP",
TRANSIT )
AS select "acc-type",
SUBSTRING("account-name", 1, 130),
"analitic",
"arch",
"count1",
"currency",
"plan",
"quantity",
"rid-anobject",
"rid-app",
"transit"
FROM PUB."accounts";
COMMIT;
use sqlexp for automatic creation:
sqlexp account -H localhost -S ' + db-port + ' -user sysprogress -password sysprogress -infile recreateSQLviews.sql -outfile recreateSQLviews.log
here is code:
def var num-port as integer.
for first _Servers where _Servers._Server-Type = "Login" no-lock:
num-port = _Servers._Server-PortNum.
end.
if num-port < 0 then num-port = num-port + 65536.
if num-port = 0 then do:
message "Define -S parameter for Database" view-as alert-box.
RETURN.
end.
message num-port.
/* ttSQLWidth table: SQL WIDTH for all tables */
def var execstr as char.
def var rez-str as char.
def var db-port as char. /* -S port */
db-port = STRING(num-port).
DEFINE TEMP-TABLE ttSQLWidth NO-UNDO
FIELD tableName AS CHARACTER
FIELD tableNum AS INTEGER
FIELD fieldName AS CHARACTER
FIELD sqlWidth AS INTEGER
FIELD requireFix AS LOGICAL INIT FALSE
FIELD actualWidth AS INTEGER
FIELD newWidth AS INTEGER
INDEX tableNum tableNum
INDEX tableName tableName.
FOR EACH _File NO-LOCK WHERE _Tbl-Type = "T":
FOR EACH _Field OF _File WHERE _Field._Data-type = "character":
if _field._extent > 0 then next.
CREATE ttSQLWidth.
ASSIGN tableName = _File._File-name
tableNum = _File._File-num
fieldName = _Field._Field-name
sqlWidth = _Field._Width.
RELEASE ttSQLWidth.
END. /* FOR EACH _Field */
END. /* FOR EACH _File */
DEFINE VARIABLE bTab AS HANDLE NO-UNDO.
DEFINE VARIABLE hQuery AS HANDLE NO-UNDO.
DEFINE VARIABLE queryString AS CHARACTER NO-UNDO.
FOR EACH ttSQLWidth:
CREATE BUFFER bTab FOR TABLE tableName.
CREATE QUERY hQuery.
hQuery:ADD-BUFFER(bTab).
message tablename.
queryString = "FOR EACH " + tableName + " WHERE LENGTH(" + fieldName + ") >= " + STRING(sqlWidth) + " BY LENGTH(" + fieldName + ") DESC".
hQuery:QUERY-PREPARE(queryString).
hQuery:QUERY-OPEN().
IF hQuery:GET-NEXT() THEN DO:
ASSIGN actualWidth = LENGTH(bTab:BUFFER-FIELD(fieldName):BUFFER-VALUE)
requireFix = TRUE.
END. /* IF .. THEN DO */
hQuery:QUERY-CLOSE.
DELETE OBJECT hQuery.
bTab:BUFFER-RELEASE().
DELETE OBJECT bTab.
END. /* FOR EACH ttSQLWidth */
def var add-pr as integer initial 10. /* % from max */
def var maxWidth as integer initial 249. /* maxwidth */
FOR EACH ttSQLWidth WHERE ttSQLWidth.requireFix = TRUE:
ttSQLWidth.newWidth = TRUNCATE ( (ttSQLWidth.actualWidth + add-pr) / add-pr, 0 ) * add-pr.
ttSQLWidth.newWidth = INTEGER( ttSQLWidth.newWidth).
if ttSQLWidth.newWidth > maxWidth then ttSQLWidth.newWidth = maxWidth.
END.
/* sql script generation */
OUTPUT TO value("recreateSQLviews.sql").
def var lst-field as char.
FOR EACH ttSQLWidth WHERE BREAK BY ttSQLWidth.tableName:
IF FIRST-OF(ttSQLWidth.tableName)
THEN run MakeSQLViews(ttSQLWidth.tableName).
END.
OUTPUT CLOSE.
/* sql script execution */
execstr = 'sqlexp account -H localhost -S ' + db-port + ' -user sysprogress -password sysprogress -infile recreateSQLviews.sql -outfile recreateSQLviews.log'.
input through value(execstr).
repeat:
IMPORT UNFORMAT rez-str.
message rez-str.
end.
INPUT CLOSE.
RETURN.
PROCEDURE MakeSQLViews:
define input parameter tableName as character.
def var str_tmp as char.
def var str_tmp1 as char.
def var str as char initial "count,sum,double,row,date,level,area,number,primary".
def var fieldName as char.
def var fieldName1 as char.
FOR EACH _file WHERE _file._file-name = tableName AND
_file._file-num GT 0 AND _file._file-num LT 32000 NO-LOCK:
fieldName = "".
FOR EACH _Field OF _File NO-LOCK:
str_tmp = '"' + _Field._Field-name + '"'.
FOR FIRST ttSQLWidth where ttSQLWidth.tableName = _file._file-name and
ttSQLWidth.fieldName = _Field._Field-name and
ttSQLWidth.requireFix = TRUE:
str_tmp = 'SUBSTRING("' + _Field._Field-name + '", 1, ' + STRING(ttSQLWidth.newWidth) + ')'.
END.
fieldName = fieldName + (IF(fieldName = "") THEN ("") ELSE ("," + chr(10) + chr(9))) + str_tmp.
str_tmp1 = ( IF ( INDEX ( _Field._Field-name, "-" ) = 0 )
THEN ( _Field._Field-name )
ELSE ( '"' + _Field._Field-name + '"' )).
if LOOKUP ( _Field._Field-name, str, "," ) > 0 then str_tmp1 = '"' + _Field._Field-name + '"'.
fieldName1 = fieldName1 + (IF(fieldName1 = "") THEN ("") ELSE ("," + chr(10) + chr(9))) + UPPER(str_tmp1).
END. /* FOR EACH _Field */
PUT UNFORMATTED 'DROP VIEW PUB2."' + _file._file-name + '";' SKIP.
PUT UNFORMATTED 'CREATE VIEW PUB2."' + _file._file-name + '" ( ' + chr(10) chr(9) + fieldName1 + ' ) ' + chr(10) +
'AS select ' + fieldName + chr(10) +
'FROM PUB."' + _file._file-name + '";' SKIP.
PUT UNFORMATTED 'COMMIT;' SKIP(1).
END.
END.