Posts

Showing posts with the label stored-procedures

Add another character not existing in table when export to text file

Image
Clash Royale CLAN TAG #URR8PPP Add another character not existing in table when export to text file I create a procedure to export data to text file. It be like: 'bcp "select name,age,grade from test" queryout C:test.txt however i want to add some other character like |. And output file content would be like: Jones|6 C. Which is the most convenient way to do that. Should i create a temporary table? you mean use | as seperator ? use a BCP format file – Squirrel 10 mins ago | BCP @Squirrel that's such a good answer. I never think about that solution. so my command should be 'bcp "select name,age,grade from test" -i test.fmt queryout C:test.txt Is it right? – Nguyen Van Hung 6 mins ago ...

Passing an ArrayList of Java Objects While Calling a Stored Procedure Using Spring JDBC

Image
Clash Royale CLAN TAG #URR8PPP Passing an ArrayList of Java Objects While Calling a Stored Procedure Using Spring JDBC What is the Right approach for passing an arraylist of java objects to a stored procedure. Internally the Stored procedure expects a collection of a particular data type . Currently i am trying the following but it is not working example : //Setting the JdbcCall Object SimpleJdbcCall jdbcCall = new SimpleJdbcCall(jdbcTemplate) .withProcedureName("name") .withCatalogName("catalog") .withoutProcedureColumnMetaDataAccess() .declareParameters(new SqlParameter( "input_parameter1", Types.ARRAY, "SAMPLELIST"), new SqlOutParameter("P_ERROR_MESSAGE" , Types.VARCHAR)); //Creating the list of objects to be sent to proc List<SampleObject> list = new ArrayList<>...

Get week number and start date and end date between two given dates in postgresql

Image
Clash Royale CLAN TAG #URR8PPP Get week number and start date and end date between two given dates in postgresql I am trying to create a function that calculates the week number between two dates. For example, the function received two dates 2018-07-02 and 2018-07-27 . So The return I want to is 2018-07-02 2018-07-27 week_id | week_start_date | week_end_date week1 | 2018-07-02 | 2018-07-08 week2 | 2018-07-09 | 2018-07-15 week3 | 2018-07-16 | 2018-07-22 week4 | 2018-07-23 | 2018-07-27 I was able to do the calculation, but how may I return the result? The code I have done is below. Any help will be appreciated. --DROP FUNCTION public.find_week_numebr_by_date(integer, timestamp without time zone, timestamp without time zone); CREATE OR REPLACE FUNCTION public.find_week_numebr_by_dates( v_institution_id integer default null::integer, v_start_time timestamp without time zone default null:: timestamp without time zone, v_end_time timestamp without tim...