Focal Point
[CLOSED] SQL INSERT command

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/6511032802

January 19, 2007, 02:14 AM
DarrenH
[CLOSED] SQL INSERT command
Hi all,
I'm waiting to get my hands on some FOCUS docs, but in the meantime am trying to figure it out myself Smiler

I have a requirement to write a simple stored procedure to insert a few static values into a SQL table.

I guess at the lowest level this should be the only code I need:

-*-- Set up the SQL Environment ----------------------------
SET SQLENGINE = SQLMSS
SQL SET SERVER MYSERVER
-RUN


-*-- Insert row ----------
SQL INSERT MYDB.dbo.MYTABLE (FIELD1, FIELD2)
VALUES('1','2')
END
-RUN

BUT - I am getting an 'INTERFACE OUT OF SEQUENCE' error.
What is the correct syntax for inserting values into a table?

Many thanks!

This message has been edited. Last edited by: Kerry,


Prod: Service Manager 5.5 - DataMigrator 7.6 - Win2K
Test: Service Manager 5.5 - DataMigrator 7.6 - Win2K
Local: DevStudio 5.5.3 - Management Console
- Windows XP SP2
January 19, 2007, 03:00 AM
Tony A
Darren,

When using SQL passthru you need to process the SQL by getting WF to use it. Think of the passthru as the setting up of a temporary view. The view is there but you don't get the data unless you execute it.

Try this -
-*-- Set up the SQL Environment ----------------------------
SET SQLENGINE = SQLMSS
SQL SET SERVER MYSERVER
-RUN

-*-- Insert row ----------
SQL
  INSERT INTO MYDB.dbo.MYTABLE (FIELD1, FIELD2) VALUES('1','2')
;
TABLE FILE SQLOUT
PRINT *
END
-RUN


Good luck

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
January 19, 2007, 03:26 AM
DarrenH
Thanks Tony. I guess it's just getting my head around it conceptually now Smiler

That *seems* to work in that it doesn't return any errors, but it doesn't actually populate my table. I have double-checked my synonym definition for the destination and it's all okay. When I run the code I get a return of
"(FOC1364) ROWS AFFECTED BY PASSTHRU COMMAND: 1/INSERT" which I guess means this should have worked?


Prod: Service Manager 5.5 - DataMigrator 7.6 - Win2K
Test: Service Manager 5.5 - DataMigrator 7.6 - Win2K
Local: DevStudio 5.5.3 - Management Console
- Windows XP SP2
January 19, 2007, 03:57 AM
hammo1j
Darren

Yes that's wf reporting back its done its stuff.

Regarding the syntax of the INSERT in wf - you dont need the table since no answerset is returned unlike a select.

However the semi colon and END are essential...

SQL
INSERT INTO MYDB.dbo.MYTABLE (FIELD1, FIELD2) VALUES('1','2')
;
END

John



Server: WF 7.6.2 ( BID/Rcaster) Platform: W2003Server/IIS6/Tomcat/SQL Server repository Adapters: SQL Server 2000/Oracle 9.2
Desktop: Dev Studio 765/XP/Office 2003 Applications: IFS/Jobscope/Maximo
January 19, 2007, 04:09 AM
DarrenH
Excellent! You guys have made my Friday a whole lot easier.

All working now - thanks!


Prod: Service Manager 5.5 - DataMigrator 7.6 - Win2K
Test: Service Manager 5.5 - DataMigrator 7.6 - Win2K
Local: DevStudio 5.5.3 - Management Console
- Windows XP SP2
January 19, 2007, 08:05 AM
<DocServices>
Hi Darren,

If you have an InfoResponse ID, log on to the Tech Support Web site and then access i-Base. By logging in first, you can download the FOCUS manuals in PDF format and/or view the HTMLHelp version.

You can access i-Base via the following Web sites:


Hope this helps.

Regards,
Jennifer
January 22, 2007, 11:05 AM
ira
Hi, I believe I caqn help you - what release of WF are you using; it does make a difference...


aix-533,websphere 5.1.1,apache-2.0,
wf 538(d), 537 (p),
==============
7.6.11 (t) aix 5312
websphere 6.1.19
apache 2.0
September 15, 2010, 01:53 PM
Ted Michalski
On the same subject, I have the following code:

-SET &MONTH = EDIT(&DATEMtDwY,'999$-$$$99'); (which returns Sep-10)

ENGINE SQLMSS SET DEFAULT_CONNECTION XXXX
-RUN
SQL SQLMSS
INSERT INTO XXXX.dbo.EVAL.XXX_XXX_XXX
VALUES
( 1
, 50
, 1
, NULL
, &MONTH
, NULL
, NULL
, CURRENT_TIMESTAMP
, 'ID') ;
END


And I get the following error message:
: Microsoft OLE DB Provider for SQL Server: [42000] The name "Sep" is not: permitted in this context. Valid expressions are constants, constant exp: ressions, and (in some contexts) variables. Column names are not permitt: ed.

Why would it think Sep is a column name?


7.7.02
Windows
EXCEL, PDF, CSV, TEXT
September 15, 2010, 02:01 PM
Francis Mariani
You must place text values within single quotes, just like any SQL INSERT statement.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
September 15, 2010, 02:03 PM
<JG>
quote:
-SET &MONTH = EDIT(&DATEMtDwY,'999$-$$$99'); (which returns Sep-10)

If you want to add comments to code make sure that you tell WebFOCUS they are comments.
Otherwise it will try to execute what it thinks is code.

-*
September 15, 2010, 02:18 PM
Ted Michalski
Thanks Francis. I tried this also and it gave me the same error:

-SET &MONTH = EDIT(&DATEMtDwY,'999$-$$$99');
-SET &MONTHB = ''||&MONTH || '' ;


ENGINE SQLMSS SET DEFAULT_CONNECTION XXX
-RUN
SQL SQLMSS
INSERT INTO XXX.dbo.EVAL.XX_XXX_XX
VALUES
( 1
, 50
, 1
, NULL
, NULL
, &MONTHB
, NULL
, CURRENT_TIMESTAMP
, 'FCGSRPPR') ;
END


7.7.02
Windows
EXCEL, PDF, CSV, TEXT
September 15, 2010, 02:19 PM
Francis Mariani
The SQL statement should look like this:

SQL SQLMSS
INSERT INTO XXXX.dbo.EVAL.XXX_XXX_XXX
VALUES
( 1
, 50
, 1
, NULL
, '&MONTH'
, NULL
, NULL
, CURRENT_TIMESTAMP
, 'ID') ;
END



Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
September 15, 2010, 02:23 PM
Ted Michalski
Oh, I thought that WF would think I was trying to put literally "&MONTH" into the text field. Thansk again. I'll give this a try.


7.7.02
Windows
EXCEL, PDF, CSV, TEXT