messages
listlengths
1
1
topic
stringlengths
2
60
[ { "date": "2013-08-04", "forum": "FiveWin for Harbour/xHarbour", "text": "Please see the post of Mr James Bott here\n<!-- l --><a class=\"postlink-local\" href=\"http://forums.fivetechsupport.com/viewtopic.php?f=3&t=26787&p=149225&hilit=persisting+data#p149225\">viewtopic.php?f=3&t=26787&p=149225&hilit=persisting+data#p149225</a><!-- l -->\n\nPlease also see MSDN Article about Persisting recordsets on local disk\n[url:2m3m1qmi]http&#58;//msdn&#46;microsoft&#46;com/en-us/library/windows/desktop/ms675273(v=vs&#46;85)&#46;aspx[/url:2m3m1qmi]\n\nWe can read recordset(s) from a remote server, save them locally and disconnect from the server. We can continue to work with the saved recordset(s) and if we make any modifications we can upload the modifications to the Server, when we next connect to server.\nThis feature is useful in remote locations where connectivity to main server is not reliable and need for update data is minimal.\n\nThis example shows how to use this feature. Experts in ADO who are wellversed with this feature need to read no further. This post is intended for starters of ADO and those who are not familiar with this feature.\n\nThis example does not use the FW_ ADO functions and users without these functions also can test this example.\n(This example uses only FW_CreateMDB function. If you do not have that function, you may use an alternative or use an exsisting MDB)\n\nThis example\n1. Creates a new MDB with a Table\n2. Connects to MDB, Opens the table in a recordset and displays in browse\n3. Saves the recordset locally. closes connection and renakes MDB as MDD. This is to sumulate non-availability of the server.\n4.and 5: Uses the local recordset to edit and add records locally\n6. Renaems MDD to MDB, Connects to Database and attaches the connection object to our local recordset Then all changes in the local recordset are UPLOADED to the Server.\n7. View the table on the server to confirm uploading all changes.\n\nPlease compile the program as it is and un in any folder you like.\nFor each step the program explains the stage of the program. It is better you keep the source code open and watch the same along with each step executed by the program.\n[code=fw:2m3m1qmi]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\"><span style=\"color: #B900B9;\">/*<br />*<br />*  AdoSave.prg<br />*  Aug 02-2013 12:12 AM<br />*<br />*/</span><br /><br /><span style=\"color: #00D7D7;\">#include</span> <span style=\"color: #ff0000;\">\"FiveWin.Ch\"</span><br /><span style=\"color: #00D7D7;\">#include</span> <span style=\"color: #ff0000;\">\"adodef.ch\"</span><br /><span style=\"color: #00D7D7;\">#include</span> <span style=\"color: #ff0000;\">\"xbrowse.ch\"</span><br /><span style=\"color: #00D7D7;\">#include</span> <span style=\"color: #ff0000;\">\"hbcompat.ch\"</span><br /><br /><span style=\"color: #00C800;\">static</span> cPath, cMdb, cBak, cDat, cStr<br /><br /><span style=\"color: #B900B9;\">//----------------------------------------------------------------------------//</span><br /><br /><span style=\"color: #00C800;\">function</span> Main<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span><br /><br />   <span style=\"color: #00C800;\">local</span> oCn, oRs<br /><br />   SET DATE ITALIAN<br />   SET CENTURY <span style=\"color: #0000ff;\">ON</span><br />   XbrNumFormat<span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">'A'</span>, .t. <span style=\"color: #000000;\">&#41;</span><br />   SetGetColorFocus<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span><br />   <span style=\"color: #B900B9;\">//</span><br />   cPath    := cFilePath<span style=\"color: #000000;\">&#40;</span> ExeName<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span> <span style=\"color: #000000;\">&#41;</span><br />   cMdb     := <span style=\"color: #ff0000;\">\"tutor02.mdb\"</span><br />   cBak     := cFileSetExt<span style=\"color: #000000;\">&#40;</span> cMdb, <span style=\"color: #ff0000;\">\"mdd\"</span> <span style=\"color: #000000;\">&#41;</span><br />   cDat     := cFileSetExt<span style=\"color: #000000;\">&#40;</span> cMdb, <span style=\"color: #ff0000;\">\"dat\"</span> <span style=\"color: #000000;\">&#41;</span><br />   cStr     := <span style=\"color: #ff0000;\">\"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"</span> + cPath + cMdb + <span style=\"color: #ff0000;\">\";\"</span><br /><br /><span style=\"color: #B900B9;\">//----------------------------------------------------------------------------//</span><br /><span style=\"color: #B900B9;\">// STEP-1: Create New Database TUTOR02.MDB and create a table DLYCLN</span><br /><span style=\"color: #B900B9;\">//----------------------------------------------------------------------------//</span><br /><br />   <span style=\"color: #0000ff;\">MsgInfo</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"Step-1\"</span> + CRLF + <span style=\"color: #ff0000;\">\"Create new mdb database: \"</span> + cMdb <span style=\"color: #000000;\">&#41;</span><br />   CreateNewDatabase<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span><br />   <span style=\"color: #0000ff;\">MsgInfo</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"Data base '\"</span> + cMdb + <span style=\"color: #ff0000;\">\"' and table 'DLYCLN' created.\"</span> <span style=\"color: #000000;\">&#41;</span><br /><br /><span style=\"color: #B900B9;\">//----------------------------------------------------------------------------//</span><br /><span style=\"color: #B900B9;\">// STEP-2: OPEN TABLE \"DLYCLN\" in the database and show contents</span><br /><span style=\"color: #B900B9;\">//----------------------------------------------------------------------------//</span><br /><br />   <span style=\"color: #0000ff;\">MsgInfo</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"Step-2\"</span> + CRLF + <span style=\"color: #ff0000;\">\"Opening recordset of DLYCLN table\"</span> <span style=\"color: #000000;\">&#41;</span><br />   oRs      := CreateObject<span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"ADODB.RecordSet\"</span> <span style=\"color: #000000;\">&#41;</span><br />   oRs:<span style=\"color: #000000;\">CursorLocation</span>   := adUseClient<br />   oRs:<span style=\"color: #000000;\">Open</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"DLYCLN\"</span>, cStr, adOpenStatic, adLockBatchOptimistic, adCmdTable <span style=\"color: #000000;\">&#41;</span><br />   xbrowser oRs <span style=\"color: #0000ff;\">TITLE</span> cMdb + <span style=\"color: #ff0000;\">\":DLYCLN\"</span><br /><br /><span style=\"color: #B900B9;\">//----------------------------------------------------------------------------//</span><br /><span style=\"color: #B900B9;\">// STEP-3: SAVE RECORDSET TO LOCAL DISK, CLOSE RECORDSET AND CONNECTION TO DATABASE</span><br /><span style=\"color: #B900B9;\">//         RENAME THE MDB AS MDD, SO THAT WE CAN NOT CONNECT TO THE DATABASE</span><br /><span style=\"color: #B900B9;\">//         THIS IS TO SIMULATE NON-AVAILABILITY OF SERVER</span><br /><span style=\"color: #B900B9;\">//----------------------------------------------------------------------------//</span><br /><br />   <span style=\"color: #0000ff;\">MsgInfo</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"Step-3: Saving RecordSet Locally as \"</span> + cDat + CRLF + <span style=\"color: #ff0000;\">\"Syntax: oRs:Save( cDat, 0 )\"</span> <span style=\"color: #000000;\">&#41;</span><br />   <span style=\"color: #00C800;\">if</span> File<span style=\"color: #000000;\">&#40;</span> cDat <span style=\"color: #000000;\">&#41;</span>; FErase<span style=\"color: #000000;\">&#40;</span> cDat <span style=\"color: #000000;\">&#41;</span>; <span style=\"color: #00C800;\">endif</span><br />   oRs:<span style=\"color: #000000;\">Save</span><span style=\"color: #000000;\">&#40;</span> cDat, <span style=\"color: #000000;\">0</span> <span style=\"color: #000000;\">&#41;</span><br />   <span style=\"color: #0000ff;\">MsgInfo</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"Record Set saved as: \"</span> + cDat <span style=\"color: #000000;\">&#41;</span><br />   <span style=\"color: #0000ff;\">MsgInfo</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"Closing Connection\"</span> <span style=\"color: #000000;\">&#41;</span><br />   oRs:<span style=\"color: #000000;\">Close</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span><br />   oRs := <span style=\"color: #00C800;\">nil</span><br />   <span style=\"color: #0000ff;\">MsgInfo</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"Renaming \"</span> + cMdb + <span style=\"color: #ff0000;\">\" as \"</span> + cBak + CRLF + ;<br />      <span style=\"color: #ff0000;\">\"This is equivalent to not having connection with Server\"</span> <span style=\"color: #000000;\">&#41;</span><br />   ? FRename<span style=\"color: #000000;\">&#40;</span> cMdb, cBak <span style=\"color: #000000;\">&#41;</span><br />   <span style=\"color: #0000ff;\">MsgInfo</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"Now we can not connect to Database \"</span> + cMdb <span style=\"color: #000000;\">&#41;</span><br /><br /><span style=\"color: #B900B9;\">//----------------------------------------------------------------------------//</span><br /><span style=\"color: #B900B9;\">// STEP-4: OPEN LOCALLY SAVED FILE AS RECORDSET WITHOUT CONNECTING TO ANY DATABASE</span><br /><span style=\"color: #B900B9;\">//         AND EDIT THE TABLE IN XBROWSE AND SAVE CHANGES LOCALLY</span><br /><span style=\"color: #B900B9;\">//----------------------------------------------------------------------------//</span><br /><br />   <span style=\"color: #0000ff;\">MsgInfo</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"Step-4\"</span> + CRLF + <span style=\"color: #ff0000;\">\"Now we open locally saved RecSet without any connection\"</span> + CRLF + ;<br />            <span style=\"color: #ff0000;\">\"You may edit any data inline\"</span> <span style=\"color: #000000;\">&#41;</span><br />   oRs      := CreateObject<span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"ADODB.RecordSet\"</span> <span style=\"color: #000000;\">&#41;</span><br />   oRs:<span style=\"color: #000000;\">CursorLocation</span>   := adUseClient<br />#ifdef __XHARBOUR__<br />   oRs:<span style=\"color: #000000;\">Open</span><span style=\"color: #000000;\">&#40;</span> cDat, OleDefaultArg<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span>, adOpenStatic, adLockBatchOptimistic, adCmdFile <span style=\"color: #000000;\">&#41;</span><br />#else<br />   oRs:<span style=\"color: #000000;\">Source</span>     := cDat<br />   oRs:<span style=\"color: #000000;\">LockType</span>   := adLockBatchOptimistic<br />   oRs:<span style=\"color: #000000;\">Open</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span><br />#endif<br /><br />   xbrowser oRs <span style=\"color: #0000ff;\">TITLE</span> <span style=\"color: #ff0000;\">\"localcopy:DLYCLN (fastedit mode)\"</span> FASTEDIT  SETUP ;<br />      <span style=\"color: #000000;\">&#40;</span> oBrw:<span style=\"color: #000000;\">bSaveData</span> := <span style=\"color: #000000;\">&#123;</span> || .t. <span style=\"color: #000000;\">&#125;</span> <span style=\"color: #000000;\">&#41;</span><br />   oRs:<span style=\"color: #000000;\">Save</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span><br />   oRs:<span style=\"color: #000000;\">Close</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span><br /><br /><span style=\"color: #B900B9;\">//----------------------------------------------------------------------------//</span><br /><span style=\"color: #B900B9;\">// STEP-5: RE-OPEN LOCALLY SAVED FILE AS RECORDSET WITHOUT CONNECTING TO ANY DATABASE</span><br /><span style=\"color: #B900B9;\">//         ADD TWO NEW ROWS</span><br /><span style=\"color: #B900B9;\">//         AND EDIT THE TABLE IN XBROWSE AND SAVE CHANGES LOCALLY</span><br /><span style=\"color: #B900B9;\">//----------------------------------------------------------------------------//</span><br /><br />   <span style=\"color: #0000ff;\">MsgInfo</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"Step-5: Saved and closed. Reopening Again\"</span> <span style=\"color: #000000;\">&#41;</span><br /><br />   oRs      := CreateObject<span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"ADODB.RecordSet\"</span> <span style=\"color: #000000;\">&#41;</span><br />   oRs:<span style=\"color: #000000;\">CursorLocation</span>   := adUseClient<br />#ifdef __XHARBOUR__<br />   oRs:<span style=\"color: #000000;\">Open</span><span style=\"color: #000000;\">&#40;</span> cDat, OleDefaultArg<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span>, adOpenStatic, adLockBatchOptimistic, adCmdFile <span style=\"color: #000000;\">&#41;</span><br />#else<br />   oRs:<span style=\"color: #000000;\">Source</span>     := cDat<br />   oRs:<span style=\"color: #000000;\">LockType</span>   := adLockBatchOptimistic<br />   oRs:<span style=\"color: #000000;\">Open</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span><br />#endif<br />   <span style=\"color: #0000ff;\">MsgInfo</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"Adding two new rows to the local copy\"</span> <span style=\"color: #000000;\">&#41;</span><br /><br />   oRs:<span style=\"color: #000000;\">AddNew</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #000000;\">&#123;</span> <span style=\"color: #ff0000;\">\"WDAY\"</span>, <span style=\"color: #ff0000;\">\"COLN\"</span> <span style=\"color: #000000;\">&#125;</span>, <span style=\"color: #000000;\">&#123;</span> <span style=\"color: #ff0000;\">\"FriDay\"</span>, <span style=\"color: #000000;\">800</span> <span style=\"color: #000000;\">&#125;</span> <span style=\"color: #000000;\">&#41;</span><br />   oRs:<span style=\"color: #000000;\">AddNew</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #000000;\">&#123;</span> <span style=\"color: #ff0000;\">\"WDAY\"</span>, <span style=\"color: #ff0000;\">\"COLN\"</span> <span style=\"color: #000000;\">&#125;</span>, <span style=\"color: #000000;\">&#123;</span> <span style=\"color: #ff0000;\">\"SaturDay\"</span>, <span style=\"color: #000000;\">800</span> <span style=\"color: #000000;\">&#125;</span> <span style=\"color: #000000;\">&#41;</span><br /><br />   xbrowser oRs <span style=\"color: #0000ff;\">TITLE</span> <span style=\"color: #ff0000;\">\"localcopy:DLYCLN (fastedit mode)\"</span>  FASTEDIT  SETUP ;<br />      <span style=\"color: #000000;\">&#40;</span> oBrw:<span style=\"color: #000000;\">bSaveData</span> := <span style=\"color: #000000;\">&#123;</span> || .t. <span style=\"color: #000000;\">&#125;</span> <span style=\"color: #000000;\">&#41;</span><br />   oRs:<span style=\"color: #000000;\">Save</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span><br /><br /><span style=\"color: #B900B9;\">//----------------------------------------------------------------------------//</span><br /><span style=\"color: #B900B9;\">// STEP-6: NOW WE RENAME THE MDD AS MDB. THE DATABASE IS AVAILABLE TO CONNECT</span><br /><span style=\"color: #B900B9;\">//         WE CONNECT TO THE DATABASE AND ATTACH OUR LOCAL RECSET TO THE CONNECTION</span><br /><span style=\"color: #B900B9;\">//         UPLOAD LOCAL CHANGES TO THE DATABASE, DELETE LOCAL FILE</span><br /><span style=\"color: #B900B9;\">//----------------------------------------------------------------------------//</span><br /><br />   <span style=\"color: #0000ff;\">MsgInfo</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"Step-6\"</span> + CRLF + <span style=\"color: #ff0000;\">\"Now we rename \"</span> + cBak + <span style=\"color: #ff0000;\">\" to \"</span> + cMdb + CRLF + ;<br />      <span style=\"color: #ff0000;\">\"Connect to Database and Upload local changes to Main DataBase\"</span> <span style=\"color: #000000;\">&#41;</span><br /><br />   ? FRename<span style=\"color: #000000;\">&#40;</span> cBak, cMdb <span style=\"color: #000000;\">&#41;</span><br />   <span style=\"color: #0000ff;\">MsgInfo</span><span style=\"color: #000000;\">&#40;</span> cMdb + <span style=\"color: #ff0000;\">\" now available. Connecting\"</span> <span style=\"color: #000000;\">&#41;</span><br />   oCn   := CreateObject<span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"ADODB.Connection\"</span> <span style=\"color: #000000;\">&#41;</span><br />   oCn:<span style=\"color: #000000;\">CursorLocation</span>   := adUseClient<br />   oCn:<span style=\"color: #000000;\">Open</span><span style=\"color: #000000;\">&#40;</span> cStr <span style=\"color: #000000;\">&#41;</span><br />   <span style=\"color: #0000ff;\">MsgInfo</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"Connected to Database. Connecting Local RecSet to Database\"</span> + CRLF + ;<br />            <span style=\"color: #ff0000;\">\"Syntax: oRs:ActiveConnection := oCn\"</span> <span style=\"color: #000000;\">&#41;</span><br />   oRs:<span style=\"color: #000000;\">ActiveConnection</span> := oCn<br />   <span style=\"color: #0000ff;\">MsgInfo</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"Now our recordset is connected to database\"</span> + CRLF + ;<br />            <span style=\"color: #ff0000;\">\"We shall upload changes. Syntax: oRs:UpdateBatch()\"</span> <span style=\"color: #000000;\">&#41;</span><br />   oRs:<span style=\"color: #000000;\">UpdateBatch</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span><br />   <span style=\"color: #0000ff;\">MsgInfo</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"Uploaded. Now we close RecSet & Connection\"</span> <span style=\"color: #000000;\">&#41;</span><br /><br />   oRs:<span style=\"color: #000000;\">Close</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span><br />   oCn:<span style=\"color: #000000;\">Close</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span><br />   oRs := oCn := <span style=\"color: #00C800;\">nil</span><br />   ? FErase<span style=\"color: #000000;\">&#40;</span> cDat <span style=\"color: #000000;\">&#41;</span><br /><br /><span style=\"color: #B900B9;\">//----------------------------------------------------------------------------//</span><br /><span style=\"color: #B900B9;\">// STEP-7: NOW WE CONNECT TO DATABASE NORMALLY, OPEN TABLE IN THE DATABASE</span><br /><span style=\"color: #B900B9;\">//         TO CONFIRM THAT ALL CHANGES ARE PRESENT IN THE DATABASE</span><br /><span style=\"color: #B900B9;\">//----------------------------------------------------------------------------//</span><br /><br />   <span style=\"color: #0000ff;\">MsgInfo</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"Step-7: Now we open the table in the database and\"</span> + CRLF + <span style=\"color: #ff0000;\">\"verify if all changes are uploaded\"</span> <span style=\"color: #000000;\">&#41;</span><br /><br />   oRs   := CreateObject<span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"ADODB.RecordSet\"</span> <span style=\"color: #000000;\">&#41;</span><br />   oRs:<span style=\"color: #000000;\">CursorLocation</span>   := adUseClient<br />   oRs:<span style=\"color: #000000;\">Open</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"DLYCLN\"</span>, cStr, adOpenStatic, adLockBatchOptimistic, adCmdTable <span style=\"color: #000000;\">&#41;</span><br />   xbrowser oRs<br /><br />   <span style=\"color: #0000ff;\">MsgInfo</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"All Done.\"</span> + CRLF +  <span style=\"color: #ff0000;\">\"Cleaning Up\"</span> <span style=\"color: #000000;\">&#41;</span><br />   oRs:<span style=\"color: #000000;\">Close</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span><br />   oRs   := <span style=\"color: #00C800;\">nil</span><br /><br /><span style=\"color: #00C800;\">return</span> <span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">0</span><span style=\"color: #000000;\">&#41;</span><br /><br /><span style=\"color: #B900B9;\">//----------------------------------------------------------------------------//</span><br /><br /><span style=\"color: #00C800;\">static</span> <span style=\"color: #00C800;\">function</span> CreateNewDatabase<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span><br /><br />   <span style=\"color: #00C800;\">local</span> cSql, oCn, n<br />   <span style=\"color: #00C800;\">local</span> aData := <span style=\"color: #000000;\">&#123;</span> <span style=\"color: #000000;\">&#123;</span> <span style=\"color: #ff0000;\">\"MonDay\"</span>, <span style=\"color: #000000;\">40</span> <span style=\"color: #000000;\">&#125;</span>, <span style=\"color: #000000;\">&#123;</span> <span style=\"color: #ff0000;\">\"TuesDay\"</span>, <span style=\"color: #000000;\">50</span> <span style=\"color: #000000;\">&#125;</span>, <span style=\"color: #000000;\">&#123;</span> <span style=\"color: #ff0000;\">\"WednesDay\"</span>, <span style=\"color: #000000;\">60</span> <span style=\"color: #000000;\">&#125;</span> <span style=\"color: #000000;\">&#125;</span><br /><br />   <span style=\"color: #00C800;\">if</span> File<span style=\"color: #000000;\">&#40;</span> cMdb <span style=\"color: #000000;\">&#41;</span><br />      FErase<span style=\"color: #000000;\">&#40;</span> cMdb <span style=\"color: #000000;\">&#41;</span><br />   <span style=\"color: #00C800;\">endif</span><br />   <span style=\"color: #00C800;\">if</span> File<span style=\"color: #000000;\">&#40;</span> cBak <span style=\"color: #000000;\">&#41;</span><br />      FErase<span style=\"color: #000000;\">&#40;</span> cBak <span style=\"color: #000000;\">&#41;</span><br />   <span style=\"color: #00C800;\">endif</span><br />   FW_CreateMDB<span style=\"color: #000000;\">&#40;</span> cMdb <span style=\"color: #000000;\">&#41;</span><br /><br />   <span style=\"color: #0000ff;\">TEXT</span> INTO cSql<br />   CREATE TABLE DLYCLN <span style=\"color: #000000;\">&#40;</span><br />   <span style=\"color: #0000ff;\">ID</span> AUTOINCREMENT PRIMARY KEY,<br />   WDAY VARCHAR<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">20</span><span style=\"color: #000000;\">&#41;</span>,<br />   COLN MONEY<br />   <span style=\"color: #000000;\">&#41;</span><br />   ENDTEXT<br /><br />   oCn   := CreateObject<span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"ADODB.Connection\"</span> <span style=\"color: #000000;\">&#41;</span><br />   oCn:<span style=\"color: #000000;\">CursorLocation</span>   := adUseClient<br />   oCn:<span style=\"color: #000000;\">Open</span><span style=\"color: #000000;\">&#40;</span> cStr <span style=\"color: #000000;\">&#41;</span><br />   oCn:<span style=\"color: #000000;\">Execute</span><span style=\"color: #000000;\">&#40;</span> cSql <span style=\"color: #000000;\">&#41;</span><br /><br />   <span style=\"color: #00C800;\">for</span> n := <span style=\"color: #000000;\">1</span> <span style=\"color: #0000ff;\">to</span> Len<span style=\"color: #000000;\">&#40;</span> aData <span style=\"color: #000000;\">&#41;</span><br />      cSql  := <span style=\"color: #ff0000;\">\"INSERT INTO DLYCLN ( WDAY, COLN ) VALUES ( '\"</span> + ;<br />               aData<span style=\"color: #000000;\">&#91;</span> n, <span style=\"color: #000000;\">1</span> <span style=\"color: #000000;\">&#93;</span> + <span style=\"color: #ff0000;\">\"',\"</span> + cValToChar<span style=\"color: #000000;\">&#40;</span> aData<span style=\"color: #000000;\">&#91;</span> n, <span style=\"color: #000000;\">2</span> <span style=\"color: #000000;\">&#93;</span> <span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">\" )\"</span><br />      oCn:<span style=\"color: #000000;\">Execute</span><span style=\"color: #000000;\">&#40;</span> cSql <span style=\"color: #000000;\">&#41;</span><br />   <span style=\"color: #00C800;\">next</span> n<br />   oCn:<span style=\"color: #000000;\">Close</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span><br />   oCn   := <span style=\"color: #00C800;\">nil</span><br /><br /><span style=\"color: #00C800;\">return</span> <span style=\"color: #00C800;\">nil</span><br /><br /><span style=\"color: #B900B9;\">//----------------------------------------------------------------------------//</span><br /> </div>[/code:2m3m1qmi]", "time": "09:10", "topic": "ADO RecordSet: Working locally without connecting to Server", "username": "nageswaragunupudi" } ]
ADO RecordSet: Working locally without connecting to Server
[ { "date": "2013-08-04", "forum": "FiveWin for Harbour/xHarbour", "text": "Mr. Rao:\n\nThanks a lot for your aportation, with the RecordSet's GetRows() method can you get the same result?\n\nRegards", "time": "16:22", "topic": "ADO RecordSet: Working locally without connecting to Server", "username": "Armando" } ]
ADO RecordSet: Working locally without connecting to Server
[ { "date": "2013-08-04", "forum": "FiveWin for Harbour/xHarbour", "text": "[quote=\"Armando\":1zw7te9u]Mr. Rao:\n\nThanks a lot for your aportation, with the RecordSet's GetRows() method can you get the same result?\n\nRegards[/quote:1zw7te9u]\nWith GetRows() method you can read the recordset into an array.\nAgreed that you can do anything with the array locally.\nYou can make modifications too.\n\nWhen you reconnect, how do you upload the changes?\nYou need to develop your own logic to identify (1) new rows inserted, (2) rows deleted and (3) rows modified and the columns in the rows that are modified.\nThen you need to develop your own logic to add those new lines, delete those rows and update the specific modified columns of the modified rows.\n\nIs all the trouble worth it? And even you do it, can you do it optimally and without errrors at all?\n\nWith the persistent recordset, you need to do only two operations:\noRs:ActiveConnection := <justopened connection object>\noRs:UpdateBatch()\n\nOfcourse you need to use TRY..CATCH for all ADO methods.\n\nYou may say that you do not want to modify the data but only want for reference. The why not GetRows() enough?\nYes but only for that session.\nWhen the user closes the application and reopens, the information in the array is lost. Till you connect to the Server you can not get the info.\n\nIn the case of persistent recordset what we do is :\n\nWhen the user starts the program\nCheck if connection to server is available.\n (i) If avaliable Synchronize local recordset with Server ( Push and Pull )\n (ii) If not, continue with the local recordset", "time": "16:29", "topic": "ADO RecordSet: Working locally without connecting to Server", "username": "nageswaragunupudi" } ]
ADO RecordSet: Working locally without connecting to Server
[ { "date": "2013-08-04", "forum": "FiveWin for Harbour/xHarbour", "text": "Let me add. Handling recordsets is more cumbersome than RDD and TData(Base)", "time": "18:52", "topic": "ADO RecordSet: Working locally without connecting to Server", "username": "nageswaragunupudi" } ]
ADO RecordSet: Working locally without connecting to Server
[ { "date": "2013-08-04", "forum": "FiveWin for Harbour/xHarbour", "text": "Mr. Rao:\n\nThank for your comments.\n\nRegards", "time": "20:15", "topic": "ADO RecordSet: Working locally without connecting to Server", "username": "Armando" } ]
ADO RecordSet: Working locally without connecting to Server
[ { "date": "2013-08-12", "forum": "FiveWin for Harbour/xHarbour", "text": "Mr. Rao:\n\nThanks for your works, \n\nI have a problem with \n\nMsgInfo( \"Renaming \" + cMdb + \" as \" + cBak + CRLF + ;\n \"This is equivalent to not having connection with Server\" )\n \n ? FRename( cMdb, cBak ) \n\nfrename returns -1 , this is because cMdb is still open \n\nRegards \nMaurizio", "time": "18:04", "topic": "ADO RecordSet: Working locally without connecting to Server", "username": "Maurizio" } ]
ADO RecordSet: Working locally without connecting to Server
[ { "date": "2013-08-12", "forum": "FiveWin for Harbour/xHarbour", "text": "[quote:2wj2y3g8]? FRename( cMdb, cBak ) \n\nfrename returns -1 , this is because cMdb is still open \n[/quote:2wj2y3g8]\nIf it returns -1, then renaming was not successful for whatever reason and one of such reasons could be that the mdb is not fully closed and released.\n\nIf you execute the code I posted without any changes, the connection should be closed and the renaming should be successful.\n\nThough I made this sample with access for easy testing, this principle can be tested on networks or over internet by disconnecting the net connection.", "time": "18:09", "topic": "ADO RecordSet: Working locally without connecting to Server", "username": "nageswaragunupudi" } ]
ADO RecordSet: Working locally without connecting to Server
[ { "date": "2013-08-13", "forum": "FiveWin for Harbour/xHarbour", "text": "Mr. Rao \n\nwith the FWH 13.07 revised build it works \n\nThanks \nMaurizio", "time": "07:44", "topic": "ADO RecordSet: Working locally without connecting to Server", "username": "Maurizio" } ]
ADO RecordSet: Working locally without connecting to Server
[ { "date": "2018-07-08", "forum": "FiveWin for Harbour/xHarbour", "text": "At times it may be necessary to change the data of a Recordset with totally different data from the same or different tables and even from a different connection. One way is to read the new data into a new recordset and swap with the present recordset.\n\nIt is much easier to read the different data into the same recordset in this manner:\n[code=fw:12u9yqma]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\"><br />oRs:<span style=\"color: #000000;\">Close</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span><br />oRs:<span style=\"color: #000000;\">Source</span> := cNewSQL<br />oRs:<span style=\"color: #000000;\">ActiveConnection</span> := oNewConObject<br />oRs:<span style=\"color: #000000;\">Open</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span><br /> </div>[/code:12u9yqma]\n\nIf this change is made while the recordset is being browsed, the Browse should be able to handle the change smoothly, which was not possible till FWH18.04.\n\nFWH 18.05 handles the change smoothly, as in this sample:\n[code=fw:12u9yqma]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\"><span style=\"color: #00D7D7;\">#include</span> <span style=\"color: #ff0000;\">\"fivewin.ch\"</span><br /><br /><span style=\"color: #00C800;\">function</span> Main<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span><br /><br />   <span style=\"color: #00C800;\">local</span> oCnMDB, oCnDBF, oCnFWH, oRs<br />   <span style=\"color: #00C800;\">local</span> cSqlMDB, cSqlDBF, cSqlFWH<br />   <span style=\"color: #00C800;\">local</span> oDlg, oBrw<br /><br />   oCnMDB   := FW_OpenAdoConnection<span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"c:<span style=\"color: #000000;\">\\f</span>wh<span style=\"color: #000000;\">\\s</span>amples<span style=\"color: #000000;\">\\x</span>brtest.mdb\"</span> <span style=\"color: #000000;\">&#41;</span><br />   oCnDBF   := FW_OpenAdoConnection<span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"c:<span style=\"color: #000000;\">\\f</span>wh<span style=\"color: #000000;\">\\s</span>amples<span style=\"color: #000000;\">\\\"</span> )   <br />   oCnFWH   := FW_DemoDB( \"</span>ADO<span style=\"color: #ff0000;\">\" )<br /><br />   cSqlMDB  := \"</span><span style=\"color: #0000ff;\">SELECT</span> <span style=\"color: #0000ff;\">ID</span>,FIRST,CITY,SALARY <span style=\"color: #0000ff;\">FROM</span> CUSTOMER<span style=\"color: #ff0000;\">\"<br />   cSqlDBF  := \"</span><span style=\"color: #0000ff;\">SELECT</span> * <span style=\"color: #0000ff;\">FROM</span> STATES<span style=\"color: #ff0000;\">\"<br />   cSqlFWH  := \"</span><span style=\"color: #0000ff;\">SELECT</span> * <span style=\"color: #0000ff;\">FROM</span> annual<span style=\"color: #ff0000;\">\"<br /><br />   oRs      := FW_OpenRecordSet( oCnMDB, cSqlMDB )<br /><br />   DEFINE DIALOG oDlg SIZE 700,400 PIXEL TRUEPIXEL<br /><br />   @ 60, 20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;<br />      DATASOURCE oRs AUTOCOLS ;<br />      CELL LINES NOBORDER<br />   oBrw:CreateFromCode()<br /><br />   @ 10, 20 BTNBMP PROMPT \"</span>ADO-MDB<span style=\"color: #ff0000;\">\" SIZE 100,30 PIXEL OF oDlg FLAT ;<br />      ACTION ReadNewData( oBrw, cSqlMDB, oCnMDB )<br /><br />   @ 10,140 BTNBMP PROMPT \"</span>ADO-DBF<span style=\"color: #ff0000;\">\" SIZE 100,30 PIXEL OF oDlg FLAT ;<br />      ACTION ReadNewData( oBrw, cSqlDBF, oCnDBF )<br /><br />   @ 10,260 BTNBMP PROMPT \"</span>ADO-MYSQL<span style=\"color: #ff0000;\">\" SIZE 100,30 PIXEL OF oDlg FLAT ;<br />      ACTION ReadNewData( oBrw, cSqlFWH, oCnFWH )<br /><br />   ACTIVATE DIALOG oDlg CENTERED ON INIT oBrw:SetFocus()<br /><br />   oCnMDB:Close()<br />   oCnDBF:Close()<br />   oCnFWH:Close()<br /><br />return nil<br /><br />function ReadNewData( oBrw, cSql, oCn )<br /><br />   WITH OBJECT oBrw:oRs<br />      :Close()<br />      :Source           := cSql<br />      :ActiveConnection := oCn<br />      CursorWait()<br />      :Open()<br />   END<br />   WITH OBJECT oBrw<br />      :SetADO( oBrw:oRs, .t. )<br />      :SetFocus()<br />   END<br /><br />return nil<br /></span></div>[/code:12u9yqma]\n\n[url=https&#58;//imageshack&#46;com/i/pmSKHdLCg:12u9yqma][img:12u9yqma]https&#58;//imageshack&#46;com/a/img922/1616/SKHdLC&#46;gif[/img:12u9yqma][/url:12u9yqma]", "time": "13:26", "topic": "ADO RecordSets - Change SQL & Con at Runtime", "username": "nageswaragunupudi" } ]
ADO RecordSets - Change SQL & Con at Runtime
[ { "date": "2018-07-09", "forum": "FiveWin for Harbour/xHarbour", "text": "Very impressive <!-- s:-) --><img src=\"{SMILIES_PATH}/icon_smile.gif\" alt=\":-)\" title=\"Smile\" /><!-- s:-) -->\n\nGreat capabilities for the new FWH 18.05 <!-- s;-) --><img src=\"{SMILIES_PATH}/icon_wink.gif\" alt=\";-)\" title=\"Wink\" /><!-- s;-) -->", "time": "06:09", "topic": "ADO RecordSets - Change SQL & Con at Runtime", "username": "Antonio Linares" } ]
ADO RecordSets - Change SQL & Con at Runtime
[ { "date": "2006-08-11", "forum": "FiveWin for Harbour/xHarbour", "text": "Hi guys\n\nWhere I can find more information about ADO Recordset methods and properties like RecordCount(), fields etc\n\nThanks", "time": "23:37", "topic": "ADO Recordset Methods", "username": "wpacheco" } ]
ADO Recordset Methods
[ { "date": "2006-08-12", "forum": "FiveWin for Harbour/xHarbour", "text": "On MSDN.\n\nEMG", "time": "10:50", "topic": "ADO Recordset Methods", "username": "Enrico Maria Giordano" } ]
ADO Recordset Methods
[ { "date": "2006-08-12", "forum": "FiveWin for Harbour/xHarbour", "text": "Thanks Enrico", "time": "12:25", "topic": "ADO Recordset Methods", "username": "wpacheco" } ]
ADO Recordset Methods
[ { "date": "2015-06-24", "forum": "FiveWin for Harbour/xHarbour", "text": "Dear Sir(s)\n\nI have one table in sql database. if USER1 is browsing ARTICLE\ntable and make some changes, how to to update/visible USER2 browse with the\nsame change?\n\nSomething like dbf. when we change records it update to every where.\n\n\n\nRegards\nYunus.", "time": "15:11", "topic": "ADO SQL VISIBILITY", "username": "dagiayunus" } ]
ADO SQL VISIBILITY
[ { "date": "2015-06-24", "forum": "FiveWin for Harbour/xHarbour", "text": "You can use:\n\nCursorLocation := adUseServer\nCursorType := adOpenDynamic\n\nPros:\nSelects without where clause much faster because you dont load immediately all records\nYou'll see new adds deletes changes by others. You will always have the last info version.\n\nCons:\nNavigation slower and server overload higher\nMany Dbs do not supported so you might get it through the ODBC OLedb driver. \nThis means all navigation is transformed into queries by the driver itself delaying everything.\nIn Mysql you'll need a column to be used as recno\nServers that supported might be better.\n\nNever tried adUseServer without a server supporting it.", "time": "18:19", "topic": "ADO SQL VISIBILITY", "username": "AHF" } ]
ADO SQL VISIBILITY
[ { "date": "2015-06-24", "forum": "FiveWin for Harbour/xHarbour", "text": "Yunus,\n\nAs far as I know, there is no way other than redoing the query.\n\nEMG", "time": "17:21", "topic": "ADO SQL VISIBILITY", "username": "Enrico Maria Giordano" } ]
ADO SQL VISIBILITY
[ { "date": "2015-06-24", "forum": "FiveWin for Harbour/xHarbour", "text": "Dagia\n\nYou can put a few well placed oRs:ReQuery() to re-fresh each workstation .. Generally you can place a :ReQuery() between screens which should keep each workstation in sync. .. again, SQL workstation visibility is an art-form and takes a fairly savvy programming imagination to keep them in sync.\n\nRick Lipkin", "time": "19:35", "topic": "ADO SQL VISIBILITY", "username": "Rick Lipkin" } ]
ADO SQL VISIBILITY
[ { "date": "2015-06-25", "forum": "FiveWin for Harbour/xHarbour", "text": "Dear EMG, AHF & RICK LIPKIN\n\nThanks for the valuable information. \n\nThanks & Regards", "time": "15:20", "topic": "ADO SQL VISIBILITY", "username": "dagiayunus" } ]
ADO SQL VISIBILITY
[ { "date": "2015-06-26", "forum": "FiveWin for Harbour/xHarbour", "text": "[quote:297kcfmu]SQL workstation visibility is an art-form and takes a fairly savvy programming imagination to keep them in sync.[/quote:297kcfmu]\nYes.", "time": "08:12", "topic": "ADO SQL VISIBILITY", "username": "nageswaragunupudi" } ]
ADO SQL VISIBILITY
[ { "date": "2015-06-26", "forum": "FiveWin for Harbour/xHarbour", "text": "Severside queries (RecordSet with adUseServer) are *mostly* unidirectional and single pass, used mainly for fast single pass processing. Even this is not generally desirable and may result in wrong results because we lose the benefit of snap-shot query benefits.\n\nWhat we mostly use is RecordSet with adUseClient with either adLockOptimistic or adLockBatchOptimistic. All this is static information as at the time when we executed the query. The recordset does not get updated on its own unless we explicitly execute oRs:Requery() or in suitable cases oRs:ReSync().\n\nWith a view to keep our browse uptodate, we can not keep executing oRs:Requery() or oRs:Resync() continuously. What Mr Rick refers to is when to do this.\n\nXBrowse and TDataRow do this to some extent. That is when a user attempts to edit a row, either by inline edit or by calling oBrw:Edit() or EditSource(), the row is resynced first and then offered to edit. In other words, the user sees the latest data before he starts editing.", "time": "08:26", "topic": "ADO SQL VISIBILITY", "username": "nageswaragunupudi" } ]
ADO SQL VISIBILITY
[ { "date": "2015-06-26", "forum": "FiveWin for Harbour/xHarbour", "text": "Mr Rao,\n\nI think like in ADORDD the main problem is with additions because deletions or changes are always catched when we try to update.\n\nIn ADORDD this is only a problem working without true locks because otherwise for ex. the order will be locked and no additions are possible during a WS edition or transaction like in a normal DBF execution.\n\nTo control if we need to refresh the recordset because of additions we are studying this possibility:\n\n1) RDD area array element keeping datetime value of the last refresh of the recordset\n\n2) A SQL table NEEDREFRESH with fields:\n \n TABLE = TABLENAME\n DATETIME = DATE TIME ADD NEW RECORD\n\n3) Every time a new addition is made its registered (add or replaced) in NEEDREFRESH with datetime of addition and table name. This can be done directly from ADORDD code or through a trigger or procedure in the server. We have to decide.\n\n4) Every time any replace, delete, addnew takes place the ADORDD first looks in NEEDREFRESH for the table \n\n5) If the datetime in NEEDREFRESH table is newer than the RDD area array element with the datetime last refresh of our recordset we refresh it again resetting the RDD area array element.\n\nOne can install a procedure at the server to run at certain hours when no one its connected to clean up this table.\n\nIts a trade off between integrity and speed.\n\nThis is only primary proposal study phase and at the end we might go other way.\nWe will start working it middle August.\n\nNevertheless I would like very much to have you opinion.", "time": "09:37", "topic": "ADO SQL VISIBILITY", "username": "AHF" } ]
ADO SQL VISIBILITY
[ { "date": "2015-06-30", "forum": "FiveWin for Harbour/xHarbour", "text": "Mr Antonio\n\nYou wanted a quick method to know if other users added new records after current user opened the recordset.\nThis discussion is confined to direct tables (not queries) opened using adUseClient.\n\nIf the table has a primary-key and value of primary-key inserted is always greater than the previously inserted key ( autoincrement or similar) then:\n if the result of \"select max(primarykeycolumn) from thetable\" is greater than the maximum value of primary key in our recordset (we can keep this info somewhere in memory) it means other users added some rows. \nThen we issue oRs:Requery() and reposition our record pointer again at the previous position.\n\n\"select max(primarykey)\" is always highly optimized and fast.\n\nIf the table does not have a primary key, then leave it. The programmer anyway will face lots of problems and learn by mistakes. Anyway for small tables we may compare COUNT(*) with oRs:RecordCount() and decide, though it is slow and not foolproof.\n\nWhen opening a table it is easy for us to identify the primary key and also if it is auto-increment.\n\nSQLSERVER specific: In case the table has auto-increment primary key, we can use \"SELECT IDENT_CURRENT(‘tablename’)\" to know the last primary key value inserted. This is faster even than Max(PrimaryKey).\n\nSome programmers may use rowVersion or timestamp fields. It is possible to identify such fields while opening the table. In such cases comparing the max() values indicates activity by other users.\n\nNext question is how frequently we need to keep checking for other users' inserts. We can't keep checking continuously.\nIf the reocrdset is ordered on the primary key, it may be enough to check when (i) DBGOBOTTOM() and (ii) when DBSKIP( +n ) hits EOF.\nIn other cases we may need to do it with every SKIP() but this may slowdown the skips. You may please test it on large tables and decide.", "time": "02:40", "topic": "ADO SQL VISIBILITY", "username": "nageswaragunupudi" } ]
ADO SQL VISIBILITY
[ { "date": "2015-06-30", "forum": "FiveWin for Harbour/xHarbour", "text": "This is just for academic interest.\nFrom version 2005, MS SQLSERVER introduced a notification feature.\nInstead of client querying the server frequently for any changes in the status, a notification queue can be created and server notifies the clients with subscription whenever the change happens. Client retrieves the notifications with \"RECEIVE * FROM <quename>\". This reduces the round-trip overhead.\n\nI myself never had any occasion to use this feature.", "time": "04:31", "topic": "ADO SQL VISIBILITY", "username": "nageswaragunupudi" } ]
ADO SQL VISIBILITY
[ { "date": "2015-06-30", "forum": "FiveWin for Harbour/xHarbour", "text": "Mr Rao,\n\n[quote:3ndie2mh]\"select max(primarykey)\" is always highly optimized and fast.[/quote:3ndie2mh]\n\nAdordd its working like that but I found at least with Mysql that its taking too long.\nIf you try to use it for instances like a reccount() the browses begin to be very slow on a WAN even with tables of 50.000 recs.\n\nI agree that its a must to have a primaryey as unique autoinc value.\n\nCOUNT() its not reliable and we should forget it. ADORRD recno its based on a primarykey and it can happen that count returns 20 rows but select max() returns 35. So adordd can only use select max otherwise we could have Lastrec() returning 20 and recno 35!\n\n[quote:3ndie2mh]Next question is how frequently we need to keep checking for other users' inserts. We can't keep checking continuously.\nIf the reocrdset is ordered on the primary key, it may be enough to check when (i) DBGOBOTTOM() and (ii) when DBSKIP( +n ) hits EOF.[/quote:3ndie2mh]\n\nI was thinking in checking it before any update, addnew, delete. But dbgobott its good idea as a refresh trigger although it might not be ordered by the primarykey.\n\nTo test it on every skip is unfeasible with select max() it simply takes too long.\n\nAnother option Im study is to have a TRIGGER for every table primarykey field used as recno.\nSomething like this:\n\nCREATE TRIGGER cname ON cTable BEFORE INSERT ...\n\nWhere it saves in a table like:\n\nTLASTREC\nTABLENAME C 30\nMAXKEY N 10 0\n\nThe MAX value of the primarykey.\nThis table will be the size of n tables in the database so pretty small always.\nQuerying it even with skip should be lightning fast.\n\nConcerning MSSQL QUEUES I didnt never tried it but I would like a solution that would be the same for every SQL engine.\n\nWhat do you think about this?\n\nThanks", "time": "08:41", "topic": "ADO SQL VISIBILITY", "username": "AHF" } ]
ADO SQL VISIBILITY
[ { "date": "2015-06-30", "forum": "FiveWin for Harbour/xHarbour", "text": "Mr Antonio\n\nI agree that COUNT(* or any field) is the slowest on every RDMS.\nExcept for small tables or otherwise optimize queries yielding small subsets, no body uses count().\n\nBecause primary-key is indexed max(primary-key) should be faster but not instantaneous like the query I suggested for sql-server. I go by your tests about the acceptability or otherwise of this approach from speed point of view.\n\nCan you please try this query for reliability and speed?\nSELECT `AUTO_INCREMENT` FROM INFORMATION_SCHEMA.TABLES\nWHERE TABLE_SCHEMA = 'DatabaseName' AND TABLE_NAME = 'TableName';\n\nBetter we do not interfere with triggers etc. Better to leave it to their database programmers.", "time": "09:16", "topic": "ADO SQL VISIBILITY", "username": "nageswaragunupudi" } ]
ADO SQL VISIBILITY
[ { "date": "2015-06-30", "forum": "FiveWin for Harbour/xHarbour", "text": "Mr Rao,\n\n[quote:330cfz4w]Better we do not interfere with triggers etc. Better to leave it to their database programmers.[/quote:330cfz4w]\n\nTrue I know we shouldnt do it.\n\n[code=fw:330cfz4w]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\"><span style=\"color: #0000ff;\">SELECT</span> `AUTO_INCREMENT` <span style=\"color: #0000ff;\">FROM</span> INFORMATION_SCHEMA.TABLES<br /><span style=\"color: #0000ff;\">WHERE</span> TABLE_SCHEMA = <span style=\"color: #ff0000;\">'DatabaseName'</span> AND TABLE_NAME = <span style=\"color: #ff0000;\">'TableName'</span>;</div>[/code:330cfz4w]\n\nThis might be it! Ill keep you posted.\nIs it supported by all engines ?", "time": "09:20", "topic": "ADO SQL VISIBILITY", "username": "AHF" } ]
ADO SQL VISIBILITY
[ { "date": "2015-06-30", "forum": "FiveWin for Harbour/xHarbour", "text": "No\nThis is for MySql and I did not use it.\nFor MsSql I advised another query. \nLet us first provide optimal performance for at least two popular servers. Let's keep exploring.", "time": "09:45", "topic": "ADO SQL VISIBILITY", "username": "nageswaragunupudi" } ]
ADO SQL VISIBILITY
[ { "date": "2015-06-30", "forum": "FiveWin for Harbour/xHarbour", "text": "Mr Rao,\n\nIt works ok I need further testing.\n\nHow can I check the size of the schema table being queried ?\nIs it there only the max autoinc of each table ?", "time": "09:55", "topic": "ADO SQL VISIBILITY", "username": "AHF" } ]
ADO SQL VISIBILITY
[ { "date": "2015-06-30", "forum": "FiveWin for Harbour/xHarbour", "text": "SELECT * FROM INFORMATION_SCHEMA.TABLES", "time": "12:51", "topic": "ADO SQL VISIBILITY", "username": "nageswaragunupudi" } ]
ADO SQL VISIBILITY
[ { "date": "2015-07-01", "forum": "FiveWin for Harbour/xHarbour", "text": "Mr Antonio\n\nPlease try this on different databases and see if this works.\n\n[code=fw:1csdtyl2]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\"><span style=\"color: #00C800;\">function</span> LastAutoIncID<span style=\"color: #000000;\">&#40;</span> cTable, cPrimaryKey, oCn <span style=\"color: #000000;\">&#41;</span><br /><br />&nbsp; &nbsp;<span style=\"color: #00C800;\">local</span> oRs, nRet<br /><br />&nbsp; &nbsp;oRs &nbsp; := oCn:<span style=\"color: #000000;\">OpenSchema</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #000000;\">12</span>, <span style=\"color: #000000;\">&#123;</span> <span style=\"color: #00C800;\">nil</span>, <span style=\"color: #00C800;\">nil</span>, <span style=\"color: #00C800;\">nil</span>, <span style=\"color: #00C800;\">nil</span>, ctable <span style=\"color: #000000;\">&#125;</span> <span style=\"color: #000000;\">&#41;</span><br />&nbsp; &nbsp;oRs:<span style=\"color: #000000;\">Filter</span> &nbsp;:= <span style=\"color: #ff0000;\">\"COLUMN_NAME = '\"</span> + cPrimaryKey + <span style=\"color: #ff0000;\">\"'\"</span><br />&nbsp; &nbsp;nRet &nbsp; &nbsp; &nbsp; &nbsp;:= oRs:<span style=\"color: #000000;\">Fields</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"CARDINALITY\"</span> <span style=\"color: #000000;\">&#41;</span>:<span style=\"color: #000000;\">Value</span><br /><br /><span style=\"color: #00C800;\">return</span> nRet<br /> </div>[/code:1csdtyl2]\nNotes: (1) You need to add error checking later\n (2) Use this only if AUTOINCREMENT primary key exists\n\nAdded:\nThis works with MSACCESS, MSSQL and MYSQL", "time": "08:24", "topic": "ADO SQL VISIBILITY", "username": "nageswaragunupudi" } ]
ADO SQL VISIBILITY
[ { "date": "2015-07-02", "forum": "FiveWin for Harbour/xHarbour", "text": "[quote=\"dagiayunus\":r49dv00l]Dear Sir(s)\n\nI have one table in sql database. if USER1 is browsing ARTICLE\ntable and make some changes, how to to update/visible USER2 browse with the\nsame change?\n\nSomething like dbf. when we change records it update to every where.\n\n\n\nRegards\nYunus.[/quote:r49dv00l]\n\nWhen we browse a DBF, we see other usres' changes to a row when we \"move\" to that row. \nWe do not see any changes by other users automatically, without navigating the browse. \n\nTo get the same effect, while creating the browse, add this line:\noBrw:bChange := { || oBrw:oRs:Resync( 1, 2 ), oBrw:RefreshCurrent() }\nWhen a user moves browse cursor to any row, he will see the latest values of that row, as modified by other users.\n\nIn case of DBF, when we refresh the browse, we see all changes to all rows that are visible in the browse window.\nTo get the same effect:\noBrw:bOnRefresh := { || oBrw:oRs:Requery() }\n\nAs we go on things get a bit more complex, which need to learn step by step.\n\nTalking about multi-user issues, ADO is more secure in handling multi-user conflicts than DBF.", "time": "03:47", "topic": "ADO SQL VISIBILITY", "username": "nageswaragunupudi" } ]
ADO SQL VISIBILITY
[ { "date": "2016-09-30", "forum": "FiveWin for Harbour/xHarbour", "text": "Hi,\n\nI'm using FWH ADO on MariaDB.\n\nEverything is working fine.\nOnly one client have a problem on 2 PC's\n\nThe program is a cash desk.\nIf the products are scanned, everything is fast.\nIf there is no client for 5 minutes, I take 8 seconds to show the product on the screen after scanning.\nThen everything is working fast again.\n\nFirst I thought that it was the server that when to sleep-mode, but when testing it with an other (older) PC, it keeps being fast.\n\nDoes anyone know what the problem can be. \nThe PC's are running Windows 10. The server is a Synology NAS with MariaDB on it.\n\nThanks", "time": "18:07", "topic": "ADO SQL slow after idle for a while", "username": "Marc Vanzegbroeck" } ]
ADO SQL slow after idle for a while
[ { "date": "2016-11-03", "forum": "FiveWin for Harbour/xHarbour", "text": "Hi,\n\nDoes anyone else have also this problem?\nI've been testing it and have change some settings in the database-server, but no result.\n\nThe delay is not very long (0.8s), but the problem is that it is used in a shop with a barcodescanner, and then it is long if they have to wait <!-- s:( --><img src=\"{SMILIES_PATH}/icon_sad.gif\" alt=\":(\" title=\"Sad\" /><!-- s:( --> \n\nI run a simple query\n[code=fw:s30sb5dc]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\">otmp = CREATEOBJECT<span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"ADODB.Recordset\"</span> <span style=\"color: #000000;\">&#41;</span><br />otmp:<span style=\"color: #000000;\">cursortype</span> :=<span style=\"color: #000000;\">1</span><br />otmp:<span style=\"color: #000000;\">cursorlocation</span> :=<span style=\"color: #000000;\">3</span><br />otmp:<span style=\"color: #000000;\">locktype</span> := <span style=\"color: #000000;\">3</span><br />otmp:<span style=\"color: #000000;\">open</span><span style=\"color: #000000;\">&#40;</span>SQLCommando,ADO_SQL_Connectionstring<span style=\"color: #000000;\">&#41;</span><br /> </div>[/code:s30sb5dc]\n\nIt only lake 0.03s to run, but after waiting a while (1-2minutes) it take 0.8s, and then 0.03s again...\nI have been change the query_cache_size, but no luck <!-- s:( --><img src=\"{SMILIES_PATH}/icon_sad.gif\" alt=\":(\" title=\"Sad\" /><!-- s:( --> \n\nI have been thinking to run a timer that call a query each 20sec, but I think there must be another solution.\n\nThe strange thing is that they als have al old XP-PC, and there is no delay, only on the Windows 10 pc's <!-- s:shock: --><img src=\"{SMILIES_PATH}/icon_eek.gif\" alt=\":shock:\" title=\"Shocked\" /><!-- s:shock: -->\n\nI just tried to connect my laptop to the network, and on my PC it also keeps running fine (Windows 10 Pro) <!-- s:shock: --><img src=\"{SMILIES_PATH}/icon_eek.gif\" alt=\":shock:\" title=\"Shocked\" /><!-- s:shock: --> <!-- s:shock: --><img src=\"{SMILIES_PATH}/icon_eek.gif\" alt=\":shock:\" title=\"Shocked\" /><!-- s:shock: --> <!-- s:shock: --><img src=\"{SMILIES_PATH}/icon_eek.gif\" alt=\":shock:\" title=\"Shocked\" /><!-- s:shock: -->", "time": "10:30", "topic": "ADO SQL slow after idle for a while", "username": "Marc Vanzegbroeck" } ]
ADO SQL slow after idle for a while
[ { "date": "2016-11-04", "forum": "FiveWin for Harbour/xHarbour", "text": ">>>\notmp:open(SQLCommando,ADO_SQL_Connectionstring)\n\n>>>\nIf you want speed, do not use connection strings, use connection object which is already open.", "time": "10:11", "topic": "ADO SQL slow after idle for a while", "username": "nageswaragunupudi" } ]
ADO SQL slow after idle for a while
[ { "date": "2016-11-04", "forum": "FiveWin for Harbour/xHarbour", "text": "Thank you, but how can I the run each time a different query to receive arecordsset?", "time": "11:16", "topic": "ADO SQL slow after idle for a while", "username": "Marc Vanzegbroeck" } ]
ADO SQL slow after idle for a while
[ { "date": "2016-11-04", "forum": "FiveWin for Harbour/xHarbour", "text": "Marc\n\nHere is a Sql Server example on how to create a Global Connection (oCn ) .. Once you have made your connection .. just pass oCn instead of your connection string. There are other ways you can do the same thing using the FWAdo wrappers .. Rao can help you there.\n\nRick Lipkin\n\n[code=fw:2megjoka]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\"><br /><span style=\"color: #00C800;\">Local</span> xProvider,xSource,xCatalog,xPassword,cString,oRs<br /><span style=\"color: #00C800;\">Public</span> oCn<br /><br /><br />xPROVIDER := <span style=\"color: #ff0000;\">\"SQLOLEDB\"</span> &nbsp; &nbsp;<span style=\"color: #B900B9;\">// specific to Sql Server .. ole</span><br />xSOURCE   := <span style=\"color: #ff0000;\">\"YourServer\"</span><br />xCatalog  := <span style=\"color: #ff0000;\">\"YourDatabase\"</span><br />xUserId   := <span style=\"color: #ff0000;\">\"XXXXXXX\"</span><br />xPASSWORD := <span style=\"color: #ff0000;\">\"XXXXXXX\"</span><br /><br /><br />cString := <span style=\"color: #ff0000;\">'Provider='</span>+xPROVIDER+<span style=\"color: #ff0000;\">';Data Source='</span>+xSOURCE+<span style=\"color: #ff0000;\">';Initial Catalog='</span>+xCATALOG+<span style=\"color: #ff0000;\">';User Id='</span>+xUSERID+<span style=\"color: #ff0000;\">';Password='</span>+xPASSWORD<br /><br /><span style=\"color: #B900B9;\">// global connection string</span><br />oCn := CREATEOBJECT<span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"ADODB.Connection\"</span> <span style=\"color: #000000;\">&#41;</span><br /><br /><span style=\"color: #00C800;\">TRY</span><br />   oCn:<span style=\"color: #000000;\">Open</span><span style=\"color: #000000;\">&#40;</span> cString <span style=\"color: #000000;\">&#41;</span><br />CATCH oErr<br />   Saying := <span style=\"color: #ff0000;\">\"Could not open a Global Connection to Database \"</span>+xSource<br />   <span style=\"color: #0000ff;\">MsgInfo</span><span style=\"color: #000000;\">&#40;</span> Saying <span style=\"color: #000000;\">&#41;</span><br />   <span style=\"color: #00C800;\">RETURN</span><span style=\"color: #000000;\">&#40;</span>.F.<span style=\"color: #000000;\">&#41;</span><br />END <span style=\"color: #00C800;\">TRY</span><br /><br /><span style=\"color: #B900B9;\">// open a recordset with global connection</span><br />oRs := TOleAuto<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span>:<span style=\"color: #00C800;\">New</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"ADODB.Recordset\"</span> <span style=\"color: #000000;\">&#41;</span><br />oRs:<span style=\"color: #000000;\">CursorType</span>     := <span style=\"color: #000000;\">1</span>        <span style=\"color: #B900B9;\">// opendkeyset</span><br />oRs:<span style=\"color: #000000;\">CursorLocation</span> := <span style=\"color: #000000;\">3</span>        <span style=\"color: #B900B9;\">// local cache</span><br />oRs:<span style=\"color: #000000;\">LockType</span>       := <span style=\"color: #000000;\">3</span>        <span style=\"color: #B900B9;\">// lockoportunistic</span><br /><br />cSQL := <span style=\"color: #ff0000;\">\"SELECT * from YourTable\"</span><br /><br /><span style=\"color: #00C800;\">TRY</span><br />  oRS:<span style=\"color: #000000;\">Open</span><span style=\"color: #000000;\">&#40;</span>cSQL,oCn <span style=\"color: #000000;\">&#41;</span><br />CATCH oErr<br />   <span style=\"color: #0000ff;\">MsgInfo</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"Error in Opening YourTable )<br />      Return(.f.)<br />END TRY<br /></span></div>[/code:2megjoka]", "time": "15:11", "topic": "ADO SQL slow after idle for a while", "username": "Rick Lipkin" } ]
ADO SQL slow after idle for a while
[ { "date": "2016-11-04", "forum": "FiveWin for Harbour/xHarbour", "text": "Rick,\n\nThank you, I will try it.", "time": "16:01", "topic": "ADO SQL slow after idle for a while", "username": "Marc Vanzegbroeck" } ]
ADO SQL slow after idle for a while
[ { "date": "2013-03-12", "forum": "FiveWin para Harbour/xHarbour", "text": "If you are looking for a Sample on how to call a stored procedure on MS-SQL Server with parameters, here is one which may be useful to you\n\n[code=fw:pirhx5yi]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\"><span style=\"color: #B900B9;\">// Trying to initiate the Stored Procedure</span><br />oCmd:=CreateObject<span style=\"color: #000000;\">&#40;</span><span style=\"color: #ff0000;\">\"ADODB.Command\"</span><span style=\"color: #000000;\">&#41;</span><br />oCmd:<span style=\"color: #000000;\">ActiveConnection</span>:=oApp:<span style=\"color: #000000;\">oConnection</span><br />oCmd:<span style=\"color: #000000;\">CommandType</span>:=adCmdStoredProc<br />oCmd:<span style=\"color: #000000;\">CommandText</span>:=<span style=\"color: #ff0000;\">\"StockUpDate\"</span> &nbsp;<span style=\"color: #B900B9;\">// Strored Procedure Name</span><br /><br /><span style=\"color: #B900B9;\">// Creating Parameters before sending parameters to Stored Procedure</span><br />oParam := oCmd:<span style=\"color: #000000;\">CreateParameter</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"cPartNo\"</span>, adChar, adParamInput, <span style=\"color: #000000;\">25</span> <span style=\"color: #000000;\">&#41;</span><br />oCmd:<span style=\"color: #000000;\">Parameters</span>:<span style=\"color: #000000;\">Append</span><span style=\"color: #000000;\">&#40;</span> oParam <span style=\"color: #000000;\">&#41;</span><br />oParam := oCmd:<span style=\"color: #000000;\">CreateParameter</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"cPartName\"</span>,adChar, adParamInput, <span style=\"color: #000000;\">25</span> <span style=\"color: #000000;\">&#41;</span><br />oCmd:<span style=\"color: #000000;\">Parameters</span>:<span style=\"color: #000000;\">Append</span><span style=\"color: #000000;\">&#40;</span> oParam <span style=\"color: #000000;\">&#41;</span><br />oParam := oCmd:<span style=\"color: #000000;\">CreateParameter</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"cQty\"</span>,adChar, adParamInput, <span style=\"color: #000000;\">25</span> <span style=\"color: #000000;\">&#41;</span><br />oCmd:<span style=\"color: #000000;\">Parameters</span>:<span style=\"color: #000000;\">Append</span><span style=\"color: #000000;\">&#40;</span> oParam <span style=\"color: #000000;\">&#41;</span><br />oParam := oCmd:<span style=\"color: #000000;\">CreateParameter</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"cColumName\"</span>,adChar, adParamInput, <span style=\"color: #000000;\">25</span> <span style=\"color: #000000;\">&#41;</span><br />oCmd:<span style=\"color: #000000;\">Parameters</span>:<span style=\"color: #000000;\">Append</span><span style=\"color: #000000;\">&#40;</span> oParam <span style=\"color: #000000;\">&#41;</span><br /><br /><span style=\"color: #B900B9;\">// Assigning Values to the Paramter</span><br /><span style=\"color: #00C800;\">TRY</span><br />&nbsp; &nbsp;oCmd:<span style=\"color: #000000;\">Parameters</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"cPartNo\"</span> <span style=\"color: #000000;\">&#41;</span>:<span style=\"color: #000000;\">Value</span> := SparMast->PART<br />&nbsp; &nbsp;oCmd:<span style=\"color: #000000;\">Parameters</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"cPartName\"</span> <span style=\"color: #000000;\">&#41;</span>:<span style=\"color: #000000;\">Value</span> := Rtrim<span style=\"color: #000000;\">&#40;</span>Ltrim<span style=\"color: #000000;\">&#40;</span>SparMast->DESC<span style=\"color: #000000;\">&#41;</span><span style=\"color: #000000;\">&#41;</span><br />&nbsp; &nbsp;oCmd:<span style=\"color: #000000;\">Parameters</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"cQty\"</span> <span style=\"color: #000000;\">&#41;</span>:<span style=\"color: #000000;\">Value</span> := LTrim<span style=\"color: #000000;\">&#40;</span> Str<span style=\"color: #000000;\">&#40;</span>Int<span style=\"color: #000000;\">&#40;</span>SparMast->CURR_QTY<span style=\"color: #000000;\">&#41;</span><span style=\"color: #000000;\">&#41;</span> &nbsp;<span style=\"color: #000000;\">&#41;</span><br />&nbsp; &nbsp;oCmd:<span style=\"color: #000000;\">Parameters</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"cColumName\"</span> <span style=\"color: #000000;\">&#41;</span>:<span style=\"color: #000000;\">Value</span> := <span style=\"color: #ff0000;\">\"Alpy_Parvr_Qty\"</span><br />CATCH oError<br />&nbsp; &nbsp;ShowSqlError<span style=\"color: #000000;\">&#40;</span> oError <span style=\"color: #000000;\">&#41;</span><br />END&nbsp;&nbsp; &nbsp; <br /><br /><span style=\"color: #B900B9;\">// Executing or Calling Stored Procedure&nbsp; &nbsp; </span><br /><span style=\"color: #00C800;\">TRY</span><br />&nbsp; &nbsp;oCmd:<span style=\"color: #000000;\">Execute</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span><br />CATCH oError<br />&nbsp; &nbsp;ShowSqlError<span style=\"color: #000000;\">&#40;</span> oError <span style=\"color: #000000;\">&#41;</span><br />END&nbsp;<br />&nbsp;</div>[/code:pirhx5yi]Regards\n[b:pirhx5yi]Anser[/b:pirhx5yi]", "time": "06:41", "topic": "ADO STORED PROCEDURES", "username": "anserkk" } ]
ADO STORED PROCEDURES
[ { "date": "2013-03-11", "forum": "FiveWin para Harbour/xHarbour", "text": "Buenas Tardes, alguien tendra un ejemplo de como llamar un store procedure y pasarles sus parametros MS-SQLSERVER a traves de ADO. Gracias.", "time": "18:27", "topic": "ADO STORED PROCEDURES", "username": "angstin" } ]
ADO STORED PROCEDURES
[ { "date": "2013-03-11", "forum": "FiveWin para Harbour/xHarbour", "text": "Select Tu_procedimiento( parametros )\n\nSaludos", "time": "18:37", "topic": "ADO STORED PROCEDURES", "username": "horacio" } ]
ADO STORED PROCEDURES
[ { "date": "2013-03-11", "forum": "FiveWin para Harbour/xHarbour", "text": "Gracias, por responder lo hago de esa manera y me da el siguiente error: Class: 'ERROR' has no exported method \n\n[code=fw:120ud9zj]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\">cad_sql0:=<span style=\"color: #ff0000;\">\"SELECT pp_actualiza_stock(@co_art='\"</span>+xc_art+<span style=\"color: #ff0000;\">\"',@co_alma='\"</span>+xc_alma+<span style=\"color: #ff0000;\">\"',@total_art=\"</span>+str<span style=\"color: #000000;\">&#40;</span>xtot_art<span style=\"color: #000000;\">&#41;</span><br />         cad_sql0:=cad_sql0+<span style=\"color: #ff0000;\">\",@tipo_stock='stock_act',@costo_b=\"</span>+str<span style=\"color: #000000;\">&#40;</span>xuct<span style=\"color: #000000;\">&#41;</span>+<span style=\"color: #ff0000;\">\",@fecha_mov='\"</span>+dtoc<span style=\"color: #000000;\">&#40;</span>xf_lot<span style=\"color: #000000;\">&#41;</span><br />         cad_sql0:=cad_sql0+<span style=\"color: #ff0000;\">\"',@stotal_art=\"</span>+str<span style=\"color: #000000;\">&#40;</span>xst_art<span style=\"color: #000000;\">&#41;</span>+<span style=\"color: #ff0000;\">\",@costo_om=\"</span>+str<span style=\"color: #000000;\">&#40;</span>xuctom<span style=\"color: #000000;\">&#41;</span>+<span style=\"color: #ff0000;\">\",@total_uni=\"</span>+str<span style=\"color: #000000;\">&#40;</span>xtot_uni<span style=\"color: #000000;\">&#41;</span><br />         cad_sql0:=cad_sql0+<span style=\"color: #ff0000;\">\",@co_us_in='PROFIT',@co_sucu='01',@r_stock_neg=2,@accion='R',@desde='NDD')\"</span><br />                 oRs := CreateObject<span style=\"color: #000000;\">&#40;</span><span style=\"color: #ff0000;\">\"ADODB.RecordSet\"</span><span style=\"color: #000000;\">&#41;</span>   <br />         ors:<span style=\"color: #000000;\">CursorType</span>     = adOpenDynamic <br />                 ors:<span style=\"color: #000000;\">CursorLocation</span> = adUseClient<br />                 ors:<span style=\"color: #000000;\">LockType</span>       = adLockOptimistic<br />                 oRs:<span style=\"color: #000000;\">ActiveConnection</span>:= bc:<span style=\"color: #000000;\">ado</span><br />                 oRs:<span style=\"color: #000000;\">source</span> := cad_Sql0<br />                 oRs:<span style=\"color: #000000;\">Open</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span><br /> </div>[/code:120ud9zj]", "time": "19:02", "topic": "ADO STORED PROCEDURES", "username": "angstin" } ]
ADO STORED PROCEDURES
[ { "date": "2013-03-11", "forum": "FiveWin para Harbour/xHarbour", "text": "No entiendo como pasas los parámetros, aqui un ejemplo \n\n[code=fw:ij4mydjj]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\"><br />&nbsp; &nbsp; &nbsp; &nbsp; cQuery &nbsp; &nbsp; := <span style=\"color: #ff0000;\">\"Select Neto( \"</span> + cNroLegajo + <span style=\"color: #ff0000;\">\" ), Bruto( \"</span> + cNroLegajo + <span style=\"color: #ff0000;\">\" )\"</span><br />&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;oRec := TOleAuto<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span> : <span style=\"color: #00C800;\">New</span> <span style=\"color: #000000;\">&#40;</span><span style=\"color: #ff0000;\">\"ADODB.RecordSet\"</span><span style=\"color: #000000;\">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; oRec : <span style=\"color: #000000;\">CursorLocation</span> &nbsp; &nbsp; := adUseClient<br />&nbsp; &nbsp; &nbsp; &nbsp; oRec : <span style=\"color: #000000;\">CursorType</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:= adOpenDynamic<br />&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; oRec : <span style=\"color: #000000;\">LockType</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; := adLockOptimistic<br />&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; oRec : <span style=\"color: #000000;\">ActiveConnection</span> := oVarGlobales : <span style=\"color: #000000;\">oCon</span><br />&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; oRec : <span style=\"color: #000000;\">Source</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; := cQuery<br />&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; oRec : <span style=\"color: #000000;\">Open</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span><br />&nbsp;</div>[/code:ij4mydjj]\n\nSaludos", "time": "19:28", "topic": "ADO STORED PROCEDURES", "username": "horacio" } ]
ADO STORED PROCEDURES
[ { "date": "2013-03-11", "forum": "FiveWin para Harbour/xHarbour", "text": "Y cual es el nombre del procedimiento ahi en tu ejemplo y cuales son los parametros? gracias", "time": "19:34", "topic": "ADO STORED PROCEDURES", "username": "angstin" } ]
ADO STORED PROCEDURES
[ { "date": "2013-03-11", "forum": "FiveWin para Harbour/xHarbour", "text": "Neto y bruto son los procedimientos, y cNroLegajo es el parámetro. Sería bueno que que pusieras aqui como programaste el procedimiento\n\nSaludos", "time": "20:27", "topic": "ADO STORED PROCEDURES", "username": "horacio" } ]
ADO STORED PROCEDURES
[ { "date": "2013-03-11", "forum": "FiveWin para Harbour/xHarbour", "text": "me sigue dando el mismo error\n cad_sql0:=\"SELECT pp_actualiza_stock('\"+xc_art+\"','\"+xc_alma+\"',\"+str(xtot_art)\n\t\t cad_sql0:=cad_sql0+\",'stock_act',\"+str(xuct)+\",'\"+dtoc(xf_lot)\n\t\t cad_sql0:=cad_sql0+\"',\"+str(xst_art)+\",\"+str(xuctom)+\",\"+str(xtot_uni)\n\t\t cad_sql0:=cad_sql0+\",'PROFIT','01',2,'R','NDD')\"\n\nes un procedimiento almacenado en el server MS-SQLSERVER\n[code=fw:2jdyjeb5]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\"><br />USE <span style=\"color: #000000;\">&#91;</span>demo<span style=\"color: #000000;\">&#93;</span><br />GO<br /><span style=\"color: #B900B9;\">/****** Object: &nbsp;StoredProcedure [dbo].[pp_actualiza_stock] &nbsp; &nbsp;Script Date: 03/11/2013 15:08:14 ******/</span><br />SET ANSI_NULLS <span style=\"color: #0000ff;\">ON</span><br />GO<br />SET QUOTED_IDENTIFIER <span style=\"color: #0000ff;\">ON</span><br />GO<br /><br /><br />ALTER PROC <span style=\"color: #000000;\">&#91;</span>dbo<span style=\"color: #000000;\">&#93;</span>.<span style=\"color: #000000;\">&#91;</span>pp_actualiza_stock<span style=\"color: #000000;\">&#93;</span><br /><span style=\"color: #B900B9;\">/******************************************************************************<br />* Stored Procedure : pp_actualiza_stock &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />* Fecha Creación &nbsp; : 22/11/2001 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />* Parámetros &nbsp; &nbsp; &nbsp; : - @co_art char(30) código del articulo al cual se le mo- *<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;difica el stock. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- @co_alma char(6) código del almacen donde se afectará &nbsp;*<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;el stock. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- @total_art decimal(28,12) cantidad de artículos. &nbsp; &nbsp; &nbsp; *<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- @tipo_stock char(9) tipo de operación a ser realizada: *<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- stock_com --> comprometido, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- stock_act --> actual, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- stock_des --> por despachar, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- stock_lle --> por llegar. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- @costo_b decimal(28,12) costo en la moneda base. &nbsp; &nbsp; &nbsp; *<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- @fecha_mov smalldatetime fecha del movimiento. &nbsp; &nbsp; &nbsp; &nbsp; *<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- @stotal_art decimal(28,12) cantidad de artículos en la *<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;unidad secundaria. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- @costo_om decimal(28,12) costa en otra moneda. &nbsp; &nbsp; &nbsp; &nbsp; *<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- @total_uni decimal(28,12) unidad de la venta. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- @co_us_in char(6) usuario que realiza la operación. &nbsp; &nbsp;*<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- @co_sucu char(6) sucursal del movimiento. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- @r_stock_neg tinyint indica cual será el comportamien- *<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;to con respecto al stock negativo: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- 0 --> indica que no se puede facturar en negativo. &nbsp; *<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- 1 --> indica que se debe preguntar al usuario si de- *<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sea facturar con estoc en negativo. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- 2 --> indica que puede facturar con stock en negati- *<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vo o que la respuesta fue positiva. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- @accion char(1) indica cual es el tipo de operación a &nbsp;*<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;realizar sobre el stock: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- S --> aumentar el stock. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- R --> disminuir el stock. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- @desde char(4) indica desde donde se llama a este &nbsp; &nbsp; &nbsp;*<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;procedimiento. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />* Descripción &nbsp; &nbsp; &nbsp;: Este procedimiento se encarga modificar el stock de un &nbsp; *<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;artículo y de manejar el esquema de los casos de negati- *<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vo de acuerdo a los parámetros que recibe. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />* Desarrollador &nbsp; &nbsp;: Noel Quiroz A. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />******************************************************************************/</span><br />@co_art char<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">30</span><span style=\"color: #000000;\">&#41;</span>,@co_alma char<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">6</span><span style=\"color: #000000;\">&#41;</span>,@total_art decimal<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">28</span>,<span style=\"color: #000000;\">12</span><span style=\"color: #000000;\">&#41;</span>,@tipo_stock char<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">9</span><span style=\"color: #000000;\">&#41;</span>,<br />@costo_b decimal<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">28</span>,<span style=\"color: #000000;\">12</span><span style=\"color: #000000;\">&#41;</span>,@fecha_mov smalldatetime,@stotal_art decimal<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">28</span>,<span style=\"color: #000000;\">12</span><span style=\"color: #000000;\">&#41;</span>,<br />@nro_lote char<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">10</span><span style=\"color: #000000;\">&#41;</span>,@fech_lote smalldatetime,@costo_om decimal<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">28</span>,<span style=\"color: #000000;\">12</span><span style=\"color: #000000;\">&#41;</span>,<br />@total_uni decimal<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">28</span>,<span style=\"color: #000000;\">12</span><span style=\"color: #000000;\">&#41;</span>,@co_us_in char<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">6</span><span style=\"color: #000000;\">&#41;</span>,@co_sucu char<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">6</span><span style=\"color: #000000;\">&#41;</span>,@r_stock_neg tinyint,<br />@p_lotefec_amb bit,@p_lotefec_res bit,@accion char<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">1</span><span style=\"color: #000000;\">&#41;</span>,@desde char<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">4</span><span style=\"color: #000000;\">&#41;</span><br />as<br />declare @cantidad_act decimal <span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">28</span>,<span style=\"color: #000000;\">12</span><span style=\"color: #000000;\">&#41;</span>,@scantidad_act decimal <span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">28</span>,<span style=\"color: #000000;\">12</span><span style=\"color: #000000;\">&#41;</span>,<br />&nbsp; &nbsp; &nbsp; &nbsp; @total_artc decimal<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">28</span>,<span style=\"color: #000000;\">12</span><span style=\"color: #000000;\">&#41;</span> &nbsp; ,@status_sal int,@des_art varchar<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">120</span><span style=\"color: #000000;\">&#41;</span>,<br />&nbsp; &nbsp; &nbsp; &nbsp; @ult_cos_un decimal<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">28</span>,<span style=\"color: #000000;\">12</span><span style=\"color: #000000;\">&#41;</span> &nbsp; ,@cos_pro_un decimal<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">28</span>,<span style=\"color: #000000;\">12</span><span style=\"color: #000000;\">&#41;</span>,<br />&nbsp; &nbsp; &nbsp; &nbsp; @ult_cos_om decimal<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">28</span>,<span style=\"color: #000000;\">12</span><span style=\"color: #000000;\">&#41;</span> &nbsp; ,@cos_pro_om decimal<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">28</span>,<span style=\"color: #000000;\">12</span><span style=\"color: #000000;\">&#41;</span>,<br />&nbsp; &nbsp; &nbsp; &nbsp; @fec_ult_co smalldatetime &nbsp; &nbsp;,@fec_pro_un smalldatetime,<br />&nbsp; &nbsp; &nbsp; &nbsp; @fec_ult_om smalldatetime &nbsp; &nbsp;,@fec_pro_om smalldatetime,<br />&nbsp; &nbsp; &nbsp; &nbsp; @relac_aut int &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ,@uni_relac decimal<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">28</span>,<span style=\"color: #000000;\">12</span><span style=\"color: #000000;\">&#41;</span>,<br />&nbsp; &nbsp; &nbsp; &nbsp; @p_lotenro bit &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ,@p_lotefec bit,<br />&nbsp; &nbsp; &nbsp; &nbsp; @lote bit &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br /><br /><span style=\"color: #0000ff;\">select</span> @des_art &nbsp; &nbsp;= art_des &nbsp; ,@cantidad_act = stock_act,<br />&nbsp; &nbsp; &nbsp; &nbsp;@ult_cos_un = ult_cos_un,@cos_pro_un = cos_pro_un,<br />&nbsp; &nbsp; &nbsp; &nbsp;@ult_cos_om = ult_cos_om,@cos_pro_om = cos_pro_om,<br />&nbsp; &nbsp; &nbsp; &nbsp;@fec_ult_co = fec_ult_co,@fec_pro_un = fec_cos_pr,<br />&nbsp; &nbsp; &nbsp; &nbsp;@fec_ult_om = fec_ult_om,@fec_pro_om = fec_pro_om,<br />&nbsp; &nbsp; &nbsp; &nbsp;@relac_aut &nbsp;= relac_aut ,@uni_relac &nbsp;= uni_relac,<br />&nbsp; &nbsp; &nbsp; &nbsp;@lote &nbsp; &nbsp; &nbsp; = lote<br /><span style=\"color: #0000ff;\">from</span> art <span style=\"color: #0000ff;\">where</span> co_art = @co_Art<br /><br /><span style=\"color: #00C800;\">if</span> @relac_aut in <span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">2</span>,<span style=\"color: #000000;\">3</span><span style=\"color: #000000;\">&#41;</span> and @uni_relac != <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; set @stotal_art = <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp;end<br /><br /><span style=\"color: #0000ff;\">select</span> @p_lotenro = p_lotenro, @p_lotefec = p_lotefec <span style=\"color: #0000ff;\">from</span> par_emp<br /><br /><span style=\"color: #B900B9;\">/******************************************************************************<br />* Proceso para el Stock comprometido. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />******************************************************************************/</span><br /><span style=\"color: #00C800;\">if</span> @tipo_stock = <span style=\"color: #ff0000;\">'stock_com'</span> <br />&nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @accion = <span style=\"color: #ff0000;\">'S'</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">update</span> art set stock_com = stock_com + <span style=\"color: #000000;\">&#40;</span>@total_art * @total_uni<span style=\"color: #000000;\">&#41;</span>,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sstock_com = sstock_com + @stotal_art<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #0000ff;\">where</span> co_art = @co_art<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @@error != <span style=\"color: #000000;\">0</span> or @@rowcount = <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">1</span> as Errores,<span style=\"color: #ff0000;\">'No se pudo aumentar el stock comprometido en la tabla de artículos '</span> + <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #ff0000;\">'para el artículo '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_art<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">' '</span> + @des_art as Mensaje<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">RETURN</span> <span style=\"color: #000000;\">1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> not <span style=\"color: #0000ff;\">exists</span> <span style=\"color: #000000;\">&#40;</span><span style=\"color: #0000ff;\">select</span> * <span style=\"color: #0000ff;\">from</span> st_almac <span style=\"color: #0000ff;\">where</span> co_alma = @co_alma<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; and co_art = @co_art<span style=\"color: #000000;\">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; insert into st_almac <span style=\"color: #000000;\">&#40;</span>co_alma,co_art<span style=\"color: #000000;\">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; values <span style=\"color: #000000;\">&#40;</span>@co_alma,@co_art<span style=\"color: #000000;\">&#41;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @@error != <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">1</span> as Errores,<span style=\"color: #ff0000;\">'No se pudo insertar registro en la tabla de st_almac para el stock comprometido '</span> +<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #ff0000;\">'para el artículo '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_art<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">' '</span> + @des_art + <span style=\"color: #ff0000;\">' en el almacén '</span> + <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rtrim<span style=\"color: #000000;\">&#40;</span>@co_alma<span style=\"color: #000000;\">&#41;</span> as Mensaje<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">RETURN</span> <span style=\"color: #000000;\">1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">update</span> st_almac set stock_com = stock_com + <span style=\"color: #000000;\">&#40;</span>@total_art * @total_uni<span style=\"color: #000000;\">&#41;</span>,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sstock_com = sstock_com + @stotal_art <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #0000ff;\">where</span> co_art = @co_art<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;and co_alma = @co_alma<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @@error != <span style=\"color: #000000;\">0</span> or @@rowcount = <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">1</span> as Errores,<span style=\"color: #ff0000;\">'No se pudo aumentar el stock comprometido en la tabla de artículos '</span> +<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #ff0000;\">'para el artículo '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_art<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">' '</span> + @des_art + <span style=\"color: #ff0000;\">' en el almacén '</span> + <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rtrim<span style=\"color: #000000;\">&#40;</span>@co_alma<span style=\"color: #000000;\">&#41;</span> as Mensaje<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">RETURN</span> <span style=\"color: #000000;\">1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br />&nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">else</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">update</span> st_almac set stock_com = stock_com - <span style=\"color: #000000;\">&#40;</span>@total_art * @total_uni<span style=\"color: #000000;\">&#41;</span>,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sstock_com = sstock_com - @stotal_art <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #0000ff;\">where</span> co_art = @co_art<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;and co_alma = @co_alma<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @@error != <span style=\"color: #000000;\">0</span> or @@rowcount = <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">1</span> as Errores,<span style=\"color: #ff0000;\">'No se pudo disminuir el stock comprometido en la tabla de artículos '</span> +<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #ff0000;\">'para el artículo '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_art<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">' '</span> + @des_art + <span style=\"color: #ff0000;\">' en el almacén '</span> + <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rtrim<span style=\"color: #000000;\">&#40;</span>@co_alma<span style=\"color: #000000;\">&#41;</span> as Mensaje<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">RETURN</span> <span style=\"color: #000000;\">1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">update</span> art set stock_com = stock_com - <span style=\"color: #000000;\">&#40;</span>@total_art * @total_uni<span style=\"color: #000000;\">&#41;</span>,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sstock_com = sstock_com - @stotal_art<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #0000ff;\">where</span> co_art = @co_art<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @@error != <span style=\"color: #000000;\">0</span> or @@rowcount = <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">1</span> as Errores,<span style=\"color: #ff0000;\">'No se pudo disminuir el stock comprometido en la tabla de artículos '</span> + <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #ff0000;\">'para el artículo '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_art<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">' '</span> + @des_art as Mensaje<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">RETURN</span> <span style=\"color: #000000;\">1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br />&nbsp; &nbsp;end<br /><br /><span style=\"color: #B900B9;\">/******************************************************************************<br />* Proceso para el Stock actual. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />******************************************************************************/</span><br /><span style=\"color: #00C800;\">if</span> @tipo_stock = <span style=\"color: #ff0000;\">'stock_act'</span> <br />&nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @accion = <span style=\"color: #ff0000;\">'S'</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #B900B9;\">/*Actualizar los costos*/</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @fecha_mov >= @fec_ult_co<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set @fec_ult_co = @fecha_mov<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set @ult_cos_un = @costo_b<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set @cos_pro_un = <span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#40;</span>@ult_cos_un * @cantidad_act<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #000000;\">&#40;</span>@total_art * @costo_b<span style=\"color: #000000;\">&#41;</span><span style=\"color: #000000;\">&#41;</span> <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; / <span style=\"color: #000000;\">&#40;</span>@cantidad_act + @total_art<span style=\"color: #000000;\">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">update</span> art set stock_act = stock_act + <span style=\"color: #000000;\">&#40;</span>@total_art * @total_uni<span style=\"color: #000000;\">&#41;</span>,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sstock_act = sstock_act + @stotal_art,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ult_cos_un = @ult_cos_un,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cos_pro_un = @cos_pro_un,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fec_ult_co = @fec_ult_co<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #0000ff;\">where</span> co_art = @co_art<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @@error != <span style=\"color: #000000;\">0</span> or @@rowcount = <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">1</span> as Errores,<span style=\"color: #ff0000;\">'No se pudo aumentar el stock actual en la tabla de artículos '</span> + <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #ff0000;\">'para el artículo '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_art<span style=\"color: #000000;\">&#41;</span> &nbsp;+ <span style=\"color: #ff0000;\">' '</span> + @des_art as Mensaje<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">RETURN</span> <span style=\"color: #000000;\">1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> not <span style=\"color: #0000ff;\">exists</span> <span style=\"color: #000000;\">&#40;</span><span style=\"color: #0000ff;\">select</span> * <span style=\"color: #0000ff;\">from</span> st_almac <span style=\"color: #0000ff;\">where</span> co_alma = @co_alma<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; and co_art = @co_art<span style=\"color: #000000;\">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; insert into st_almac <span style=\"color: #000000;\">&#40;</span>co_alma,co_art<span style=\"color: #000000;\">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; values <span style=\"color: #000000;\">&#40;</span>@co_alma,@co_art<span style=\"color: #000000;\">&#41;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @@error != <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">1</span> as Errores,<span style=\"color: #ff0000;\">'No se pudo insertar registro en la tabla de st_almac para el stock actual '</span> +<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #ff0000;\">'para el artículo '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_art<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">' '</span> + @des_art + <span style=\"color: #ff0000;\">' en el almacén '</span> +<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rtrim<span style=\"color: #000000;\">&#40;</span>@co_alma<span style=\"color: #000000;\">&#41;</span> as Mensaje<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">RETURN</span> <span style=\"color: #000000;\">1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">update</span> st_almac set stock_act = stock_act + <span style=\"color: #000000;\">&#40;</span>@total_art * @total_uni<span style=\"color: #000000;\">&#41;</span>,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sstock_act = sstock_act + @stotal_art<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #0000ff;\">where</span> co_art = @co_art<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;and co_alma = @co_alma<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @@error != <span style=\"color: #000000;\">0</span> or @@rowcount = <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">1</span> as Errores,<span style=\"color: #ff0000;\">'No se pudo aumentar el stock actual en la tabla de artículos '</span> +<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #ff0000;\">'para el artículo '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_art<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">' '</span> + @des_art + <span style=\"color: #ff0000;\">' en el almacén '</span> + <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rtrim<span style=\"color: #000000;\">&#40;</span>@co_alma<span style=\"color: #000000;\">&#41;</span> as Mensaje<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">RETURN</span> <span style=\"color: #000000;\">1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br />&nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">else</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br /><span style=\"color: #B900B9;\">/******************************************************************************<br />* Manejo de lotes, para este fin se utilizan 3 variables: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />* - p_lotenro --> esta indica si en parámetros de la empresa está activada la *<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; marca de trabajar los lotes por número. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />* - p_lotefec --> esta indica si en parámetros de la empresa está activada la *<br />* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; marca de trabajar los lotes por fecha de vencimiento. &nbsp; &nbsp; &nbsp; *<br />* - lote &nbsp; &nbsp; &nbsp;--> esta indica si el artículo en curso maneja lotes. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br />******************************************************************************/</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> <span style=\"color: #000000;\">&#40;</span>@p_lotenro = <span style=\"color: #000000;\">1</span> or @p_lotefec = <span style=\"color: #000000;\">1</span><span style=\"color: #000000;\">&#41;</span> and @lote = <span style=\"color: #000000;\">1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> len<span style=\"color: #000000;\">&#40;</span>rtrim<span style=\"color: #000000;\">&#40;</span>@nro_lote<span style=\"color: #000000;\">&#41;</span><span style=\"color: #000000;\">&#41;</span> = space<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">0</span><span style=\"color: #000000;\">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">3</span> as Errores,<span style=\"color: #ff0000;\">'El número de lote para el artículo '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_art<span style=\"color: #000000;\">&#41;</span> + <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #ff0000;\">' no fue especificado '</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #00C800;\">return</span> <span style=\"color: #000000;\">3</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @fecha_mov > @fech_lote and @p_lotefec_res = <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @p_lotefec_amb = <span style=\"color: #000000;\">1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">3</span> as Errores,<span style=\"color: #ff0000;\">'El número de lote '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@nro_lote<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">' se encuentra vencido '</span> + <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; convert<span style=\"color: #000000;\">&#40;</span>varchar,@fech_lote,<span style=\"color: #000000;\">103</span><span style=\"color: #000000;\">&#41;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">return</span> <span style=\"color: #000000;\">3</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">else</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #00C800;\">if</span> @p_lotefec_amb = <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">2</span> as Errores,<span style=\"color: #ff0000;\">'El número de lote '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@nro_lote<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">' se encuentra vencido '</span> + <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;convert<span style=\"color: #000000;\">&#40;</span>varchar,@fech_lote,<span style=\"color: #000000;\">103</span><span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">'.'</span> + char<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">13</span><span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">'Desea Continuar?'</span> as Mensaje<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #00C800;\">return</span> <span style=\"color: #000000;\">2</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">update</span> st_lote set stock_act &nbsp; &nbsp; &nbsp;= stock_act - <span style=\"color: #000000;\">&#40;</span>@total_art * @total_uni<span style=\"color: #000000;\">&#41;</span>,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;@cantidad_act &nbsp;= stock_act - <span style=\"color: #000000;\">&#40;</span>@total_art * @total_uni<span style=\"color: #000000;\">&#41;</span>,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sstock_act &nbsp; &nbsp; = sstock_act - @stotal_art,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;@scantidad_act = sstock_act - @stotal_art<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #0000ff;\">where</span> co_art &nbsp; = @co_art<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;and co_alma &nbsp;= @co_alma<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;and nro_lote = @nro_lote<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @@error != <span style=\"color: #000000;\">0</span> or @@rowcount = <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">1</span> as Errores,<span style=\"color: #ff0000;\">'No se pudo actualizar el stock actual para el lote '</span> + <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;@nro_lote as Mensaje<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">RETURN</span> <span style=\"color: #000000;\">1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @cantidad_act < <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @r_stock_neg = <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @desde in <span style=\"color: #000000;\">&#40;</span><span style=\"color: #ff0000;\">'FACT'</span>,<span style=\"color: #ff0000;\">'COMP'</span><span style=\"color: #000000;\">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">3</span> as Errores,<span style=\"color: #ff0000;\">'No hay suficiente stock para el artículo '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_art<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">' almacén '</span> +<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rtrim<span style=\"color: #000000;\">&#40;</span>@co_alma<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">' Nro lote '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@nro_lote<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">'.'</span> + char<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">13</span><span style=\"color: #000000;\">&#41;</span> +<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #ff0000;\">'Stock actual: '</span> + convert<span style=\"color: #000000;\">&#40;</span>varchar,<span style=\"color: #000000;\">&#40;</span>@cantidad_act + <span style=\"color: #000000;\">&#40;</span>@total_art * @total_uni<span style=\"color: #000000;\">&#41;</span><span style=\"color: #000000;\">&#41;</span><span style=\"color: #000000;\">&#41;</span> <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;as Mensaje<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">return</span> <span style=\"color: #000000;\">3</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">else</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #00C800;\">if</span> @r_stock_neg = <span style=\"color: #000000;\">2</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">2</span> as Errores,<span style=\"color: #ff0000;\">'No hay suficiente stock para el artículo '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_art<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">' almacén '</span> +<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rtrim<span style=\"color: #000000;\">&#40;</span>@co_alma<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">' Nro lote '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@nro_lote<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">'.'</span> + char<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">13</span><span style=\"color: #000000;\">&#41;</span> +<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #ff0000;\">'Stock actual: '</span> + convert<span style=\"color: #000000;\">&#40;</span>varchar,<span style=\"color: #000000;\">&#40;</span>@cantidad_act + <span style=\"color: #000000;\">&#40;</span>@total_art * @total_uni<span style=\"color: #000000;\">&#41;</span><span style=\"color: #000000;\">&#41;</span><span style=\"color: #000000;\">&#41;</span> &nbsp;+ char<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">13</span><span style=\"color: #000000;\">&#41;</span> + <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #ff0000;\">'Desea Continuar?'</span> as Mensaje<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #00C800;\">return</span> <span style=\"color: #000000;\">2</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> <span style=\"color: #0000ff;\">exists</span> <span style=\"color: #000000;\">&#40;</span><span style=\"color: #0000ff;\">select</span> * <span style=\"color: #0000ff;\">from</span> art <span style=\"color: #0000ff;\">where</span> co_art = @co_art <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;and compuesto = <span style=\"color: #000000;\">1</span> <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;and @desde in <span style=\"color: #000000;\">&#40;</span><span style=\"color: #ff0000;\">'FACT'</span>,<span style=\"color: #ff0000;\">'COMP'</span><span style=\"color: #000000;\">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;and stock_act < @total_art<span style=\"color: #000000;\">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">select</span> @total_artc = <span style=\"color: #000000;\">&#40;</span>@total_art - stock_act<span style=\"color: #000000;\">&#41;</span> <span style=\"color: #0000ff;\">from</span> art <span style=\"color: #0000ff;\">where</span> co_art = @co_art<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exec @status_sal = pp_genera_compuesto @co_art,@co_alma,@total_artc,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;@tipo_stock,@costo_b,@fecha_mov, <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;@stotal_art,@costo_om,@total_uni,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;@co_us_in,@co_sucu,@r_stock_neg,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;@accion<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @status_sal != <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">return</span> <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br /><br />&nbsp;<span style=\"color: #00C800;\">if</span> not <span style=\"color: #0000ff;\">exists</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #0000ff;\">select</span> * <span style=\"color: #0000ff;\">from</span> st_almac <span style=\"color: #0000ff;\">where</span> co_art &nbsp;= @co_art and co_alma = @co_alma<span style=\"color: #000000;\">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Insert into st_almac <span style=\"color: #000000;\">&#40;</span>co_art, co_alma<span style=\"color: #000000;\">&#41;</span> values <span style=\"color: #000000;\">&#40;</span>@co_art, @co_alma<span style=\"color: #000000;\">&#41;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">update</span> st_almac set stock_act &nbsp; &nbsp; &nbsp;= stock_act - <span style=\"color: #000000;\">&#40;</span>@total_art * @total_uni<span style=\"color: #000000;\">&#41;</span>,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @cantidad_act &nbsp;= stock_act - <span style=\"color: #000000;\">&#40;</span>@total_art * @total_uni<span style=\"color: #000000;\">&#41;</span>,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sstock_act &nbsp; &nbsp; = sstock_act - @stotal_art,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @scantidad_act = sstock_act - @stotal_art<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #0000ff;\">where</span> co_art &nbsp;= @co_art<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;and co_alma = @co_alma<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @@error != <span style=\"color: #000000;\">0</span> or @@rowcount = <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">1</span> as Errores,<span style=\"color: #ff0000;\">'No se pudo actualizar el stock actual para el almacen '</span> + <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;@co_alma as Mensaje<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">RETURN</span> <span style=\"color: #000000;\">1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @cantidad_act < <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @r_stock_neg = <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @desde in <span style=\"color: #000000;\">&#40;</span><span style=\"color: #ff0000;\">'FACT'</span>,<span style=\"color: #ff0000;\">'COMP'</span><span style=\"color: #000000;\">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">3</span> as Errores,<span style=\"color: #ff0000;\">'No hay suficiente stock, en el almacén: '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_alma<span style=\"color: #000000;\">&#41;</span> +<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #ff0000;\">' para el artículo: '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_art<span style=\"color: #000000;\">&#41;</span> + &nbsp;<span style=\"color: #ff0000;\">' '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@des_art<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">'.'</span> + char<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">13</span><span style=\"color: #000000;\">&#41;</span> <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+ <span style=\"color: #ff0000;\">'Stock actual: '</span> + convert<span style=\"color: #000000;\">&#40;</span>varchar,<span style=\"color: #000000;\">&#40;</span>@cantidad_act + <span style=\"color: #000000;\">&#40;</span>@total_art * @total_uni<span style=\"color: #000000;\">&#41;</span><span style=\"color: #000000;\">&#41;</span><span style=\"color: #000000;\">&#41;</span> <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;as Mensaje<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">return</span> <span style=\"color: #000000;\">3</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">else</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #00C800;\">if</span> @r_stock_neg = <span style=\"color: #000000;\">2</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">2</span> as Errores,<span style=\"color: #ff0000;\">'No hay suficiente stock, en el almacén: '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_alma<span style=\"color: #000000;\">&#41;</span> +<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #ff0000;\">' para el artículo: '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_art<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">' '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@des_art<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">'.'</span> + <span style=\"color: #ff0000;\">' Stock actual: '</span> + <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;convert<span style=\"color: #000000;\">&#40;</span>varchar,<span style=\"color: #000000;\">&#40;</span>@cantidad_act + <span style=\"color: #000000;\">&#40;</span>@total_art * @total_uni<span style=\"color: #000000;\">&#41;</span><span style=\"color: #000000;\">&#41;</span><span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">'.'</span> + char<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">13</span><span style=\"color: #000000;\">&#41;</span> + <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #ff0000;\">'Desea Continuar?'</span> as Mensaje<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #00C800;\">return</span> <span style=\"color: #000000;\">2</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @scantidad_act < <span style=\"color: #000000;\">0</span> and @stotal_art != <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @r_stock_neg = <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @desde in <span style=\"color: #000000;\">&#40;</span><span style=\"color: #ff0000;\">'FACT'</span>,<span style=\"color: #ff0000;\">'COMP'</span><span style=\"color: #000000;\">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">3</span> as Errores,<span style=\"color: #ff0000;\">'No hay suficiente stock(Secun), en el almacén: '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_alma<span style=\"color: #000000;\">&#41;</span> +<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #ff0000;\">' para el artículo: '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_art<span style=\"color: #000000;\">&#41;</span> + &nbsp;<span style=\"color: #ff0000;\">' '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@des_art<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">'.'</span> + char<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">13</span><span style=\"color: #000000;\">&#41;</span> <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+ <span style=\"color: #ff0000;\">'Stock actual: '</span> + convert<span style=\"color: #000000;\">&#40;</span>varchar,<span style=\"color: #000000;\">&#40;</span>@scantidad_act + <span style=\"color: #000000;\">&#40;</span>@stotal_art * @total_uni<span style=\"color: #000000;\">&#41;</span><span style=\"color: #000000;\">&#41;</span><span style=\"color: #000000;\">&#41;</span> <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;as Mensaje<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">return</span> <span style=\"color: #000000;\">3</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">else</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #00C800;\">if</span> @r_stock_neg = <span style=\"color: #000000;\">2</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">2</span> as Errores,<span style=\"color: #ff0000;\">'No hay suficiente stock(Secun), en el almacén: '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_alma<span style=\"color: #000000;\">&#41;</span> +<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #ff0000;\">' para el artículo: '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_art<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">' '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@des_art<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">'.'</span> + <span style=\"color: #ff0000;\">' Stock actual: '</span> + <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;convert<span style=\"color: #000000;\">&#40;</span>varchar,<span style=\"color: #000000;\">&#40;</span>@scantidad_act + <span style=\"color: #000000;\">&#40;</span>@stotal_art * @total_uni<span style=\"color: #000000;\">&#41;</span><span style=\"color: #000000;\">&#41;</span><span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">'.'</span> + char<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">13</span><span style=\"color: #000000;\">&#41;</span> + <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #ff0000;\">'Desea Continuar?'</span> as Mensaje<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #00C800;\">return</span> <span style=\"color: #000000;\">2</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">update</span> art set stock_act &nbsp;= stock_act - <span style=\"color: #000000;\">&#40;</span>@total_art * @total_uni<span style=\"color: #000000;\">&#41;</span>,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sstock_act = sstock_act - @stotal_art <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #0000ff;\">where</span> co_art = @co_art<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @@error != <span style=\"color: #000000;\">0</span> or @@rowcount = <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">1</span> as Errores,<span style=\"color: #ff0000;\">'No se pudo disminuir el stock actual en la tabla de artículos '</span> + <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #ff0000;\">'para el artículo '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_art<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">' '</span> + @des_art as Mensaje<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">RETURN</span> <span style=\"color: #000000;\">1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br />&nbsp; &nbsp;end<br /><br /><span style=\"color: #B900B9;\">/******************************************************************************<br />* Proceso para el Stock por despachar. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />******************************************************************************/</span><br /><span style=\"color: #00C800;\">if</span> @tipo_stock = <span style=\"color: #ff0000;\">'stock_des'</span> <br />&nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @accion = <span style=\"color: #ff0000;\">'S'</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">update</span> art set stock_des = stock_des + <span style=\"color: #000000;\">&#40;</span>@total_art * @total_uni<span style=\"color: #000000;\">&#41;</span>,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sstock_des = sstock_des + @stotal_art<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #0000ff;\">where</span> co_art = @co_art<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @@error != <span style=\"color: #000000;\">0</span> or @@rowcount = <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">1</span> as Errores,<span style=\"color: #ff0000;\">'No se pudo aumentar el stock por despachar en la tabla de artículos '</span> + <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #ff0000;\">'para el artículo '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_art<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">' '</span> + @des_art as Mensaje<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">RETURN</span> <span style=\"color: #000000;\">1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> not <span style=\"color: #0000ff;\">exists</span> <span style=\"color: #000000;\">&#40;</span><span style=\"color: #0000ff;\">select</span> * <span style=\"color: #0000ff;\">from</span> st_almac <span style=\"color: #0000ff;\">where</span> co_alma = @co_alma<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; and co_art = @co_art<span style=\"color: #000000;\">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; insert into st_almac <span style=\"color: #000000;\">&#40;</span>co_alma,co_art<span style=\"color: #000000;\">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; values <span style=\"color: #000000;\">&#40;</span>@co_alma,@co_art<span style=\"color: #000000;\">&#41;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @@error != <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">1</span> as Errores,<span style=\"color: #ff0000;\">'No se pudo insertar registro en la tabla de st_almac para el stock por despachar '</span> +<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #ff0000;\">'para el artículo '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_art<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">' '</span> + @des_art + <span style=\"color: #ff0000;\">' en el almacén '</span> + <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rtrim<span style=\"color: #000000;\">&#40;</span>@co_alma<span style=\"color: #000000;\">&#41;</span> as Mensaje<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #00C800;\">RETURN</span> <span style=\"color: #000000;\">1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">update</span> st_almac set stock_des = stock_des + <span style=\"color: #000000;\">&#40;</span>@total_art * @total_uni<span style=\"color: #000000;\">&#41;</span>,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sstock_des = sstock_des + @stotal_art <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #0000ff;\">where</span> co_art = @co_art<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;and co_alma = @co_alma<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @@error != <span style=\"color: #000000;\">0</span> or @@rowcount = <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">1</span> as Errores,<span style=\"color: #ff0000;\">'No se pudo aumentar el stock por despachar en la tabla de artículos '</span> +<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #ff0000;\">'para el artículo '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_art<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">' '</span> + @des_art + <span style=\"color: #ff0000;\">' en el almacén '</span> + <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rtrim<span style=\"color: #000000;\">&#40;</span>@co_alma<span style=\"color: #000000;\">&#41;</span> as Mensaje<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">RETURN</span> <span style=\"color: #000000;\">1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br />&nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">else</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">update</span> st_almac set stock_des = stock_des - <span style=\"color: #000000;\">&#40;</span>@total_art * @total_uni<span style=\"color: #000000;\">&#41;</span>,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sstock_des = sstock_des - @stotal_art <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #0000ff;\">where</span> co_art = @co_art<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;and co_alma = @co_alma<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @@error != <span style=\"color: #000000;\">0</span> or @@rowcount = <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">1</span> as Errores,<span style=\"color: #ff0000;\">'No se pudo disminuir el stock por despachar en la tabla de artículos '</span> +<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #ff0000;\">'para el artículo '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_art<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">' '</span> + @des_art + <span style=\"color: #ff0000;\">' en el almacén '</span> + <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rtrim<span style=\"color: #000000;\">&#40;</span>@co_alma<span style=\"color: #000000;\">&#41;</span> as Mensaje<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">RETURN</span> <span style=\"color: #000000;\">1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">update</span> art set stock_des = stock_des - <span style=\"color: #000000;\">&#40;</span>@total_art * @total_uni<span style=\"color: #000000;\">&#41;</span>,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sstock_des = sstock_des - @stotal_art<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #0000ff;\">where</span> co_art = @co_art<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @@error != <span style=\"color: #000000;\">0</span> or @@rowcount = <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">1</span> as Errores,<span style=\"color: #ff0000;\">'No se pudo disminuir el stock por despachar en la tabla de artículos '</span> + <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #ff0000;\">'para el artículo '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_art<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">' '</span> + @des_art as Mensaje<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">RETURN</span> <span style=\"color: #000000;\">1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br />&nbsp; &nbsp;end<br /><br /><span style=\"color: #B900B9;\">/******************************************************************************<br />* Proceso para el Stock por entregar. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />******************************************************************************/</span><br /><span style=\"color: #00C800;\">if</span> @tipo_stock = <span style=\"color: #ff0000;\">'stock_lle'</span> <br />&nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @accion = <span style=\"color: #ff0000;\">'S'</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">update</span> art set stock_lle = stock_lle + <span style=\"color: #000000;\">&#40;</span>@total_art * @total_uni<span style=\"color: #000000;\">&#41;</span>,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sstock_lle = sstock_lle + @stotal_art<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #0000ff;\">where</span> co_art = @co_art<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @@error != <span style=\"color: #000000;\">0</span> or @@rowcount = <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">1</span> as Errores,<span style=\"color: #ff0000;\">'No se pudo aumentar el stock por llegar en la tabla de artículos '</span> + <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #ff0000;\">'para el artículo '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_art<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">' '</span> + @des_art as Mensaje<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">RETURN</span> <span style=\"color: #000000;\">1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> not <span style=\"color: #0000ff;\">exists</span> <span style=\"color: #000000;\">&#40;</span><span style=\"color: #0000ff;\">select</span> * <span style=\"color: #0000ff;\">from</span> st_almac <span style=\"color: #0000ff;\">where</span> co_alma = @co_alma<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; and co_art = @co_art<span style=\"color: #000000;\">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; insert into st_almac <span style=\"color: #000000;\">&#40;</span>co_alma,co_art<span style=\"color: #000000;\">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; values <span style=\"color: #000000;\">&#40;</span>@co_alma,@co_art<span style=\"color: #000000;\">&#41;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @@error != <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">1</span> as Errores,<span style=\"color: #ff0000;\">'No se pudo insertar registro en la tabla de st_almac para el stock poe llegar '</span> +<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #ff0000;\">'para el artículo '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_art<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">' '</span> + @des_art + <span style=\"color: #ff0000;\">' en el almacén '</span> +<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rtrim<span style=\"color: #000000;\">&#40;</span>@co_alma<span style=\"color: #000000;\">&#41;</span> as Mensaje<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #00C800;\">RETURN</span> <span style=\"color: #000000;\">1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">update</span> st_almac set stock_lle = stock_lle + <span style=\"color: #000000;\">&#40;</span>@total_art * @total_uni<span style=\"color: #000000;\">&#41;</span>,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sstock_lle = sstock_lle + @stotal_art <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #0000ff;\">where</span> co_art = @co_art<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;and co_alma = @co_alma<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @@error != <span style=\"color: #000000;\">0</span> or @@rowcount = <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">1</span> as Errores,<span style=\"color: #ff0000;\">'No se pudo aumentar el stock por llegar en la tabla de artículos '</span> +<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #ff0000;\">'para el artículo '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_art<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">' '</span> + @des_art + <span style=\"color: #ff0000;\">' en el almacén '</span> + <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rtrim<span style=\"color: #000000;\">&#40;</span>@co_alma<span style=\"color: #000000;\">&#41;</span> as Mensaje<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">RETURN</span> <span style=\"color: #000000;\">1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br />&nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">else</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">update</span> st_almac set stock_lle = stock_lle - <span style=\"color: #000000;\">&#40;</span>@total_art * @total_uni<span style=\"color: #000000;\">&#41;</span>,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sstock_lle = sstock_lle - @stotal_art <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #0000ff;\">where</span> co_art = @co_art<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;and co_alma = @co_alma<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @@error != <span style=\"color: #000000;\">0</span> or @@rowcount = <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">1</span> as Errores,<span style=\"color: #ff0000;\">'No se pudo aumentar el stock por llegar en la tabla de artículos '</span> +<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #ff0000;\">'para el artículo '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_art<span style=\"color: #000000;\">&#41;</span> + <span style=\"color: #ff0000;\">' '</span> + @des_art + <span style=\"color: #ff0000;\">' en el almacén '</span> + <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rtrim<span style=\"color: #000000;\">&#40;</span>@co_alma<span style=\"color: #000000;\">&#41;</span> as Mensaje<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">RETURN</span> <span style=\"color: #000000;\">1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">update</span> art set stock_lle = stock_lle - <span style=\"color: #000000;\">&#40;</span>@total_art * @total_uni<span style=\"color: #000000;\">&#41;</span>,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sstock_lle = sstock_lle - @stotal_art<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #0000ff;\">where</span> co_art = @co_art<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> @@error != <span style=\"color: #000000;\">0</span> or @@rowcount = <span style=\"color: #000000;\">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff;\">select</span> <span style=\"color: #000000;\">1</span> as Errores,<span style=\"color: #ff0000;\">'No se pudo disminuir el stock por llegar en la tabla de artículos '</span> + <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #ff0000;\">'para el artículo '</span> + rtrim<span style=\"color: #000000;\">&#40;</span>@co_art<span style=\"color: #000000;\">&#41;</span> &nbsp;+ <span style=\"color: #ff0000;\">' '</span> + @des_art as Mensaje<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">RETURN</span> <span style=\"color: #000000;\">1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br />&nbsp; &nbsp;end<br /><br /><span style=\"color: #00C800;\">RETURN</span><br />&nbsp;</div>[/code:2jdyjeb5]", "time": "20:40", "topic": "ADO STORED PROCEDURES", "username": "angstin" } ]
ADO STORED PROCEDURES
[ { "date": "2013-03-11", "forum": "FiveWin para Harbour/xHarbour", "text": "No trabajo mssql, imagino que el paso de parámetros debe estar normalizado para cualquier motor sql. Lo que no entiendo son las igualdades que ponés en el paso de parámetros po ej '@co_art='\"+xc_art', en MySql el paso sería solamente el valor. Acá se me acabó la sapiencia.\n\nSaludos", "time": "22:45", "topic": "ADO STORED PROCEDURES", "username": "horacio" } ]
ADO STORED PROCEDURES
[ { "date": "2013-03-12", "forum": "FiveWin para Harbour/xHarbour", "text": "Em sql server (microsoft) los store procedures se llaman con EXECUTE no con SELECT.\n\npor ejemplo, si necesito el SP me devuelva un recordset:\n\n[code=fw:1tc97y1v]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\"><br /><br />oClientes := adoRecordSet<span style=\"color: #000000;\">&#40;</span> oApp:<span style=\"color: #000000;\">oAdoConnector</span>, <span style=\"color: #ff0000;\">\"EXEC sp_buscar_cliente '\"</span> + aVars<span style=\"color: #000000;\">&#91;</span> <span style=\"color: #000000;\">1</span> <span style=\"color: #000000;\">&#93;</span> + <span style=\"color: #ff0000;\">\"'\"</span> <span style=\"color: #000000;\">&#41;</span><br /><span style=\"color: #0000ff;\">xBrowse</span><span style=\"color: #000000;\">&#40;</span> oClientes <span style=\"color: #000000;\">&#41;</span><br /><br /><span style=\"color: #00C800;\">Function</span> ADORecordSet<span style=\"color: #000000;\">&#40;</span> oConnect, cSql, lConnect <span style=\"color: #000000;\">&#41;</span><br /><br />&nbsp; &nbsp;<span style=\"color: #00C800;\">Local</span> oRs<br />&nbsp; &nbsp;<span style=\"color: #00C800;\">Local</span> cError := <span style=\"color: #ff0000;\">\"No se ha podido crear el objeto contenedor RECORDSET !\"</span><br /><br />&nbsp; &nbsp;<span style=\"color: #00C800;\">try</span><br />&nbsp; &nbsp; &nbsp; oRs := CreateObject<span style=\"color: #000000;\">&#40;</span><span style=\"color: #ff0000;\">\"ADODB.RecordSet\"</span><span style=\"color: #000000;\">&#41;</span><br />&nbsp; &nbsp; &nbsp; oRs:<span style=\"color: #000000;\">CursorLocation</span> &nbsp;:= <span style=\"color: #000000;\">3</span><br />&nbsp; &nbsp; &nbsp; oRs:<span style=\"color: #000000;\">LockType</span> &nbsp; &nbsp; &nbsp; &nbsp;:= <span style=\"color: #000000;\">4</span><br />&nbsp; &nbsp; &nbsp; oRs:<span style=\"color: #000000;\">ActiveConnection</span>:= oConnect<br />&nbsp; &nbsp; &nbsp; oRs:<span style=\"color: #000000;\">source</span> := cSql<br />&nbsp; &nbsp; &nbsp; oRs:<span style=\"color: #000000;\">Open</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span><br />&nbsp; &nbsp; &nbsp; lConnect := .t.<br />&nbsp; &nbsp;catch<br />&nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; msadoerror<span style=\"color: #000000;\">&#40;</span> cSql, <span style=\"color: #ff0000;\">\"Error de Conexion con servidor\"</span> <span style=\"color: #000000;\">&#41;</span><br />&nbsp; &nbsp; &nbsp; <span style=\"color: #00C800;\">return</span> <span style=\"color: #00C800;\">nil</span><br /><br />&nbsp; &nbsp;end <span style=\"color: #00C800;\">try</span><br /><br /><span style=\"color: #00C800;\">Return</span> oRS<br /><br /><br />&nbsp;</div>[/code:1tc97y1v]", "time": "13:28", "topic": "ADO STORED PROCEDURES", "username": "Simon" } ]
ADO STORED PROCEDURES
[ { "date": "2015-05-28", "forum": "FiveWin for Harbour/xHarbour", "text": "I using ors:sort := \"field1,field2\" but I get a error.\n\nDB Mysql CursorLocation = adUseClient.\n\nDoes anyone knows what might be the cause and how to solve it?", "time": "16:24", "topic": "ADO Sort error", "username": "AHF" } ]
ADO Sort error
[ { "date": "2015-05-29", "forum": "FiveWin for Harbour/xHarbour", "text": "Antonio\n\nI always put my sort values as parameters within parenthesis .. Try it this way:\n[code=fw:36lx90vt]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\"><br />oRs:<span style=\"color: #000000;\">sort</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"[field1],[field2]\"</span> <span style=\"color: #000000;\">&#41;</span> <br /> </div>[/code:36lx90vt] \n\nRick Lipkin", "time": "13:45", "topic": "ADO Sort error", "username": "Rick Lipkin" } ]
ADO Sort error
[ { "date": "2015-05-30", "forum": "FiveWin for Harbour/xHarbour", "text": "oRs:Sort := \"field1,field2\" is perfectly valid.\nBut oRs:Sort works only on client side recordsets", "time": "17:59", "topic": "ADO Sort error", "username": "nageswaragunupudi" } ]
ADO Sort error
[ { "date": "2015-06-01", "forum": "FiveWin for Harbour/xHarbour", "text": "Thanks!", "time": "18:52", "topic": "ADO Sort error", "username": "AHF" } ]
ADO Sort error
[ { "date": "2008-08-05", "forum": "FiveWin for Harbour/xHarbour", "text": "To All\r\n\r\nI have put together a simple sql query that joins two tables that I have cut and pasted out of MS SQL Studio.\r\n\r\nI know the query works .. every time I try to execute this query, my computer locks up .. any ideas here ??\r\n\r\nRick Lipkin\r\n\r\n//----------\r\n\r\ncSQL := \"SELECT proj.PROJECTEID, proj.PROJNAME, proj.DESCRIP, proj.START_DATE, proj.END_DATE, \"+;\r\n \"proj.EST_BUDGET, proj.FUNDED, proj.USEREID, proj.PROJMGR, \"+;\r\n \"proj.REPORTING, proj.FREQUENCYEID, proj.FREQUENCY, proj.ROW_COLOR, proj.EMAIL, \"+;\r\n \"proj.ACTIVE, proj.CONTRACT, proj.ENTRYBY, proj.ENTRYDATE, \"+;\r\n \"proj.CREATEDBY, proj.CREATEDATE, proj.UPDATED, spon.PROJECTEID AS Expr1, spon.SPONSORID \"+;\r\n \"FROM PROJECT AS proj INNER JOIN P_SPONSOR AS spon ON proj.PROJECTEID = spon.PROJECTEID \"+;\r\n \"WHERE (proj.PROJMGR = 'LIPKINRM') OR (spon.SPONSORID = 'LIPKINRM')\"\r\n\r\noRsProj := TOleAuto():New( \"ADODB.Recordset\" )\r\noRsProj:CursorType := 1 // opendkeyset\r\noRsProj:CursorLocation := 3 // local cache\r\noRsProj:LockType := 3 // lockoportunistic\r\n\r\nTRY\r\n oRsProj:Open( cSQL,'Provider='+xPROVIDER+';Data Source='+xSOURCE+';Initial Catalog='+xCATALOG+';User Id='+xUSERID+';Password='+xPASSWORD )\r\nCATCH oErr\r\n MsgInfo( \"Error in Opening PROJECT table\" )\r\n oDlg:End()\r\n RETURN(.F.)\r\nEND TRY", "time": "21:40", "topic": "ADO Sql Query limitations ??", "username": "Rick Lipkin" } ]
ADO Sql Query limitations ??
[ { "date": "2008-08-06", "forum": "FiveWin for Harbour/xHarbour", "text": "To All\r\n\r\nI have this problem FIXED .. as it turned out .. it had nothing directly to do with the query, but I was displaying cSQL on a title bar for a wait dialog box .. see code :\r\n\r\nIt was the length of the variable cSQL that was being passed on the title line that 'hosed' everything up .. Until I placed a few msgbox's before and after did I realize that the Openup() function was not even being executed .. The program stopped at the wrapper dialog ..\r\n\r\nI just could not believe it ..Thanks, the query ran as expected and returned all the rows it was supposed to !!!\r\n\r\nRick Lipkin\r\n\r\n//-------\r\n\r\ncLEVEL2 := \"Y\"\r\n\r\nDO CASE\r\nCASE xSUPER = 'Y'\r\n cSQL := \"SELECT * from PROJECT order by Projname\"\r\nCASE xPROJ = 'Y' .and. xSUPER <> 'Y'\r\n IF cLEVEL2 = \"N\"\r\n cSQL := \"SELECT * from PROJECT order by Projname\"\r\n ELSE\r\n\r\n cSQL := \"SELECT proj.PROJECTEID, proj.PROJNAME, proj.DESCRIP, proj.START_DATE, proj.END_DATE, \"+;\r\n \"proj.EST_BUDGET, proj.FUNDED, proj.USEREID, proj.PROJMGR, \"+;\r\n \"proj.REPORTING, proj.FREQUENCYEID, proj.FREQUENCY, proj.ROW_COLOR, proj.EMAIL, \"+;\r\n \"proj.ACTIVE, proj.CONTRACT, proj.ENTRYBY, proj.ENTRYDATE, \"+;\r\n \"proj.CREATEDBY, proj.CREATEDATE, proj.UPDATED, spon.PROJECTEID AS Expr1, spon.SPONSORID \"+;\r\n \"FROM PROJECT AS proj INNER JOIN P_SPONSOR AS spon ON proj.PROJECTEID = spon.PROJECTEID \"+;\r\n \"WHERE (proj.PROJMGR = 'LIPKINRM') OR (spon.SPONSORID = 'LIPKINRM')\"\r\n\r\n ENDIF\r\n\r\n\r\n\r\n//------------------\r\n\r\nSysReFresh()\r\n\r\nlOK := .F.\r\n\r\nDEFINE DIALOG oDlg ;\r\n FROM 5, 8 to 10, 75 ;\r\n TITLE \"Please be patient \" ; //+cSQL ; <--- here\r\n COLOR \"N/W\" ;\r\n STYLE nOr( WS_POPUP,WS_CAPTION,WS_THICKFRAME )\r\n\r\n cSAY := \"Opening Initial PROJECT Data Recordset\"\r\n\r\n @ 1,13 SAY oSay var cSAY of oDLG COLOR \"N/W\"\r\n oDLG:bStart := { | | lOK1 := _OpenUm(oDlg, cSQL, oWNDMDI, lFROMLINK, xPROJECTEID ) }\r\n\r\n\r\n\r\nACTIVATE DIALOG oDLG CENTERED\r\n\r\nIF lOK1 = .F.\r\n SysReFresh()\r\n RETURN(NIL)\r\nENDIF\r\n\r\nSysReFresh()\r\n\r\n_PBrow(oWndMdi, cSQL, lFROMLINK, xPROJECTEID, cLEVEL2 )\r\n\r\nSysReFresh()\r\nReturn(nil)\r\n\r\n//----------------\r\nStatic Func _OpenUm(oDlg, cSQL, oWNDMDI, lFROMLINK, xPROJECTEID )\r\n\r\nLOCAL oErr, SAYING, cSTRING, cFIND\r\n\r\n\r\nIF cSQL = \" \"\r\n cSQL := \"SELECT * FROM PROJECT order by projname\"\r\nENDIF\r\n\r\nSysReFresh()\r\n\r\noRsProj := TOleAuto():New( \"ADODB.Recordset\" )\r\noRsProj:CursorType := 1 // opendkeyset\r\noRsProj:CursorLocation := 3 // local cache\r\noRsProj:LockType := 3 // lockoportunistic\r\n\r\nTRY\r\n oRsProj:Open( cSQL,'Provider='+xPROVIDER+';Data Source='+xSOURCE+';Initial Catalog='+xCATALOG+';User Id='+xUSERID+';Password='+xPASSWORD )\r\nCATCH oErr\r\n MsgInfo( \"Error in Opening PROJECT table\" )\r\n oDlg:End()\r\n RETURN(.F.)\r\nEND TRY\r\n\r\nSysReFresh()\r\noDLG:END()", "time": "19:25", "topic": "ADO Sql Query limitations ??", "username": "Rick Lipkin" } ]
ADO Sql Query limitations ??
[ { "date": "2008-03-01", "forum": "FiveWin for Harbour/xHarbour", "text": "With DBF files, i use a listbox in a dialog and display the records of the DBF .\nIf the user want to search , he press the search button and write what he is looking for\n\nHow to do the same with record set, how to requery ??\n\n\nThanks for your help .\n=======================\nXbase sample:\n\nselect 0\nuse adresses\nset index to NAME\ngo top\nDEFINE DIALOG ...\nREDEFINE LISBOX oLbx FIELDS ...\nREDEFINE BUTTON .... ACTION (RESEARCH(),oLbx:upstable(),oLbx:refresh()\nACTIVATE DIALOG ...\n\n\n\n\nfunction RESEARCH()\nlocal av\nav:=space(20)\nif MsgGet (\" Recherche Patient \",\"Search :\",@av)\n seek trim(av)\nendif\nreturn .T.", "time": "15:42", "topic": "ADO Sql and Requery", "username": "Jack" } ]
ADO Sql and Requery
[ { "date": "2008-03-01", "forum": "FiveWin for Harbour/xHarbour", "text": "I use the sort option when I have multiple search possibliities .. consider this code :\n\noRs:Sort := \"fname\"\noRs:MoveFirst()\noRs:Find(\"fname = '\"+cFIND+\"'\" )\n\noLBX:ReFresh()\nSysReFresh()\n\n.. or\n\noRs:Sort := \"lname\"\noRs:MoveFirst()\noRs:Find(\"lname = '\"+cFIND+\"'\" )\n\noLBX:ReFresh()\nSysReFresh()\n\n..\n\nRick Lipkin", "time": "17:01", "topic": "ADO Sql and Requery", "username": "Rick Lipkin" } ]
ADO Sql and Requery
[ { "date": "2008-03-02", "forum": "FiveWin for Harbour/xHarbour", "text": "Rick,\nThanks for this answer but what have i to to\nif the date is not in the record set .\nI i have a table with 1 000 000 of records or more,\ni will not have : select * form table \ni will place a first scope : select * form table where NAME like \"J*\"\nand if the user want to llok for a name starting with R ...\nHow to refresh ?", "time": "18:56", "topic": "ADO Sql and Requery", "username": "Jack" } ]
ADO Sql and Requery
[ { "date": "2018-06-26", "forum": "FiveWin para Harbour/xHarbour", "text": "Buenas tardes, \nestoy comenzando a convertir mis bases de datos DBF a MYSQL. Una vez importadas las tablas en MYSQL me he encontrado con el problema de la anchura de los campos numéricos.\nPrimero probé con la propiedad nPrecision de los objetos Fields, pero para los tipos Int, TinyInt y BigInt siempre devuelven un valor fijo. \nYo necesito el valor entre paréntesis que aparece en la creación de la tabla, por ejemplo Int(5) es un ancho de 5, en cambio nPrecision es 10 y FWADOFieldLen() es 11.\n\nLo he conseguido solucionar usando el siguiente código :\n\n[code=fw:29ujis6j]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\">oRS := oCon:<span style=\"color: #000000;\">Execute</span> <span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"SHOW CREATE TABLE \"</span> + cTabla <span style=\"color: #000000;\">&#41;</span><br />cCreateTabla := oRs:<span style=\"color: #000000;\">Fields</span><span style=\"color: #000000;\">&#91;</span><span style=\"color: #000000;\">1</span><span style=\"color: #000000;\">&#93;</span>:<span style=\"color: #000000;\">value</span></div>[/code:29ujis6j]\n\nDe esta forma en la variable cCreateTabla se guarda una cadena de caracteres con la sentencia SQL que creó la tabla, como ejemplo :\n[quote:29ujis6j]CREATE TABLE `reembols` (\n\t`ID` INT(11) NOT NULL AUTO_INCREMENT,\n\t`SERIE1` VARCHAR(2) NULL DEFAULT NULL COLLATE 'utf8_spanish_ci',\n\t`TALON` BIGINT(20) NULL DEFAULT NULL,\n\t`SERIE2` VARCHAR(3) NULL DEFAULT NULL COLLATE 'utf8_spanish_ci',\n\t`NUMERO` BIGINT(20) NULL DEFAULT NULL,\n\t`CLIENTE` VARCHAR(25) NULL DEFAULT NULL COLLATE 'utf8_spanish_ci',\n\t`FECHA` DATE NULL DEFAULT NULL,\n\t`IMPORTE` DECIMAL(11,2) NULL DEFAULT NULL,\n\t`BANCO1` VARCHAR(8) NULL DEFAULT NULL COLLATE 'utf8_spanish_ci',\n\t`BANCO` TINYINT(2) NULL DEFAULT NULL,\n\t`APUNTE` INT(5) NULL DEFAULT NULL,\n\t`IBAN` VARCHAR(34) NULL DEFAULT NULL COLLATE 'utf8_spanish_ci',\n\tPRIMARY KEY (`ID`)\n)\n[/quote:29ujis6j]\nYa sólo queda buscar el nombre del campo que queramos y sacar el número entre paréntesis.\n\nExpongo esta solución por si le sirve a algún compañero del grupo y por si alguien conoce una forma más sencilla de obtenerlo.\n\nUn saludo.", "time": "17:57", "topic": "ADO anchura campos numéricos", "username": "gmart1" } ]
ADO anchura campos numéricos
[ { "date": "2018-06-26", "forum": "FiveWin para Harbour/xHarbour", "text": "gmart:\n\nPodrías crear los campos numérico como DECIMAL (5,2), de esa forma\nsiempre sabrás tamaño y cantidad de decimales.\n\nPara tomar en cuenta, MySql siempre guarda el contenido como tipo carácter\ny el punto decimal se almacena, por tanto si defines el tamaño como (5,2)\nel valor máximo no será 999.99 sino 99.99.\n\nmis 2 centavos.\n\nSaludos", "time": "19:32", "topic": "ADO anchura campos numéricos", "username": "Armando" } ]
ADO anchura campos numéricos
[ { "date": "2018-06-27", "forum": "FiveWin para Harbour/xHarbour", "text": "Muchas gracias Armando,\nen mi caso estoy usando la función FW_ADOImportFromDBF para importar los DBF en MYSQL y me he encontrado que las tablas creadas automáticamente tienen campos BigInt, TinyInt, Int y Decimal.\nAdemás no ha respetado el ancho que tenían originalmente en las DBF, intentaré investigar esa función para adaptarla a lo que quiero.\n\nPor lo que me dices si necesito un campo Int(5), al pasarlo a Decimal sería (8,2). Lo tendré en cuenta, aunque con la solución que he encontrado me sirve.\n\nNo sé si \"SHOW CREATE TABLE\" sólo la tiene MySQL, pero es el motor de base de datos que voy a usar y por ahora sigo en la adaptación a MySQL con ADO.\n\nUn saludo.", "time": "14:04", "topic": "ADO anchura campos numéricos", "username": "gmart1" } ]
ADO anchura campos numéricos
[ { "date": "2018-06-27", "forum": "FiveWin para Harbour/xHarbour", "text": "With DBF, { \"fieldname\", \"N\", 6, 2 } uses 8 bytes including \"-\" sign and decimal. So it can store from -99.99 to 999.99.\n\nIn MySql (and many other RDBS), DECIMAL( 5, 2 ) can store -999.99 to 999.99\n\nIntegers:\nMySQL INT takes only 4 bytes of storage space on the disk, but can contain values from -2147483648 to 2147483647. This is equivalent to Numeric 11,0 in DBF.\n\nIf we want to store a number in this range, do we like to waste 11 bytes of space in MySql or just use 4 bytes only. In addition INT is a lot faster than Decimal.", "time": "15:26", "topic": "ADO anchura campos numéricos", "username": "nageswaragunupudi" } ]
ADO anchura campos numéricos
[ { "date": "2018-06-28", "forum": "FiveWin para Harbour/xHarbour", "text": "Muchas gracias Rao, \nlo tendré en cuenta para el diseño de mis tablas cuando esté funcionando al 100 por 100 con ADO y MySQL.\n\nUn saludo.", "time": "13:50", "topic": "ADO anchura campos numéricos", "username": "gmart1" } ]
ADO anchura campos numéricos
[ { "date": "2015-06-18", "forum": "FiveWin for Harbour/xHarbour", "text": "Hello,\nI have an invoice file with a field InvoiceNumber, when the user add a record, the invoice number must be the last one + 1\n\nIn a SQL network environment, how can i be shure that dont have 2 times the same number .\n\nWith DBF, when i want to do the same, i open an other file (LOCK.DBF) in EXCLUSIVE MODE and. if neterr() return .T. ,\ni select the INVOICE file, go bottom , place last invoicenumber in memory, i add a new record in INVOICE file , replace InvoiceNumber with last one+1 and than i close the LOCK file .\nIf an other user try to add a record at same time, the EXCLUSIVE MODE (LOCK.DBF) return FALSE and the user is invited to try again .\n\nHow to do this with SQL code ?\n\nThanks\n\nI", "time": "07:30", "topic": "ADO and Lock", "username": "Jack" } ]
ADO and Lock
[ { "date": "2015-06-18", "forum": "FiveWin for Harbour/xHarbour", "text": "The easiest and the most reliable way is to create the invoiceno field as an autoincrement field.\nNote: Even for DBFs (using DBFCDX) this is the current practice to use autoincrement field.\nFW functions for ADO make it very easy to implement", "time": "09:03", "topic": "ADO and Lock", "username": "nageswaragunupudi" } ]
ADO and Lock
[ { "date": "2015-06-18", "forum": "FiveWin for Harbour/xHarbour", "text": "I agree with you BUTthe custumer ask me to reset the counter to 1 each month.\n\nThere is a prefix in front of the invoice number who is YYYYMM-invoice number ==> 201506-0001 .....\n\nThanks for your help .", "time": "09:17", "topic": "ADO and Lock", "username": "Jack" } ]
ADO and Lock
[ { "date": "2015-06-18", "forum": "FiveWin for Harbour/xHarbour", "text": "Understand.\nI'll be back with a proposal in a while", "time": "09:26", "topic": "ADO and Lock", "username": "nageswaragunupudi" } ]
ADO and Lock
[ { "date": "2015-06-18", "forum": "FiveWin for Harbour/xHarbour", "text": "Hi,\n\nYou can define a field as unique and there is no chance to have 2 same values\n\nBest regards,", "time": "10:00", "topic": "ADO and Lock", "username": "avista" } ]
ADO and Lock
[ { "date": "2015-06-18", "forum": "FiveWin for Harbour/xHarbour", "text": "Jack\n\nTo my knowledge there is not a ( good ) way to lock a Sql table ... and the Ole provider usually handles all the 'opportunistic' locks for you.\n\nWith that said .. I have come up with a table called [InvoiceNumbers] and when a person wishes to create a new Invoice, I open the [InvoiceNumber] table, go to the bottom in Ascending order and add a new record +1 and immediately assign the new transaction the next Invoice Number oRs:Update() .. and out, ready for the next transaction, which works quite will in a multi-user application. \n\nIf the User wishes to cancel the transaction before I commit the detail .. so be it. There is just a sequence gap in the committed Invoice transactions.\n\nRao does have a GOOD point about using an AutoNumber on the InvoiceNumber field letting the database issue the next number, however using AutoNumber especially on a primary key can EASILY lead to 'Sql Injection' from a malicious attacker that may ( covertly ) gain access to your system, as 'unlikely' as that may be .. Database Security is a BIG issue today and creating your Own Invoices Numbers under program control ( not database control ) is a good ( security ) selling point.\n\nRick Lipkin", "time": "13:55", "topic": "ADO and Lock", "username": "Rick Lipkin" } ]
ADO and Lock
[ { "date": "2015-06-18", "forum": "FiveWin for Harbour/xHarbour", "text": "Jack,\n\nI put a unique index on the invoice-number.\nEach time a customer add a new invoice I check for the last invoice number (Query with a desc order on invoice-number and a limit of 1).\nThen I add directly an empty record with that invoice number to the table. So, if someone else whant to add an invoice, he will get a higher number. In an other table I record that someone is using that invoice, so nobody else can modify than invoice. Only when it is finished...", "time": "15:55", "topic": "ADO and Lock", "username": "Marc Vanzegbroeck" } ]
ADO and Lock
[ { "date": "2015-06-18", "forum": "FiveWin for Harbour/xHarbour", "text": "Marc,\nIs it possible to give a sample of code .\n\nI read in the past that it is possible to use a SQL table in exclusive mode , how to ?\n\nThanks.", "time": "19:53", "topic": "ADO and Lock", "username": "Jack" } ]
ADO and Lock
[ { "date": "2015-06-18", "forum": "FiveWin for Harbour/xHarbour", "text": "An Auto-increment field is a double edge sword that I would avoid as invoice numbers. One of the potential problems that can arise with auto-increment fields is that if the table is later merged o copied to another table, append from another table, or transported somewhere else, or even if restructured -these numbers will change. i.e... you don't have any control over auto-increment fields.\n\nRestarting sequences every month will generate duplicated invoice numbers. I think you'd want to keep monthly sequences a part from invoice numbers which must be unique. \n\nIn this case I would declare the field as \"unique\" -that will ensure that even if badly coded, the invoice number will not be duplicated. It wouldn't be too hard to obtain the last invoice number used with a sql sentence using max. Then inside a transaction I would -try-and-retry to create the record with max(invoice#) + 1. The trying-and-re-trying inside a transaction will help solve the problem of other users racing to create an invoice # with the same number.\n\nI hope that helps.\n\n\nReinaldo.", "time": "22:09", "topic": "ADO and Lock", "username": "reinaldocrespo" } ]
ADO and Lock
[ { "date": "2015-08-04", "forum": "FiveWin for Harbour/xHarbour", "text": "I am back with this problem .\n\nCould someone share some sample of code of transaction with fivewin .\n\nThanks", "time": "19:33", "topic": "ADO and Lock", "username": "Jack" } ]
ADO and Lock
[ { "date": "2015-08-05", "forum": "FiveWin for Harbour/xHarbour", "text": "Hello\n\n I have DBF file \n AADD (aDbf, {\"XXXXX\", \"L\", 1 , 0 }) \n\n when I print the Invoice I open the file in in exclusive mode\n Dbusearea(.F. ,\"DBFCDX\" , m->E7 + ::cFile ,::oDbfMov:cAlias ,.T. ,.F.)\n\n I use the same method with SQL. \n\nRegards Maurizio\n<!-- w --><a class=\"postlink\" href=\"http://www.nipeservice.com\">www.nipeservice.com</a><!-- w -->", "time": "07:34", "topic": "ADO and Lock", "username": "Maurizio" } ]
ADO and Lock
[ { "date": "2015-08-05", "forum": "FiveWin for Harbour/xHarbour", "text": "[quote=\"nageswaragunupudi\":3r9ydpse]The easiest and the most reliable way is to create the invoiceno field as an autoincrement field.\nNote: Even for DBFs (using DBFCDX) this is the current practice to use autoincrement field.\nFW functions for ADO make it very easy to implement[/quote:3r9ydpse]\n\nHi Mr. Rao,\n\nHow Can I define autoincrement field in DBFCDX. \n\nThanks.", "time": "08:07", "topic": "ADO and Lock", "username": "Horizon" } ]
ADO and Lock
[ { "date": "2015-08-05", "forum": "FiveWin for Harbour/xHarbour", "text": "[code=fw:1w3d98sw]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\"><br />Hi...<br /><br />In addition <span style=\"color: #0000ff;\">to</span> controlling the row, I check <span style=\"color: #00C800;\">if</span> the <span style=\"color: #00C800;\">new</span> invoice number <span style=\"color: #0000ff;\">exists</span> in the transaction table, since it is feasible that someone consecutive alter table, <span style=\"color: #00C800;\">for</span> which use the following SQL with php :<br /><br /><span style=\"color: #00C800;\">function</span> bloqueaDesbloqueaTablaConsecutivo<span style=\"color: #000000;\">&#40;</span>$conn,$lBloTab<span style=\"color: #000000;\">&#41;</span> <span style=\"color: #000000;\">&#123;</span><br /><br />    $cSenEje  = <span style=\"color: #ff0000;\">\"UNLOCK TABLES;\"</span>;<br />    <span style=\"color: #00C800;\">if</span> <span style=\"color: #000000;\">&#40;</span> $lBloTab == <span style=\"color: #000000;\">1</span> <span style=\"color: #000000;\">&#41;</span> <span style=\"color: #000000;\">&#123;</span><br />       $cSenEje  = <span style=\"color: #ff0000;\">\"LOCK TABLES consecutivos AS sec WRITE, transainventarios  WRITE, conceptosinventarios AS con WRITE;\"</span>;<br />    <span style=\"color: #000000;\">&#125;</span>;   <br />  $stmt=$conn->prepare<span style=\"color: #000000;\">&#40;</span>$cSenEje<span style=\"color: #000000;\">&#41;</span>;<br />  $stmt->setFetchMode<span style=\"color: #000000;\">&#40;</span>PDO::<span style=\"color: #000000;\">FETCH_ASSOC</span><span style=\"color: #000000;\">&#41;</span>;<br />    $stmt->execute<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span>;    <br />    $registros = $stmt->rowCount<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span>;<br />    unset<span style=\"color: #000000;\">&#40;</span>$stmt<span style=\"color: #000000;\">&#41;</span>; <br />    <br /><span style=\"color: #000000;\">&#125;</span>   <br /><br />Johnson Russi <br /><br /> </div>[/code:1w3d98sw]", "time": "14:30", "topic": "ADO and Lock", "username": "russimicro" } ]
ADO and Lock
[ { "date": "2015-08-05", "forum": "FiveWin for Harbour/xHarbour", "text": "Instead of using an AutoIncrement field -for the reasons I have argued above on this thread- one way to solve this problem is to create a unique index based on the Invoice No field. When you try to insert a new record with an existing invoice number it will fail. After recovering, have the code continue to iterate until successful. \n\nLike I said above, IMHO auto increment fields do not make good invoice numbers. If you ever merge data, replicate, res-structure, move records, you will not have any control over these auto-incremented values and they may reset creating havoc with child-relationships.\n\nIf you still prefer to use auto-increment field as invoice numbers here is sample code similar to clipper's syntax:\n[url:onp3c0ox]http&#58;//www&#46;dbase&#46;com/Knowledgebase/dbulletin/bu02_c&#46;htm[/url:onp3c0ox]\n\nHope that helps.\n\n\nReinaldo.", "time": "15:11", "topic": "ADO and Lock", "username": "reinaldocrespo" } ]
ADO and Lock
[ { "date": "2015-08-05", "forum": "FiveWin for Harbour/xHarbour", "text": "Horizon,\n\n[quote:182kpnr9]How Can I define autoincrement field in DBFCDX.[/quote:182kpnr9]\n\nDefine it with the type \"+\"\n\nJames", "time": "15:53", "topic": "ADO and Lock", "username": "James Bott" } ]
ADO and Lock
[ { "date": "2015-08-06", "forum": "FiveWin for Harbour/xHarbour", "text": "[quote=\"James Bott\":2sy6tb1t]Horizon,\n\n[quote:2sy6tb1t]How Can I define autoincrement field in DBFCDX.[/quote:2sy6tb1t]\n\nDefine it with the type \"+\"\n\nJames[/quote:2sy6tb1t]\n\nThank you James. Is it possible to set a number to autoincrement field as a starting number?", "time": "12:47", "topic": "ADO and Lock", "username": "Horizon" } ]
ADO and Lock
[ { "date": "2015-08-06", "forum": "FiveWin for Harbour/xHarbour", "text": "Hakan,\n\n[quote:2plxszwg]Is it possible to set a number to autoincrement field as a starting number?[/quote:2plxszwg]\n\nI don't believe there is a command for that. You could try adding one less records than the starting number you want, then doing a table TRUNCATE command (or ZAP if you are using the ADORDD) and see if that works. I suspect it will just start at 1 again. Maybe you could delete all but the last record.\n\nKeep in mind the things that Reinaldo mentioned previously in this thread about all the different issues with using autoincrement fields as IDs. The table can end up with new numbers in the field in several circumstances.\n\nJames\n\nUpdate: Sorry, I was thinking you were asking about SQL instead of DBFCDX. I don't know the answer for DBFCDX as I just discovered there was an autoincrement fieldtype recently myself, so I have not worked with them.", "time": "16:13", "topic": "ADO and Lock", "username": "James Bott" } ]
ADO and Lock
[ { "date": "2015-08-06", "forum": "FiveWin for Harbour/xHarbour", "text": "[quote=\"James Bott\":3qap0zx0]Hakan,\n\n[quote:3qap0zx0]Is it possible to set a number to autoincrement field as a starting number?[/quote:3qap0zx0]\n\nI don't believe there is a command for that. You could try adding one less records than the starting number you want, then doing a table TRUNCATE command (or ZAP if you are using the ADORDD) and see if that works. I suspect it will just start at 1 again. Maybe you could delete all but the last record.\n\nKeep in mind the things that Reinaldo mentioned previously in this thread about all the different issues with using autoincrement fields as IDs. The table can end up with new numbers in the field in several circumstances.\n\nJames\n\nUpdate: Sorry, I was thinking you were asking about SQL instead of DBFCDX. I don't know the answer for DBFCDX as I just discovered there was an autoincrement fieldtype recently myself, so I have not worked with them.[/quote:3qap0zx0]\n\nThank you James.", "time": "19:04", "topic": "ADO and Lock", "username": "Horizon" } ]
ADO and Lock
[ { "date": "2015-08-07", "forum": "FiveWin for Harbour/xHarbour", "text": "[code=fw:2o5jar0p]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\"><br />DbFieldInfo<span style=\"color: #000000;\">&#40;</span> DBS_COUNTER, <span style=\"color: #000000;\">1</span>, <span style=\"color: #000000;\">10</span><span style=\"color: #000000;\">&#41;</span> <span style=\"color: #B900B9;\">//Set autoincremt to 10</span><br />DbFieldInfo<span style=\"color: #000000;\">&#40;</span> DBS_STEP, <span style=\"color: #000000;\">1</span>, <span style=\"color: #000000;\">4</span><span style=\"color: #000000;\">&#41;</span> <span style=\"color: #B900B9;\">//Set Step to 4</span></div>[/code:2o5jar0p]", "time": "07:06", "topic": "ADO and Lock", "username": "Biel EA6DD" } ]
ADO and Lock
[ { "date": "2015-08-07", "forum": "FiveWin for Harbour/xHarbour", "text": "Biel,\n\n[quote:or83td8y]DbFieldInfo( DBS_COUNTER, 1, 10) //Set autoincremt to 10[/quote:or83td8y]\n\nI am guessing that sets the next number to be 10?\n\nJames", "time": "16:46", "topic": "ADO and Lock", "username": "James Bott" } ]
ADO and Lock
[ { "date": "2015-08-10", "forum": "FiveWin for Harbour/xHarbour", "text": "[quote=\"James Bott\":2wwyvqk6]\nI am guessing that sets the next number to be 10?\n\nJames[/quote:2wwyvqk6]\n\nJames,\n that is, next number will be 10.", "time": "09:24", "topic": "ADO and Lock", "username": "Biel EA6DD" } ]
ADO and Lock
[ { "date": "2015-08-24", "forum": "FiveWin for Harbour/xHarbour", "text": "Hello everyone;\n\nAs you see from my previous posts, I do not like auto-increment fields as unique invoice numbers and I have explained why. I've also explained how a unique index on the invoice number can easily and safely solve the problem. \n\nOn this post I offer some SQL code (ADS compatible) that relies on a RowVersion field type to accomplish the same. This is how I use it on my applications. The idea here is to keep a single sequences table where all sequences are kept. The table fields are \"TableName\", \"FieldName\", \"Sequence\" and \"RowVersion\". This last field is of type row version. Whenever a new sequences for any given field on a table is needed, simply update the sequence by adding 1 as long as the rowversion field hasn't changed, we can guarantee no one else has changed the field on a race condition. \n\nJust like auto-inc fields rowversion fields are maintained by the SQL engine and incremented anytime a record is updated.\n\nHere is the code which explains itself a lot better than words:\n\n[code=fw:231a9f9o]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\"><span style=\"color: #B900B9;\">//-------------------------------------------------</span><br /><span style=\"color: #B900B9;\">//</span><br />DECLARE @num INTEGER ;<br />DECLARE @rv INTEGER ;<br />DECLARE @numrows INTEGER ;<br />DECLARE @c CUROSR AS <span style=\"color: #0000ff;\">SELECT</span> <span style=\"color: #000000;\">&#91;</span>sequence<span style=\"color: #000000;\">&#93;</span>, <span style=\"color: #000000;\">&#91;</span>rowversion<span style=\"color: #000000;\">&#93;</span> <span style=\"color: #0000ff;\">FROM</span> sequences <span style=\"color: #0000ff;\">WHERE</span> table = :<span style=\"color: #000000;\">table</span> AND field = :<span style=\"color: #000000;\">field</span>;<br /><br />@numrows = <span style=\"color: #000000;\">0</span> ;<br /><br /><span style=\"color: #00C800;\">WHILE</span> @numrows=<span style=\"color: #000000;\">0</span> <span style=\"color: #00C800;\">DO</span><br /><br />&nbsp; OPEN @c;<br />&nbsp; FETCH @c;<br /><br />&nbsp; @rv   = @c.rowversion ;<br />&nbsp; @num  = @c.rowversion + <span style=\"color: #000000;\">1</span> ;<br />&nbsp; CLOSE @c;<br /><br />&nbsp; <span style=\"color: #B900B9;\">//if rowversion has changed then someone else has updated the record.</span><br />&nbsp; <span style=\"color: #0000ff;\">UPDATE</span> Sequences SET <span style=\"color: #000000;\">&#91;</span>Sequence<span style=\"color: #000000;\">&#93;</span> = @num <span style=\"color: #0000ff;\">WHERE</span> <span style=\"color: #000000;\">&#91;</span>rowversion<span style=\"color: #000000;\">&#93;</span> = @rv;  <br /><br />&nbsp; @numrows = ::<span style=\"color: #000000;\">stmt</span>.UpdateCount ;<br /><br />END;<br /><span style=\"color: #0000ff;\">SELECT</span> @num <span style=\"color: #0000ff;\">FROM</span> system.iota ;<br /><span style=\"color: #B900B9;\">//-------------------------------------------------</span><br /> </div>[/code:231a9f9o]\n\nYou might have to translate this code into the SQL flavor being used but you get the idea.\n\nReinaldo.", "time": "20:57", "topic": "ADO and Lock", "username": "reinaldocrespo" } ]
ADO and Lock
[ { "date": "2015-08-25", "forum": "FiveWin for Harbour/xHarbour", "text": "I have a similar table that I use to track and generate new ID numbers that I use with DBFs. Since we can use both SQL tables and DBFs in the same app, I am thinking I can continue to use the same DBF which allows locking and thus is a simple solution.\n\nI also have a database class that has auto-incrementing using the above table, so I can solve the SQL auto-increment issue too. I think I can implement both of these with the new ADORDD by simply making one change--adding the VIA clause to the sequencing DBF, so that it is uses the DBFCDX RDD.\n\nJames", "time": "16:35", "topic": "ADO and Lock", "username": "James Bott" } ]
ADO and Lock
[ { "date": "2015-08-26", "forum": "FiveWin for Harbour/xHarbour", "text": "James,\n\nWith adordd with SET ADO FORCE LOCK ON no other user or other app (using clipper compatible locking) can alter the table lock or exclusive or record locked hold by you. \n\nWith this set ON the FILE LOCK, RECORD LOCK, EXCLUSIVE USE are guaranteed.", "time": "09:49", "topic": "ADO and Lock", "username": "AHF" } ]
ADO and Lock
[ { "date": "2015-08-26", "forum": "FiveWin for Harbour/xHarbour", "text": "Antonio F.\n\nThanks for confirming that. I have been meaning to ask about it.\n\nSo, it seems, that my original auto-incrementing system should still work with the ADORDD. I will do some testing to confirm it.\n\nUsing the ADORDD is too easy, where's the challenge? <!-- s;-) --><img src=\"{SMILIES_PATH}/icon_wink.gif\" alt=\";-)\" title=\"Wink\" /><!-- s;-) -->\n\nKeep working your magic, Antonio.\n\nRegards,\nJames", "time": "15:21", "topic": "ADO and Lock", "username": "James Bott" } ]
ADO and Lock
[ { "date": "2015-08-26", "forum": "FiveWin for Harbour/xHarbour", "text": "Interesting.\n\nI use a single file on the server that contains all unique counters ( ie. invoice numbers, client account numbers, etc ). When someone wants to create a new invoice, a very simple call grabs the last number used, increments it, saves it, and gives it to the client machine. This takes a fraction of a second.\n\nOver all the years I've used the system, with probably millions of invoices generated on systems from1 to 20 users, I've never had a single duplicate number generated.\n\nTim", "time": "16:58", "topic": "ADO and Lock", "username": "TimStone" } ]
ADO and Lock
[ { "date": "2015-08-27", "forum": "FiveWin for Harbour/xHarbour", "text": "In a Sql concept,you will do :\n\noRs:Open(\"select ID FROM TABLE1\",oCon)\nwid:=oRs:Fields(\"ID\"):Value\nwid:=wid+1\nUPDATE TABLE1 SET ID=wid\n*\nHow can you lock, how are you sure that this code is not execute at the same time from another computer using the same application .\n\n======= \n\nIn DBF concept , you can open the TABLE1 in EXCLUSIVE and nobody else can modify the record .\n\nAny idea ?\n\nThanks", "time": "10:51", "topic": "ADO and Lock", "username": "Jack" } ]
ADO and Lock
[ { "date": "2015-08-27", "forum": "FiveWin for Harbour/xHarbour", "text": "Just some ideas.\nI would prefer the 2nd one.\nAnother alternative in MySql is SELECT ... FOR UPDATE this locks the records.\n\n[code=fw:2urumznq]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\"><br />oRs:<span style=\"color: #000000;\">Open</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #ff0000;\">\"select ID FROM TABLE1\"</span>,oCon<span style=\"color: #000000;\">&#41;</span><br />wid:=oRs:<span style=\"color: #000000;\">Fields</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #ff0000;\">\"ID\"</span><span style=\"color: #000000;\">&#41;</span>:<span style=\"color: #000000;\">Value</span> <span style=\"color: #000000;\">+1</span><br />oRs:<span style=\"color: #000000;\">Fields</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #ff0000;\">\"ID\"</span><span style=\"color: #000000;\">&#41;</span>:<span style=\"color: #000000;\">Value</span> :=wid<br /><span style=\"color: #00C800;\">try</span><br />&nbsp; oRs:<span style=\"color: #0000ff;\">update</span> <span style=\"color: #B900B9;\">//if it has been changed in underlying data by others it will fail</span><br />catch<br />&nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> &nbsp;oRs:<span style=\"color: #000000;\">Fields</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #ff0000;\">\"ID\"</span><span style=\"color: #000000;\">&#41;</span>:<span style=\"color: #000000;\">Value</span> <> wid<br />&nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #B900B9;\">//update fail</span><br />&nbsp; &nbsp;<span style=\"color: #00C800;\">endif</span><br />end<br />&nbsp;</div>[/code:2urumznq]\n\n[code=fw:2urumznq]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\"><br />oRs:<span style=\"color: #000000;\">Open</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #ff0000;\">\"select ID FROM TABLE1\"</span>,oCon<span style=\"color: #000000;\">&#41;</span><br />wid:=oRs:<span style=\"color: #000000;\">Fields</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #ff0000;\">\"ID\"</span><span style=\"color: #000000;\">&#41;</span>:<span style=\"color: #000000;\">Value</span><span style=\"color: #000000;\">+1</span><br /><span style=\"color: #0000ff;\">UPDATE</span> TABLE1 SET <span style=\"color: #0000ff;\">ID</span>=widwhere <span style=\"color: #0000ff;\">ID</span> = wid <span style=\"color: #000000;\">-1</span><br />oRs:<span style=\"color: #000000;\">Resync</span> &nbsp;<span style=\"color: #B900B9;\">//in this table no one can delete records otherwise this might fail</span><br />&nbsp; &nbsp; <span style=\"color: #00C800;\">if</span> &nbsp;oRs:<span style=\"color: #000000;\">Fields</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #ff0000;\">\"ID\"</span><span style=\"color: #000000;\">&#41;</span>:<span style=\"color: #000000;\">Value</span> <> wid<br />&nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #B900B9;\">//update fail</span><br />&nbsp; &nbsp;<span style=\"color: #00C800;\">endif</span><br />&nbsp;</div>[/code:2urumznq]", "time": "12:03", "topic": "ADO and Lock", "username": "AHF" } ]
ADO and Lock
[ { "date": "2013-07-09", "forum": "FiveWin for Harbour/xHarbour", "text": "Hi All\n\nI a trying to use MySQL and ADO - I have a connection to the database and can open a table \nbut not sure what code to use to add records - according to a wiki page I found called ado-related stuff I can do the following\n\noRs:AddNew()\noRs:Fields('code'):Value := 'Test')\noRs:Update()\n\nThat code does not produce any errors but the record is not added\n\nthe other way is to use a insert statement which I have got to work.\n\nIs it worth using AdoRDD ( not sure if it works with xHarbour or where I get it from ) \n\nCheers\n\nColin", "time": "10:18", "topic": "ADO and MySql", "username": "Colin Haig" } ]
ADO and MySql
[ { "date": "2013-07-09", "forum": "FiveWin for Harbour/xHarbour", "text": "Hello,\n\nPlease, see TDataRow class explained in whatsnew.txt.\n\nVery good class.", "time": "11:01", "topic": "ADO and MySql", "username": "lucasdebeltran" } ]
ADO and MySql
[ { "date": "2013-07-09", "forum": "FiveWin for Harbour/xHarbour", "text": "Colin\n\nNothing specifically wrong with your addnew() and Update() .. please check how you create your Recordset and I suggest using these parameters :\n\n[code=fw:3o04bzri]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\"><br />oRs := TOleAuto<span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span>:<span style=\"color: #00C800;\">New</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"ADODB.Recordset\"</span> <span style=\"color: #000000;\">&#41;</span><br />oRs:<span style=\"color: #000000;\">CursorType</span>     := <span style=\"color: #000000;\">1</span>        <span style=\"color: #B900B9;\">// opendkeyset</span><br />oRs:<span style=\"color: #000000;\">CursorLocation</span> := <span style=\"color: #000000;\">3</span>        <span style=\"color: #B900B9;\">// local cache</span><br />oRs:<span style=\"color: #000000;\">LockType</span>       := <span style=\"color: #000000;\">3</span>        <span style=\"color: #B900B9;\">// lockoportunistic</span><br /><br />cSql := <span style=\"color: #ff0000;\">\"Select * From [YourTable] \"</span><br /><br /><span style=\"color: #00C800;\">TRY</span><br />   oRs:<span style=\"color: #000000;\">Open</span><span style=\"color: #000000;\">&#40;</span> cSQL,xCONNECT <span style=\"color: #000000;\">&#41;</span><br />CATCH oErr<br />   <span style=\"color: #0000ff;\">MsgInfo</span><span style=\"color: #000000;\">&#40;</span> <span style=\"color: #ff0000;\">\"Error in Opening YOURTABLE table\"</span> <span style=\"color: #000000;\">&#41;</span><br />   <span style=\"color: #00C800;\">RETURN</span><span style=\"color: #000000;\">&#40;</span>.F.<span style=\"color: #000000;\">&#41;</span><br />END <span style=\"color: #00C800;\">TRY</span><br /><br />oRs:<span style=\"color: #000000;\">AddNew</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span><br />oRs:<span style=\"color: #000000;\">Fields</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #ff0000;\">\"YourField\"</span><span style=\"color: #000000;\">&#41;</span>:<span style=\"color: #000000;\">Value</span> := <span style=\"color: #ff0000;\">\"Test\"</span><br />oRs:<span style=\"color: #0000ff;\">Update</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span><br /><br /><span style=\"color: #0000ff;\">xBrowse</span><span style=\"color: #000000;\">&#40;</span> oRs <span style=\"color: #000000;\">&#41;</span><br /><br />oRs:<span style=\"color: #000000;\">CLose</span><span style=\"color: #000000;\">&#40;</span><span style=\"color: #000000;\">&#41;</span><br /> </div>[/code:3o04bzri]\n\nThe above code assumes that you have a Primary key that is auto created... xConnect is your connection string to MySql.\n\nRick Lipkin", "time": "13:56", "topic": "ADO and MySql", "username": "Rick Lipkin" } ]
ADO and MySql
[ { "date": "2013-07-10", "forum": "FiveWin for Harbour/xHarbour", "text": "Thanks Rick - much appreciated.\n\nColin", "time": "00:45", "topic": "ADO and MySql", "username": "Colin Haig" } ]
ADO and MySql
[ { "date": "2017-07-20", "forum": "FiveWin for Harbour/xHarbour", "text": "hi\nI have this code\n[code=fw:2b7k45tt]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\"><br /><br />@ <span style=\"color: #000000;\">40</span>, <span style=\"color: #000000;\">10</span> <span style=\"color: #0000ff;\">GET</span> o_get <span style=\"color: #0000ff;\">VAR</span> m_get MEMO <span style=\"color: #0000ff;\">OF</span> <span style=\"color: #0000ff;\">dialog</span> <span style=\"color: #0000ff;\">SIZE</span> <span style=\"color: #000000;\">450</span>, <span style=\"color: #000000;\">200</span>   <span style=\"color: #0000ff;\">PIXEL</span><br /><br />oRs := FW_OpenRecordSet<span style=\"color: #000000;\">&#40;</span> oCn, m_Get, <span style=\"color: #000000;\">1</span> <span style=\"color: #000000;\">&#41;</span><br />...<br />@ <span style=\"color: #000000;\">40</span>,<span style=\"color: #000000;\">10</span> <span style=\"color: #0000ff;\">XBROWSE</span> oBrw <span style=\"color: #0000ff;\">SIZE</span> <span style=\"color: #000000;\">-10</span>,<span style=\"color: #000000;\">-50</span> <span style=\"color: #0000ff;\">PIXEL</span> CELL AUTOSORT;<br />RECORDSET oRs <span style=\"color: #0000ff;\">AUTOCOLS</span>;<br /><span style=\"color: #0000ff;\">OF</span> oDlg2    <br /> </div>[/code:2b7k45tt]\nIn m_get I put my Select... (Select * FROM...)\nXBROWSE shows two decimal numbers but I want four decimal numbers\nI can not to use PICTURE because SELECT change according to what I write in m_get\n\nthank you", "time": "07:33", "topic": "ADO and decimal numbers", "username": "damianodec" } ]
ADO and decimal numbers
[ { "date": "2017-07-20", "forum": "FiveWin for Harbour/xHarbour", "text": "Ciao ,\ntry \n\n SET DECIMALS TO 4\n\nMaurizio \n<!-- w --><a class=\"postlink\" href=\"http://www.nipeservice.com\">www.nipeservice.com</a><!-- w -->", "time": "07:57", "topic": "ADO and decimal numbers", "username": "Maurizio" } ]
ADO and decimal numbers
[ { "date": "2017-07-20", "forum": "FiveWin for Harbour/xHarbour", "text": "Hi\nciao Maurizio\n\nSET DECIMAL TO is inside at the top of .prg but not work with ADO", "time": "08:16", "topic": "ADO and decimal numbers", "username": "damianodec" } ]
ADO and decimal numbers
[ { "date": "2017-07-20", "forum": "FiveWin for Harbour/xHarbour", "text": "Please make this modification in your xbrowse.prg:\n\nPlease locate the following lines in METHOD SetColFromADO(...)\n[code=fw:wj8iv9yq]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\"> &nbsp; <span style=\"color: #00C800;\">CASE</span> ASCAN<span style=\"color: #000000;\">&#40;</span> <span style=\"color: #000000;\">&#123;</span> <span style=\"color: #000000;\">4</span>, <span style=\"color: #000000;\">5</span>, <span style=\"color: #000000;\">6</span> <span style=\"color: #000000;\">&#125;</span>, nType <span style=\"color: #000000;\">&#41;</span> > <span style=\"color: #000000;\">0</span> &nbsp;<span style=\"color: #B900B9;\">// Single, Double, Currency</span><br />&nbsp; &nbsp; &nbsp; cType &nbsp; &nbsp; &nbsp; &nbsp; := <span style=\"color: #ff0000;\">'N'</span><br />&nbsp; &nbsp; &nbsp; nLen &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:= oField:<span style=\"color: #000000;\">Precision</span><br />&nbsp; &nbsp; &nbsp; nDec &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:= <span style=\"color: #000000;\">2</span><br />&nbsp;</div>[/code:wj8iv9yq]\n\nPlease change the last line as:\n[code=fw:wj8iv9yq]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\"><br />&nbsp; &nbsp; &nbsp; &nbsp;nDec &nbsp;:= Set<span style=\"color: #000000;\">&#40;</span> _SET_DECIMALS <span style=\"color: #000000;\">&#41;</span><br />&nbsp;</div>[/code:wj8iv9yq]\n\nNow, in your code \nSET DECIMALS TO 4 and run your program\nPlease let us know if this is working ok for you.", "time": "17:27", "topic": "ADO and decimal numbers", "username": "nageswaragunupudi" } ]
ADO and decimal numbers
[ { "date": "2017-07-21", "forum": "FiveWin for Harbour/xHarbour", "text": "hi Mr Rao thank you\nI try this in xbrowse.prg\n[code=fw:shxqfnam]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\">   <span style=\"color: #00C800;\">CASE</span> ASCAN<span style=\"color: #000000;\">&#40;</span> <span style=\"color: #000000;\">&#123;</span> <span style=\"color: #000000;\">4</span>, <span style=\"color: #000000;\">5</span>, <span style=\"color: #000000;\">6</span> <span style=\"color: #000000;\">&#125;</span>, nType <span style=\"color: #000000;\">&#41;</span> > <span style=\"color: #000000;\">0</span>  <span style=\"color: #B900B9;\">// Single, Double, Currency</span><br />      cType         := <span style=\"color: #ff0000;\">'N'</span><br />      nLen          := oField:<span style=\"color: #000000;\">Precision</span><br />      nDec          := Set<span style=\"color: #000000;\">&#40;</span> _SET_DECIMALS <span style=\"color: #000000;\">&#41;</span><br />*     nDec          := <span style=\"color: #000000;\">2</span></div>[/code:shxqfnam]\nand in my.prg\n[code=fw:shxqfnam]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\">   SET DATE ITALIAN<br />    SET DELETED <span style=\"color: #0000ff;\">ON</span><br />    SET CENTURY <span style=\"color: #0000ff;\">ON</span><br />    SET CONFIRM <span style=\"color: #0000ff;\">ON</span><br />    SET DECIMALS <span style=\"color: #0000ff;\">TO</span> <span style=\"color: #000000;\">4</span><br />    SET FIXED <span style=\"color: #0000ff;\">ON</span>   </div>[/code:shxqfnam]\n\nInside file LINK1.RSP there is list of all .obj to compile and I put in xbrowse.obj \n\n[code=fw:shxqfnam]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\"><span style=\"color: #00C800;\">IF</span> NOT ERRORLEVEL <span style=\"color: #000000;\">1</span> <span style=\"color: #00C800;\">IF</span> EXIST *.obj c:\\borland\\bcc55\\bin\\ilink32 c0w32 @link1.rsp</div>[/code:shxqfnam]\n\n[code=fw:shxqfnam]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\">...<br />prvmail.obj +<br />sendmail1.obj +<br />sendmail2.obj +<br />interact.obj +<br /><span style=\"color: #0000ff;\">xbrowse</span>.obj +<br />funzio.obj, +<br />MYEXE.exe, + <br />MYEXE.map, ...+</div>[/code:shxqfnam]\n\nbut in my browse I still get two decimals", "time": "07:47", "topic": "ADO and decimal numbers", "username": "damianodec" } ]
ADO and decimal numbers
[ { "date": "2017-07-24", "forum": "FiveWin for Harbour/xHarbour", "text": "I Mr Rao\nin xBrowse i changed oCol:nDataDec in SetColFromADO METHOD\n[code=fw:1jz3udsy]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\"><br /><span style=\"color: #00C800;\">if</span> nDec != <span style=\"color: #00C800;\">nil</span><br />*      oCol:<span style=\"color: #000000;\">nDataDec</span>  := <span style=\"color: #0000ff;\">Min</span><span style=\"color: #000000;\">&#40;</span> nDec, <span style=\"color: #000000;\">2</span> <span style=\"color: #000000;\">&#41;</span><br />       oCol:<span style=\"color: #000000;\">nDataDec</span>  :=  nDec <br /><span style=\"color: #00C800;\">endif</span></div>[/code:1jz3udsy]\n\nand now works", "time": "08:37", "topic": "ADO and decimal numbers", "username": "damianodec" } ]
ADO and decimal numbers
[ { "date": "2017-07-30", "forum": "FiveWin for Harbour/xHarbour", "text": "[quote=\"damianodec\":293nk86n]I Mr Rao\nin xBrowse i changed oCol:nDataDec in SetColFromADO METHOD\n[code=fw:293nk86n]<div class=\"fw\" id=\"{CB}\" style=\"font-family: monospace;\"><br /><span style=\"color: #00C800;\">if</span> nDec != <span style=\"color: #00C800;\">nil</span><br />*      oCol:<span style=\"color: #000000;\">nDataDec</span>  := <span style=\"color: #0000ff;\">Min</span><span style=\"color: #000000;\">&#40;</span> nDec, <span style=\"color: #000000;\">2</span> <span style=\"color: #000000;\">&#41;</span><br />       oCol:<span style=\"color: #000000;\">nDataDec</span>  :=  nDec <br /><span style=\"color: #00C800;\">endif</span></div>[/code:293nk86n]\n\nand now works[/quote:293nk86n]\nThis seems to be code from an older version.\nCurrent version is just what you corrected.\nSo my first modification was working for me without problems", "time": "17:39", "topic": "ADO and decimal numbers", "username": "nageswaragunupudi" } ]
ADO and decimal numbers